summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_nanfunctions.py
Commit message (Collapse)AuthorAgeFilesLines
* 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: Quantile function on complex number now throws an error (#22652) (#22703)Matteo Raso2022-12-081-8/+30
| | | | | | | | | | | | | | | | | 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/+58
| | | | | | `numpy.percentile()`, and `numpy.quantile()`. Closes #22714, #22544.
* API,DEP: Rename percentile/quantile `interpolation=` to `method=`Sebastian Berg2021-11-121-2/+2
|
* MAINT: remove unused importsAlessia Marcolini2021-10-081-2/+2
|
* TST: Add tests for the new `nan<x>` function parametersBas van Beek2021-10-041-0/+103
|
* TST: Add a test for comparing the signatures of `nan<x>` and `<x>` functionsBas van Beek2021-10-041-0/+48
|
* MAINT: Make parameters match label.Charles Harris2021-09-131-1/+1
|
* TST: Fix a couple of `pytest` id labelsBas van Beek2021-09-131-3/+3
| | | | Co-Authored-By: Charles Harris <charlesr.harris@gmail.com>
* TST: Expand/rewrite the `test_allnans` testsBas van Beek2021-09-111-79/+115
| | | | Parametrize w.r.t. the axis, array dimensionality and dtype
* TST: Expand `TestNanFunctions_NumberTypes` with 0d arraysBas van Beek2021-09-091-12/+17
|
* TST: Make nanfunc test ignore overflow instead of xfailing testSebastian Berg2021-09-071-3/+1
| | | | | | This makes the test more precise, and I ran into having to broaden the xfails otherwise, because right now reduce-likes incorrectly faile to give floating point warnings (and I was fixing that).
* TST: Add more tests for `nanmedian`, `nanquantile` and `nanpercentile`Bas van Beek2021-09-031-0/+17
|
* TST: Expand the old `TestNanFunctions_IntTypes` test with non-integer number ↵Bas van Beek2021-09-031-71/+52
| | | | types
* TST: Update the `np.nanmedian` tests for all-nan arraysBas van Beek2021-05-221-16/+34
| | | | Test multiple dtypes in the `test_allnans` + a minor refactor
* MAINT: Remove uses of scalar aliasesEric Wieser2020-06-101-1/+1
| | | | This is a follow up to d1d9dd58e2de5f3b69c02b104e1daaeec1f38d9f, as more regressions in this style have been introduced since that commit.
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-7/+7
| | | | | | | 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 unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* PERF: only copy input array in _replace_nan() if there are nans to replaceChristopher Whelan2019-12-021-1/+28
|
* ENH: add _nan_mask functionTyler Reddy2019-01-181-0/+28
| | | | | | | | | * add _nan_mask function and associated unit tests; this function is to be used to simplify reduction operations involving np.nan elements by using a mask with a ``where`` argument
* Merge pull request #11010 from mhvk/poly-matrix-tests-to-matrixlibCharles Harris2018-05-151-51/+54
|\ | | | | Move remaining Matrix tests to matrixlib
| * MAINT: move matrix tests in lib to matrixlib.Marten van Kerkwijk2018-04-291-51/+54
| |
* | MAINT: Misc. typos (#11005)luzpaz2018-04-301-1/+1
|/ | | | | | | | | User- and non-user-facing typos. Some source typos fixes as well. Found via `codespell`.
* ENH: Adding np.quantile() and np.nanquantile(). #10199Chun-Wei Yuan2018-04-161-0/+36
|
* MAINT: Remove all uses of run_module_suite.Charles Harris2018-04-061-6/+2
| | | | | That function is nose specific and has not worked since `__init__` files were added to the tests directories.
* TST: Remove unittest dependencies in numpy/lib/tests.Charles Harris2017-07-241-9/+9
|
* BUG: Fix incorrect behavior of nanfunctions on object arraysEric Wieser2017-04-291-0/+12
| | | | Fixes gh-8974 and gh-9008
* MAINT: Use _validate_axis inside _ureduceEric Wieser2017-03-281-8/+8
| | | | This fixes an omission where duplicate axes would only be detected when positive
* BUG: fix wrong masked median for some special casesJulian Taylor2017-01-171-0/+12
| | | | | | | the masked nans which are equivalent to valid infs must be replaced with infs earlier otherwise the inf is lost in the masked sum of the low and high part. Closes gh-8487
* Merge pull request #8364 from juliantaylor/masked-median-nanCharles Harris2016-12-121-12/+30
|\ | | | | BUG: handle unmasked NaN in ma.median like normal median
| * BUG: handle unmasked NaN in ma.median like normal medianJulian Taylor2016-12-121-12/+30
| | | | | | | | | | | | | | | | | | | | | | This requires to base masked median on sort(endwith=False) as we need to distinguish Inf and NaN. Using Inf as filler element of the sort does not work as then the mask is not guaranteed to be at the end. Closes gh-8340 Also fixed 1d ma.median not handling np.inf correctly, the nd variant was ok.
* | BUG: fix nanpercentile not returning scalar with axis argumentJulian Taylor2016-12-111-1/+5
|/ | | | Closes gh-8220
* TST: Use ComplexWarning suppression only where neededSebastian Berg2016-09-021-2/+6
|
* TST: Replace catch_warnings when recording is not enforced in test_nanfuncsSebastian Berg2016-09-021-10/+10
|
* ENH: Remove warning ignoring from nanfuncsSebastian Berg2016-09-021-30/+32
| | | | | | Comment mentions a speedup, but it seems unsure why it should be there. Instead use an error state in divide_by_count. Some extra complex warnings had to be ignored (but those seemed correct)
* ENH: adds np.nancumsum and np.nancumprodPhillip J. Wolfram2016-03-241-1/+106
| | | | | | | | This PR adds an implementation of `nancumsum` and `nancumprod`. The actual function is a two-liner adapted from `nansum`. Its structure is adapted from PR: https://github.com/numpy/numpy/pull/5418/
* BUG: Fixed previous attempt to fix dimension mismatch in nanpercentileJoseph Fox-Rabinovitz2016-02-051-1/+4
| | | | | | | | | nanpercentile was conforming to dimension convention of percentile incorrectly. percentile outputs results for the different percentiles along the first dimension of the output. nanpercentile was moving the reduction axis to the front using swapaxes, which would move the first axis out of place if there were more than two in the array. Added a test with more than two axes to demonstrate and used rollaxis instead of swapaxes to do the interhange.
* Merge pull request #5981 from dfreese/fix/multi_percent_nanperc_bugJulian Taylor2016-01-171-1/+25
|\ | | | | BUG: Handle multiple percentiles for all-nan slices in nanpercentile
| * BUG: Fix nanpercentile crash on all-nan slicesDavid Freese2016-01-121-1/+25
| | | | | | | | | | | | | | | | Fix bug where nanpercentile would crash with an all-nan slices when given multiple percentiles. Also corrects behavior where array sizes different from numpy.percentile would be returned with keepdims enabled. Fix #5760
* | TEST: Ignore `FutureWarning` if raised from running masked array operations.John Kirkham2016-01-151-0/+1
|/
* [TST] fix test_dtype_error to actually test what it's supposed toNathaniel J. Smith2015-12-081-3/+3
| | | | | Discovered while cleaning up uses of the silly aliases like 'np.object'.
* ENH: add np.nanprodStephan Hoyer2015-01-051-148/+81
| | | | | | | | | | | This PR adds an implementation of `nanprod`. The actual function is a two-liner adapted from `nansum`. Most of this PR consists of documentation and tests (for which I took the opportunity to do some consolidation). A method with the same functionality exists in pandas, and I was surprised to discover that it's not in numpy.
* BUG: fix nanmedian on arrays containing infJulian Taylor2014-10-141-0/+16
| | | | | | | | | | | | | | | | | There are two issues: A masked divide of an infinite value is a masked value which means one can't use np.ma.mean to compute the median as infinity division is well defined. This behaviour seems wrong to me but it also looks intentional so changing it is not appropriate for a bugfix release. The second issue is that the ordering of the sorted masked array is undefined for equal values, the sorting considers infinity the largest floating point value which is not correct in respect to sorting where nan is considered larger. This is fixed by changing the minimum_fill_value to nan for float data in the masked sorts. Closes gh-5138
* STY: PEP8 compliance for numpy/lib/tests.Charles Harris2014-07-311-12/+12
| | | | | | | The possibly controversial part of this is making the nested array value lists PEP8 compliant, as there is something to be said aligning the values for clarity. In the end, it seemed like the easiest thing to do was to make them PEP8 compliant. The eye can get used to that.
* ENH: use masked median for small multidimensional nanmediansJulian Taylor2014-06-021-1/+17
|
* BUG: nanpercentile/nanmedian 0-d with output given.Sebastian Berg2014-05-281-40/+71
| | | | Also some PEP-8 fixes and test improvements
* ENH: added functionality nanpercentile to numpyDavid Freese2014-05-221-0/+90
| | | | | | Implemented a nanpercentile and associated tests as an extension of np.percentile to complement the other nanfunctions.
* ENH: added functionality nanmedian to numpyDavid Freese2014-05-021-4/+94
| | | | | | | | | | Implemented a nanmedian and associated tests as an extension of np.median to complement the other nanfunctions Added negative values to the unit tests Cleaned up documentation of nanmedian
* Add tests using matricesMarten van Kerkwijk2014-04-221-0/+25
|
* TST: do not use "ignore" to filter warningsSebastian Berg2014-02-211-2/+2
| | | | | | | | | | | | | | | | | When a warning is ignored (or raised once) in python, the warnings module will tag on a `__warningregistry__` dictionary to be able to filter these warnings in the future. This is tagged on to the current context, causing leakage to later calls (this is a bit more complex, since where the registry ends up depends on the layers between the original caller and warner). In short, tests should typically not use ignore but catch the warnings to avoid changing the user experience (or errors on duplicate test runs). Fixes an error on duplicate test runs (does not remove all "ignores" which may change behaviour outside tests). Closes gh-4340