summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Revert "ENH: Adding __array_ufunc__ capability to MaskedArrays."mattip2022-07-201-1/+1
| | | | This reverts commit 8cd6f4ca00b6e0da3833fc267d50067b2ddbc069.
* ENH: Adding __array_ufunc__ capability to MaskedArrays.Greg Lucas2022-07-131-1/+1
| | | | | | This enables any ufunc numpy operations that are called on a MaskedArray to use the masked version of that function automatically without needing to resort to np.ma.func() calls.
* Revert "ENH: Adding __array_ufunc__ capability to MaskedArrays"Matti Picus2022-07-091-1/+1
|
* ENH: Adding __array_ufunc__ capability to MaskedArrays.Greg Lucas2022-06-291-1/+1
| | | | | | This enables any ufunc numpy operations that are called on a MaskedArray to use the masked version of that function automatically without needing to resort to np.ma.func() calls.
* BUG: Fix numpy.isin for timedelta dtype (#21860)Miles Cranmer2022-06-291-0/+31
| | | | | | | | | | | | | | | | | | | | | This PR fixes the issue discussed on #12065 and #21843 where 'timedelta64' was noted to be a subtype of numpy.integer. This in principle should detect any cases where int(np.min(ar2)) fails. This PR also adds unittests for these. * TST: Create in1d test for timedelta input * MAINT: fix in1d for timedelta input * TST: in1d raise ValueError for timedelta input * MAINT: Clean up type checking for isin kind="table" * TST: Add test for mixed boolean/integer in1d * MAINT: Increase readability of in1d type checking * STY: Apply small code style tweaks This is probably really mainly my personal opinion... Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* Merge pull request #21863 from seberg/fpe-warning-simplificationCharles Harris2022-06-281-2/+1
|\ | | | | ENH,MAINT: Improve and simplify scalar floating point warnings
| * ENH,MAINT: Improve and simplify scalar floating point warningsSebastian Berg2022-06-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the scalar operations warnings read e.g.: overflow encountered in scalar multiply rather than: overflow encountered in float_scalars It also fixes one case where "assignment" rather than "cast" was used when I added the FPEs for casts. Otherwise, uses the helper that I intrudced for for the floating point casts in all places to simplify the code, the only "complicated" thing is that I try to give "scalar divide" rather than "scalar true_divide" as warnings, since "true_divide" should not really be something that end-users need be aware of.
* | BUG: Reject non integer array-likes with size 1 in delete (#21857)Sebastian Berg2022-06-281-12/+33
|/ | | | | | | | Non integer array-likes were not correctly rejected when a new fast-path was added to `np.delete` in gh-16895. This includes the _explicitly_ added `dtype=object` which should not be allowed since it is not allowed in normal indexing either. Closes gh-21840
* BUG: Use `keepdims` during normalization in `np.average` and `np.ma.average` ↵Srimukh Sripada2022-06-261-0/+12
| | | | | | | | | (#21851) The keepdims flag needs to be applied during the calculation of the sum of the weights in np.average and np.ma.average. Not passing it causes weights to broadcast incorrectly. Fixes #21850
* Merge pull request #21626 from seberg/weak-scalarsCharles Harris2022-06-261-4/+9
|\ | | | | API: Introduce optional (and partial) NEP 50 weak scalar logic
| * API: Add leading underscore to `no_nep50_warning` and `get/set_promotion_state`Sebastian Berg2022-06-151-1/+1
| |
| * TST: Adapt percentile test to changed promotionSebastian Berg2022-06-151-4/+9
| | | | | | | | | | | | Promotion in percentile will now more aggressively preserve the input dtype for floating point types (rather than upgrading the type to at least float64).
* | BUG: Fix in1d for empty integer array as input (#21842)Miles Cranmer2022-06-241-1/+19
| | | | | | | | | | | | | | | | | | | | | | * TST: Tests empty input to in1d of various types * MAINT: Skip table method on empty input array * MAINT: Check array size before call to min * MAINT: Return early for kind="table" and empty ar2 * TST: Test other dtypes of empty arrays
* | Merge pull request #12065 from MilesCranmer/masterSebastian Berg2022-06-231-26/+111
|\ \ | | | | | | MAINT: Optimize np.isin and np.in1d for integer arrays
| * | TST: Skip empty arrays for kind="table"Miles Cranmer2022-06-221-5/+7
| | |
| * | TST: Reduce code re-use with pytest markMilesCranmer2022-06-221-142/+40
| | |
| * | MAINT: change kind names for in1dMilesCranmer2022-06-181-26/+26
| | | | | | | | | | | | - Switch dictionary->table, mergesort->sort
| * | TST: validate in1d errorsMilesCranmer2022-06-171-0/+34
| | |
| * | MAINT: kind now uses "mergesort" instead of "sort"MilesCranmer2022-06-171-18/+18
| | |