summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
Commit message (Collapse)AuthorAgeFilesLines
* 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
| | |
| * | TST: Use new "kind" argument over "method"MilesCranmer2022-06-171-20/+20
| | |
| * | MAINT: Fix misplaced default in in1d testMilesCranmer2022-06-101-2/+2
| | |
| * | MAINT: Add back in1d tests of old methodMilesCranmer2022-06-101-17/+17
| | |
| * | MAINT: bool instead of np.bool_ dtypeMilesCranmer2022-06-101-1/+1
| | |
| * | MAINT: Fix linting error in testMilesCranmer2022-06-101-1/+2
| | |
| * | MAINT: Update tests to use new `method` argumentMilesCranmer2022-06-101-19/+20
| | |
| * | MAINT: Fix linting errors in in1d testsMilesCranmer2022-06-091-8/+18
| | |
| * | TST: Extend np.in1d tests to old algorithmMilesCranmer2022-06-091-2/+42
| | | | | | | | | | | | | | | - Add flag ``_slow_integer`` to np.isin/np.in1d to force the use of the old isin/in1d algorithm for integers.
| * | TST: add tests for in1d/isinMilesCranmer2022-06-091-0/+99
| | | | | | | | | | | | | | | | | | - These tests hit the areas of the old algorithm which are now replaced for the majority of cases - Another test tests behaviour of boolean input to isin/in1d
* | | BUG: lib: A loadtxt error message had two values reversed.warren2022-06-181-1/+1
| |/ |/| | | | | | | | | | | | | Fix the reversed arguments to the call of PyErr_Format() that generates the exception for an invalid index in usecols. Also fix the format characters in several other calls of PyErr_Format() where the arguments are Py_ssize_t.
* | TST: Clean up an opened temporary file descriptor in loadtxt testsSebastian Berg2022-06-141-0/+5
|/
* TST: Fixup loadtxt int-via-float tests when in release modeSebastian Berg2022-06-091-0/+2
| | | | | | | | | In release mode, the DeprecationWarning is not automatically raised, so we need to ensure this using a warning filter. (Also add missing metadata/info to the deprecation tests) Closes gh-21706
* Merge pull request #16971 from BvB93/nd_gridCharles Harris2022-06-091-0/+34
|\ | | | | BUG: Fix three `complex`- & `float128`-related issues with `nd_grid`
| * TST: Update the `np.mgrid` testsBas van Beek2021-10-131-0/+34
| |
* | DEP: Remove `normed=` keyword argument from histogromsSebastian Berg2022-06-021-41/+0
| | | | | | | | | | | | The normed keyword argument has been deprecated for a long time. This removes it, replacing its position with the new density argument.
* | MAINT: Fixup `unique`s `equal_nan` kwarg to match `np.array_equal`Sebastian Berg2022-06-011-1/+1
| | | | | | | | | | | | | | | | The other similar arguments in the testing functions and `np.array_equal` use `equal_nan` and not `equal_nans` (with plural s). So it seems we should use that here as well for consistency. Does some very minor style fixes otherwise.
* | TST: Added test for np.unique equal_nans kwargJason Thai2022-05-281-0/+8
| |
* | MAINT: Python <3.7 related cleanupsBrigitta Sipőcz2022-05-231-2/+0
| |
* | Merge pull request #19226 from ↵Matti Picus2022-05-191-1/+0
|\ \ | | | | | | | | | | | | seberg/fix-void-cast-safety-promotion-and-comparison API: Fix structured dtype cast-safety, promotion, and comparison
| * | API: Fix structured dtype cast-safety, promotion, and comparisonSebastian Berg2022-05-091-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR replaces the old gh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses https://github.com/liberfa/pyerfa/issues/77 and replaces gh-15509 (the implementation has changed too much). Fixes gh-15494 (and probably a few more) Co-authored-by: Allan Haldane <allan.haldane@gmail.com>
* | | BUG: lib: Allow type uint64 for eye() arguments.warren2022-05-111-1/+7
| | | | | | | | | | | | | | | | | | Closes gh-9982. (Plus a few small PEP 8 fixes.)
* | | ENH: Add 'keepdims' to 'average()' and 'ma.average()'.warren2022-05-091-1/+27
|/ /
* | ENH: Optimize `np.empty` for scalar arguments (#20175)Francesco Andreuzzi2022-05-061-1/+3
| | | | | | | | | | | | | | | | Optimizes the parsing of shape tuples and integers by avoiding multiple conversions and generally refactoring the code. Closes gh-19010, that parsing a single integer was very slow (due to trying to convert it to a squence twice). Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* | TST: Make `test_large_archive` robust against memory issues [wheel build]Sebastian Berg2022-05-021-2/+7
| |
* | TEST: on PyPy, skip hanging slow test [wheel build]mattip2022-05-021-0/+1
| |