summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
Commit message (Collapse)AuthorAgeFilesLines
* BUG: properly handle tuple keys in NpZFile.__getitem__ (#23757)Nathan Goldbaum2023-05-121-0/+11
| | | | | | | | | * BUG: properly handle tuple keys in NpZFile.__getitem__ * TST: test tuple rendering specifically. --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* TST: add tests for numpy.quantile (#23129)Christian Lorentzen2023-04-281-5/+100
| | | | | | | | | | This PR adds additional tests for quantiles: 1. Identification equation $E[V(q, Y)] = 0$ 2. Adding a constant $c > 0$: $q(c + Y) = c + q(Y)$ 3. Multiplying by a constant $c > 0$: $q(c \cdot Y) = c \cdot q(y)$ 4. Multiplying by $-1$: $q_{\alpha}(-Y) = -q_{1-\alpha}(Y)$ (Note by seberg as reviewer: These tests are fairly complex, but may be useful for future development. But if they seem too complicated, they are probably not really vital and could be shortened or removed.)
* ENH: ``__repr__`` for NpzFile object (#23357)Ganesh Kathiresan2023-04-061-2/+17
| | | | | | | | | | | Improves the repr to include information about the arrays contained, e.g.: >>> npzfile = np.load('arr.npz') >>> npzfile NpzFile 'arr.npz' with keys arr_0, arr_1, arr_2, arr_3, arr_4... closes #23319 Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Fixed failing testsMatteo Raso2023-04-011-4/+11
|
* Fixed docstring testMatteo Raso2023-04-011-1/+2
|
* Fixed edge case where pyfunc has no attribute `__name__`Matteo Raso2023-04-011-12/+68
|
* Revert "ENH: Enabled the use of numpy.vectorize as a decorator"Matti Picus2023-03-271-55/+0
|
* Merge pull request #23061 from MatteoRaso/vectorizeMatti Picus2023-03-261-0/+55
|\ | | | | ENH: Enabled the use of numpy.vectorize as a decorator
| * @vectorize now requires arguments to specify keywordsMatteo Raso2023-02-091-10/+9
| | | | | | | | This reverses commit 7a2ded1522305
| * Added a test for positional args (PR-23061)Matteo Raso2023-02-081-0/+11
| |
| * Added test for vectorize decorator projectMatteo Raso2023-01-271-0/+8
| | | | | | | | | | This test makes sure a function's docstring is properly preserved after calling the vectorize decorator.
| * ENH: Enabled use of numpy.vectorize as decorator (#9477)Matteo Raso2023-01-211-0/+30
| | | | | | | | | | | | | | | | Most of this code comes from PR-9593, but with the default value for pyfunc being numpy._NoValue instead of None, no override of __new__, and no effort to make subclassing possible. Co-Authored-By: Michael Lamparski <diagonaldevice@gmail.com>
| * BUG: Added __name__ atribute to vectorize class (#23021)Matteo Raso2023-01-181-0/+7
| |
* | MAINT: remove `NUMPY_EXPERIMENTAL_ARRAY_FUNCTION` env varRalf Gommers2023-03-121-9/+2
| | | | | | | | | | | | | | | | As discussed in https://mail.python.org/archives/list/numpy-discussion@python.org/thread/UKZJACAP5FUG7KP2AQDPE4P5ADNWLOHZ/ This flag was always meant to be temporary, and cleaning it up is long overdue.
* | DEP: expire deprecation for "y as out" in fix/isposinf/isneginfRalf Gommers2023-03-121-6/+0
| |
* | DEP: deprecate `product`, `cumproduct`, `sometrue`, `alltrue`Ralf Gommers2023-03-022-5/+5
| | | | | | | | [skip cirrus]
* | Merge pull request #23089 from seberg/numpy2-flagMatti Picus2023-02-121-0/+7
|\ \ | | | | | | API: Add environment variable for behavior planned in a 2.0
| * | MAINT: Use `np._using_numpy2_behavior()` and initialize it in CSebastian Berg2023-02-101-1/+1
| | |
| * | API: Modify `gradient` to return a tuple rather than a listSebastian Berg2023-02-101-0/+7
| | | | | | | | | | | | | | | This change is staged for NumPy 2.0, I assume we could get away with it otherwise, but it is a nice example and probably not pressing.
* | | MAINT, DOC: string_ → bytes_ and unicode_ → str_Dimitri Papadopoulos2023-02-101-12/+12
|/ /
* | API: Raise EOFError when trying to load past the end of a `.npy` file (#23105)Noé Rubinstein2023-01-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the following code: ``` import numpy as np with open('foo.npy', 'wb') as f: for i in range(np.random.randint(10)): np.save(f, 1) with open('foo.npy', 'rb') as f: while True: np.load(f) ``` Will raise: ``` ValueError: Cannot load file containing pickled data when allow_pickle=False ``` While there is no pickled data in the file.
* | DEP: Finalize the non-sequence stacking deprecationSebastian Berg2023-01-171-2/+2
| | | | | | | | | | | | | | | | | | The `__array_function__` API currently will exhaust iterators so we cannot accept sequences reasonably. Checking for `__getitem__` is presumably enough to reject that (and was what the deprecation used). Future changes could allow this again, although it is not a useful API anyway, since we have to materialize the iterable in any case.
* | ENH: Faster numpy.load (try/except _filter_header) (#22916)Michael2023-01-131-1/+2
| | | | | | | | | | | | | | This pull requests speeds up numpy.load. Since _filter_header is quite a bottleneck, we only run it if we must. Users will get a warning if they have a legacy Numpy file so that they can save it again for faster loading. Main discussion and benchmarks see #22898 Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* | ENH: Improve loadtxt error with dtype and non-matchinig column number (#22996)Sebastian Berg2023-01-111-1/+10
| | | | | | | | The number "changed" is weird if the user fixed it, so give a different message in that case.
* | BUG: np.loadtxt cannot load text file with quoted fields separated by ↵dmbelov2023-01-011-0/+14
|/ | | | | | | whitespace (#22906) Fix issue with `delimiter=None` and quote character not working properly (not using whitespace delimiter mode). Closes gh-22899
* BUG: Fix integer overflow in in1d for mixed integer dtypes #22877 (#22878)Miles Cranmer2022-12-251-2/+37
| | | | | | | | | | | | | | | | | | | * TST: Mixed integer types for in1d * BUG: Fix mixed dtype overflows for in1d (#22877) * BUG: Type conversion for integer overflow check * MAINT: Fix linting issues in in1d * MAINT: ar1 overflow check only for non-empty array * MAINT: Expand bounds of overflow check * TST: Fix integer overflow in mixed boolean test * TST: Include test for overflow on mixed dtypes * MAINT: Less conservative overflow checks
* TST: Ignore nan-warnings in randomized out testsSebastian Berg2022-12-221-0/+2
| | | | | | | | The tests randomize the nan pattern and thus can run into these (additional) warnings, so ignore them. (Could also fix the random seed, but this should do) Closes gh-22835
* BUG: Ensure correct behavior for rows ending in delimiter in loadtxt (#22836)Sebastian Berg2022-12-191-0/+12
| | | | | | | If a row ends in a delimiter, `add_fields` can be called twice without any field actually being parsed. This causes issues with the field buffer setup. closes gh-22833
* TST: Remove outdated xfail from quantile testsSebastian Berg2022-12-141-1/+0
| | | | There should be more tests for this, but this now passes.
* BUG: Quantile function on complex number now throws an error (#22652) (#22703)Matteo Raso2022-12-082-13/+49
| | | | | | | | | | | | | | | | | Since percentile is more or less identical to quantile, I also made it throw an error if it receives a complex input. I also made nanquantile and nanpercentile throw errors as well. * Made the changes recommended by seberg * Fixed a test for PR 22703 * Fixed tests for quantile * Shortened some more lines * Fixup more lines Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>
* BUG: fix unexpected return of np.pad with mode=wrap (#22575)LU2022-12-071-0/+17
| | | | | | | | | np.pad with mode="wrap" returns unexpected result that original data is not strictly looped in padding. This may happen in some occassions when padding widths in the same dimension are unbalanced (see added testcase in test_arraypad.py and the related issue). The reason is the function pad makes iterative calls of _set_wrap_both() in the above situation, yet period for padding is not correctly computed in each iteration. The bug is fixed by guaranteeing that period is always a multiple of original data size, and also be the possible maximum for computation efficiency. Closes #22464 Co-authored-by: Lars Grüter <lagru+github@mailbox.org>
* BUG: `keepdims=True` is ignored if `out` is not `None` in `numpy.median()`, ↵Roy Smart2022-12-052-0/+108
| | | | | | `numpy.percentile()`, and `numpy.quantile()`. Closes #22714, #22544.
* BUG: Histogramdd breaks on big arrays in Windows (#22561)Navpreet Singh2022-11-181-0/+11
| | | | | | | | | | | | | | | | | * BUG: Histogramdd breaks on big arrays in Windows Resolved the issue with line change from int to np.intp in numpy/numpy/lib/histograms.py * BUG: Histogramdd breaks on big arrays in Windows Resolved the issue with line change from int to np.intp in numpy/numpy/lib/histograms.py * Removed the binary files * Update test_histograms.py * Update test_histograms.py * Update test_histograms.py
* BLD: update OpenBLAS to 0.3.21 and clean up openblas download test (#22525)Matti Picus2022-11-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * BUILD: update OpenBLAS to 0.3.21 and clean up openblas download test * set LDFLAGS on windows64 like the openblaslib build does * use rtools compilers on windows when building wheels * fix typos * add rtools gfortran to PATH * use the openblas dll from the zip archive without rewrapping * typos * copy dll import library for 64-bit interfaces * revert many of the changes to azure-steps-windows.yaml, copy openblas better in wheels * fix wildcard copy * test OpenBLAS build worked with threadpoolctl * typos * install threadpoolctl where needed, use for loop to recursively copy * update macos OpenBLAS suffixes for newer gfortran hashes * use libgfortran5.dylib on macos * fix scripts * re-use gfortran install from MacPython/gfortran-install on macos * use pre-release version of delocate * fixes for wheel builds/tests * add debugging cruft for pypy+win, macos wheels * add DYLD_LIBRARY_PATH on macosx-x86_64 * use 32-bit openblas interfaces for ppc64le tests * skip large_archive test that sometimes segfaults on PyPy+windows
* TST: Skip tests that are not currently supported in wasmHood Chatham2022-11-113-3/+9
|
* STY: Make linter happySebastian Berg2022-10-271-0/+1
| | | | Not new things, but in touched lines...
* TST,MAINT: Replace most `setup` with `setup_method` (also teardown)Sebastian Berg2022-10-275-24/+24
| | | | | | | | In some cases, the replacement is clearly not what is intended, in those (where setup was called explicitly), I mostly renamed `setup` to `_setup`. The `test_ccompile_opt` is a bit confusing, so left it right now (this will probably fail)
* MAINT: remove u-prefix for former Unicode strings (#22479)Mike Taves2022-10-263-17/+17
|
* DEP: Add deprecation warning and check warning in test.Ross Barnowski2022-10-191-5/+6
|
* ENH: unstructured_to_structured converts dtype argument (#22442)LeonaTaric2022-10-191-0/+9
| | | | | | | | | | | | Before: >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=[('x', float), ('y', float)]) # failed >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=np.dtype([('x', float), ('y', float)])) # success After: >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=[('x', float), ('y', float)]) # success >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=np.dtype([('x', float), ('y', float)])) # success Closes gh-22428
* MAINT: Fix typos found by codespellDimitri Papadopoulos2022-10-071-1/+1
|
* Merge pull request #22393 from seberg/npy_headerMatti Picus2022-10-071-3/+44
|\ | | | | MAINT: Ensure graceful handling of large header sizes
| * MAINT: Ensure graceful handling of large header sizesSebastian Berg2022-10-061-3/+44
| | | | | | | | | | | | | | | | | | This ensures graceful handling of large header files. Unfortunately, it may be a bit inconvenient for users, thus the new kwarg and the work-around of also accepting allow-pickle. See also the documation here: https://docs.python.org/3.10/library/ast.html#ast.literal_eval
* | add spare space for growth for .npy filesMichael Siebert2022-09-261-6/+21
|/
* Merge pull request #22319 from sjtechdev/21257/add_kron_functional_testsCharles Harris2022-09-221-0/+29
|\ | | | | TST: add functional tests for kron
| * TST: add functional tests for kronShreyas Joshi2022-09-211-0/+29
| |
* | MAINT: update function's `__module__` attribute in `deprecate`Josh Wilson2022-09-211-0/+4
|/ | | | | | Currently the location of the function definition is always reported to be `numpy.lib.utils`; this changes it to be the location of the actual definition when possible.
* TST,BUG: Us context from spawn to fork in (#22204)Jyn Spring 琴春2022-09-071-2/+7
| | | | | | | | | | | | | | | Since Python 3.8, the default start method for multiprocessing has been changed from fork to spawn on macOS The default start method is still fork on other Unix platforms[1], causing inconsistency on memory sharing model It will cause a memory-sharing problem for the test test_large_zip on macOS as the memory sharing model between spawn and fork is different The fix Change the start method for this test back to fork under this testcase context In this test case context, the bug that caused default start method changed to spawn for macOS will not be triggered It is context limited, so this change will not affect default start method other than test_large_zip All platforms have the same memory sharing model now After the change, test_large_zip is passed on macOS https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods Closes gh-22203
* BUG: fix np.average for Fraction elementsPieter Eendebak2022-08-101-0/+5
|
* TST: fix test_linear_interpolation_formula_symmetricPal Barta2022-08-101-1/+1
| | | | | | | | | The lerp test compared the output of the original and the symmetric functions by using basic assertion. Double precision errors could accumulate in a way that the 2 outputs mismatch by epsilon. For more information on the precision issue, see #22073 Fix: use assert_allclose instead for float comparison.