summaryrefslogtreecommitdiff
path: root/numpy/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge pull request #16558 from person142/typing-runtimeMatti Picus2020-06-173-16/+5
|\ \ | | | | | | ENH: make typing module available at runtime
| * | MAINT: make typing module available at runtimeJosh Wilson2020-06-093-16/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Closes https://github.com/numpy/numpy/issues/16550. This makes `np.typing.ArrayLike` and `np.typing.DtypeLike` available at runtime in addition to typing time. Some things to consider: - `ArrayLike` uses protocols, which are only in the standard library in 3.8+, but are backported in `typing_extensions`. This conditionally imports `Protocol` and sets `_SupportsArray` to `Any` at runtime if the module is not available to prevent NumPy from having a hard dependency on `typing_extensions`. Since e.g. mypy already includes `typing_extensions` as a dependency, anybody actually doing type checking will have it set correctly. - We are starting to hit the edges of "the fiction of the stubs". In particular, they could just cram everything into `__init__.pyi` and ignore the real structure of NumPy. But now that typing is available a runtime, we have to e.g. carefully import `ndarray` from `numpy` in the typing module and not from `..core.multiarray`, because otherwise mypy will think you are talking about a different ndarray. We will probably need to do some shuffling the stubs into more fitting locations to mitigate weirdness like this.
* | | Merge pull request #14882 from eric-wieser/6103-alias-__getattr__-deprecationSebastian Berg2020-06-161-12/+16
|\ \ \ | | | | | | | | DEP: Deprecate aliases of builtin types in python 3.7+
| * | | DEP: Deprecate aliases of builtin types in python 3.7+Eric Wieser2020-06-121-12/+16
| |/ / | | | | | | | | | | | | | | | | | | | | | This: * Makes accessing these attributes emit a deprecation warning * Removes them from `dir(numpy)`, so as not to emit warnings for user of `inspect.getmembers` These aliases are a continual source of confusion for beginners, and are still often used by accident by experts.
* | | MAINT: changed np.generic arguments to positional-only (#16583)Bas van Beek2020-06-142-0/+18
| |/ |/| | | | | | | | | | | | | | | Closes https://github.com/numpy/numpy/issues/16577. Make the arguments of `np.generic` constructors positional-only. Also fix the constructor of`np.bytes_`: encoding is only supported when supplied a string. The opposite holds for `np.str_`.
* | MAINT: fix name of first parameter to dtype constructor in type stubsJosh Wilson2020-06-101-0/+3
| | | | | | | | | | The first parameter to the constructor is currently called "obj", which is incorrect. It should instead be "dtype".
* | MAINT: simplifying annotations for np.core.from_numeric (#16556)Bas van Beek2020-06-101-10/+0
|/ | | | | | Simplified annotations for functions requiring >=1D ArrayLike objects. Affects a set of <20 functions from ``np.core.fromnumeric``. Based on feedback from https://github.com/numpy/numpy-stubs/pull/71.
* MAINT: avoid more division by zero in typing test causing aarch64 to failJosh Wilson2020-06-071-5/+6
|
* MAINT: avoid divide by zero in typing test causing aarch64 tests to failJosh Wilson2020-06-071-1/+1
|
* MAINT: modify mypy error line parsing to work on windowsJosh Wilson2020-06-071-2/+14
| | | | It currently splits on ":", which causes problems with drives.
* MAINT: move typing tests cases into a subdirectory of numpy/testsJosh Wilson2020-06-0728-6/+6
|
* ENH: add type stubs from numpy-stubsJosh Wilson2020-06-0628-0/+1327
| | | | | | | | | | | | | | | | | | | | | Add the type stubs and tests from numpy-stubs. Things this entails: - Copy over the stubs (numpy/__init__.pyi and numpy/core/_internal.pyi) - The only modification made was removing `ndarray.tostring` since it is deprecated - Update some setup.py files to include pyi files - Move the tests from numpy-stubs/tests into numpy/tests - Skip them if mypy is not installed (planning on setting up CI in a future PR) - Add a mypy.ini; use it to configure mypy in the tests - It tells mypy where to find NumPy in the test env - It ignores internal NumPy type errors (since we only want to consider errors from the tests cases) - Some small edits were made to fix test cases that were emitting deprecation warnings - Add numpy/py.typed so that the types are picked up in an installed version of NumPy
* BUG: Allow attaching documentation twice in add_docstringSebastian Berg2020-05-191-0/+26
| | | | | | | This is technically not a bug, but some IDEs and IPython have autoreload magic which can mean that NumPy gets reloaded a second time. This is not safe, but when it happens ignoring that an identical docstring is already attached fixes the issue.
* DEP: Deprecate `numpy.dual`.Warren Weckesser2020-05-041-1/+1
| | | | | | Add a deprecation warning in the `numpy.dual` module, and remove the use of `numpy.dual` from the few places where it is used in the numpy code.
* BUG: add missing c_distributions.pxd, enables cython use of random C-API ↵Matti Picus2020-03-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (gh-15463) xref gh-14778 As pointed out in the comment by @jamesthomasgriffin, we did not include a pxd file to expose the distribution functions documented in the random c-api. This PR adds a c_distributions.pxd file that exposes them. Squashed commits: * BUG: add missing c_distributions.pxd to enable cython use of random C-API * ENH, TST: add npyrandom library like npymath, test cython use of it * BUG: actually prefix f-string with f * MAINT: fixes from review, add _bit_generato_bit_generator.pxd * STY: fixes from review * BLD: don't use nprandom library for mtrand legacy build * TST: WindowsPath cannot be used in subprocess's list2cmdline * MAINT, API: move _bit_generator to bit_generator * DOC: add release note about moving bit_generator * DOC, MAINT: fixes from review * MAINT: redo dtype determination from review
* MAINT: cleanup unused imports; avoid redefinition of importsMike Taves2020-02-063-4/+1
| | | | | | | * Cleanup unused imports (F401) of mostly standard Python modules, or some internal but unlikely referenced modules * Where internal imports are potentially used, mark with noqa * Avoid redefinition of imports (F811)
* MAINT: dir(numpy) returned duplicate "testing" (gh-15425)SanthoshBala182020-01-271-0/+6
| | | | | Modified __dir__() to remove duplicate "Tester/Testing" attribute. Also added a test to verify this. Closes gh-15383
* Merge pull request #15381 from sethtroisi/matlib_namespaceMatti Picus2020-01-271-8/+0
|\ | | | | DEP: add PendingDeprecation to matlib.py funky namespace
| * DEP: deprecate importing numpy/matrixlib.pySeth Troisi2020-01-231-8/+0
| |
* | MAINT: Replace basestring with str.Charles Harris2020-01-231-1/+0
|/ | | | | | | This replaces basestring with str except in - tools/npy_tempita/ - numpy/compat/py3k.py
* MAINT: Python2 CleanupsSeth Troisi2020-01-211-1/+1
|
* MAINT: Remove sys.version checks in testsSeth Troisi2020-01-153-63/+56
|
* Merge remote-tracking branch 'upstream/master' into ↵Eric Wieser2020-01-067-20/+5
|\ | | | | | | remove-numpy.distutils.compat
| * MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-5/+5
| | | | | | | | | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
| * MAINT: Remove unused int_asbufferJon Dufresne2020-01-041-1/+0
| | | | | | | | | | | | | | On Python 3, int_asbuffer throws NotImplementedError and goes unused internally. Fixes #12425
| * MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-037-14/+0
| | | | | | | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* | MAINT: Delete numpy.distutils.compatEric Wieser2020-01-061-1/+0
|/ | | | `get_exception` has no callers as of this commit's parent, and is hard to argue as public API given the only docstring in the file refers to "inside distutils".
* MAINT: move numpy/random/examples -> numpy/random/_examplesmattip2019-11-191-1/+0
|
* API: restructure and document numpy.random C-API (#14604)Matti Picus2019-11-191-1/+2
| | | | | | | | | | | | | | | | * API: restructure and document numpy.random C-API * DOC: fix bad reference * API: ship, document, and start to test numpy.random C-API examples * API, DOC, TST: fix tests, refactor documentation to include snippets * BUILD: move public headers to numpy/core/include/numpy/random * TST: ignore DeprecationWarnings in setuptools and numba * DOC: document the C-API as used from Cython
* API: move bit_generator and generator to be privatemattip2019-10-111-2/+0
|
* API: make BitGenerators privatemattip2019-10-111-4/+0
|
* API: rename common, bounded_integers -> _common, _bounded_integers; cleanupmattip2019-10-111-2/+0
|
* MAINT: remove unused numpy/f2py/info.py fileRalf Gommers2019-09-221-1/+0
|
* DOC: clean up numpy.lib docstring, remove numpy/lib/info.pyRalf Gommers2019-09-221-1/+0
|
* DOC: add up-to-date numpy.linalg docstring, remove info.py fileRalf Gommers2019-09-221-1/+0
| | | | | | Docstring isn't used to render the html docs, that is controlled by ``routines.linalg.rst``. Still good to bring the contents of function listings of the module docstring in line with that file.
* MAINT: remove stray numpy/random/info.py fileRalf Gommers2019-09-221-1/+0
|
* DOC: add a numpy.distutils module docstring, remove info.py fileRalf Gommers2019-09-221-1/+0
|
* DOC: remove numpy/core/info.py and incomplete docstring for core.Ralf Gommers2019-09-221-1/+0
|
* DEP: remove deprecate (and private) numpy.testing submodules.Ralf Gommers2019-09-211-3/+0
| | | | | | | | | | | Removes these files that were deprecated since 1.15.0: - numpy/testing/decorators.py - numpy/testing/noseclasses.py - numpy/testing/nosetester.py This also resolves a failure in the recently introduced tests in `test_public_api.py` (see gh-14454). Closes gh-14566
* TST: add test to check that (semi-)public API modules can be importedRalf Gommers2019-09-191-17/+68
| | | | | Also remove `numpy.ma.version.py`, it was not importable and served no purpose.
* TST: remove random.entropy from public API test, it was removed in gh-14498Ralf Gommers2019-09-191-1/+0
|
* TST: make xfailed test for modules in public API pass.Ralf Gommers2019-09-191-3/+35
|
* TST: add comment on public/semi-private modules.Ralf Gommers2019-09-191-21/+31
| | | | Also address other review comments.
* MAINT: add missing 'Arrayterator' to `numpy.lib.__all__`Ralf Gommers2019-09-191-5/+6
| | | | | | | Also finish the TODO about figuring out which np.lib.<submodule>'s are public. This is a giant mess ...
* TST: add details to the public modules test about how to check public-nessRalf Gommers2019-09-191-0/+15
|
* TST: add `core/generate_numpy_api.py` to private-but-present modulesRalf Gommers2019-09-191-0/+1
|
* TST: add test to prevent new public-looking modules being addedRalf Gommers2019-09-191-1/+288
|
* MAINT: Lazy import testing on python >=3.7 (#14097)Mark Harfouche2019-08-221-0/+23
| | | | | On new python versions, the module level `__getattr__` can be used to import testing and Tester only when needed (at no speed cost, except for the first time import). Since most users never use testing, this avoids an expensive import.
* MAINT: Fix errors seen on new python 3.8Sebastian Berg2019-05-211-1/+1
| | | | | | | | | | | | | | One of this is a small issue exposed by new warnings, the others are simply adapting our test suit to stricter integer coercion rules (avoiding float -> int conversions). The last one is that we assumed pickle protocol 5 would be in 3.8. It is not yet included in the alpha releases at least. It seems not necessary for the numpy test suit to check whether it is available based on the python version so removing that test. (Also testing if the pickle5 module works seems unnecessary.) Closes gh-13412
* DOC: Added maximum_sctype to documentationJoseph Fox-Rabinovitz2019-02-271-1/+0
|