summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
Commit message (Collapse)AuthorAgeFilesLines
* 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.)
* 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
| |
* | DEP: deprecate `product`, `cumproduct`, `sometrue`, `alltrue`Ralf Gommers2023-03-021-4/+4
| | | | | | | | [skip cirrus]
* | 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.
* 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-081-5/+19
| | | | | | | | | | | | | | | | | 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: `keepdims=True` is ignored if `out` is not `None` in `numpy.median()`, ↵Roy Smart2022-12-051-0/+50
| | | | | | `numpy.percentile()`, and `numpy.quantile()`. Closes #22714, #22544.
* TST: Skip tests that are not currently supported in wasmHood Chatham2022-11-111-1/+2
|
* TST,MAINT: Replace most `setup` with `setup_method` (also teardown)Sebastian Berg2022-10-271-1/+1
| | | | | | | | 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)
* DEP: Add deprecation warning and check warning in test.Ross Barnowski2022-10-191-5/+6
|
* 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: 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
* 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).
* ENH: Add 'keepdims' to 'average()' and 'ma.average()'.warren2022-05-091-1/+27
|
* MAINT: single value identification and testDevin Shanahan2022-01-161-0/+13
|
* BUG: quantile discrete methods ended up using -1 as index sometimesSebastian Berg2021-11-121-3/+13
| | | | | Also, the closest-observation did not correctly support multiple quantiles calculated at the same time (broadcasting error).
* API,DEP: Rename percentile/quantile `interpolation=` to `method=`Sebastian Berg2021-11-121-46/+46
|
* TST: Add test for max ulp in default quantile calculationabel2021-11-091-0/+8
|
* TST: Make use of clongdouble and longdoubleabel2021-11-041-2/+2
| | | | | On some platforms float128 and complex256 do not exist. Using (c)longdouble aliases should work on all platforms.
* TST: Add parametrize for interpolation methodsabel2021-11-041-91/+43
|
* TST: Add extrapolation testsabel2021-11-041-0/+9
|
* Fix issue with nan scalarabel2021-11-041-0/+6
| | | | Also added unit test for it.
* Fix _lerpabel2021-11-041-7/+7
| | | | | - some changes were unrelated to the PR and have been reverted, including, renaming and moving the logic around. - Also renamed _quantile_ureduce_func to its original name
* MAINT, ENH [#10736] Add interpolation methods to quantileabel2021-11-041-36/+141
| | | | | | | | | | - Added the missing linear interpolation methods. - Updated the existing unit tests. - Added pytest.mark.xfail for boolean arrays See - https://github.com/numpy/numpy/pull/19857#issuecomment-919258693 - https://github.com/numpy/numpy/issues/19154
* BUG: lib: Fix error raised by insert.warren2021-10-201-0/+5
| | | | | | | | | | | | | | | | | | When `insert` is given a single out-of-bounds index in a list, e.g. np.insert([0, 1, 2], [99], [3, 4]) # 99 is out of bounds a TypeError was being raised because of a bug in the formatting of the message. Before this change, the error is TypeError: %i format: a number is required, not list After, we get the expected IndexError: index [99] is out of bounds for axis 0 with size 3
* TST: Add more tests for `np.kaiser`Bas van Beek2021-09-301-0/+21
|
* BUG: Fix the `lib.function_base` window functions ignoring extended ↵Bas van Beek2021-09-301-13/+73
| | | | precision float dtypes
* BUG: ensure np.median does not drop subclass for NaN result.Marten van Kerkwijk2021-09-141-0/+10
| | | | | | | | Currently, np.median is almost completely safe for subclasses, except if the result is NaN. In that case, it assumes the result is a scalar and substitutes a NaN with the right dtype. This PR fixes that, since subclasses like astropy's Quantity generally use array scalars to preserve subclass information such as the unit.
* MAINT: refactor "for ... in range(len(" statementsMike Taves2021-09-011-5/+0
|
* dummy change to kick off another buildAnkit Dwivedi2021-08-081-1/+1
|
* fix lint errorsAnkit Dwivedi2021-08-071-1/+2
|
* add tests to check if whitespaces are ignored in gufunc signaturesAnkit Dwivedi2021-08-071-0/+14
|
* API: Ensure np.vectorize outputs can be subclasses.Marten van Kerkwijk2021-06-261-1/+21
| | | | | | | As is, this is true for the ufunc case, but not for the gufunc case, even if the underlying function does produce a subclass. Given the care taken to ensure inputs are kept as subclasses, this is almost certainly an oversight, which is here corrected.