summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_nanfunctions.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
* BUG: Refactor nanfunctions to behave as agreed on for 1.9.Charles Harris2013-10-041-66/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deal with subclasses of ndarray, like pandas.Series and matrix. Subclasses may not define the new keyword keepdims or deal gracefully with ufuncs in all their forms. This is solved by throwing the problem onto the np.sum, np.any, etc. functions that have ugly hacks to deal with the problem. Settle handling of all-nan slices. nanmax, nanmin -- Raise warning, return NaN for slice. nanargmax, nanargmin -- Raise ValueError. nansum -- Return 0 for slice. nanmean, nanvar, nanstd -- Raise warning, return NaN for slice. Make NaN functions work for scalar arguments. This may seem silly, but it removes a check for special cases. Update tests Deal with new all-nan handling. Test with matrix class as example of subclass without keepdims. Test with scalar arguments. Fix nanvar issue reported in #3860. Closes #3860 #3850
* STY: Make numpy/lib/test/*.py PEP8 compliant.Charles Harris2013-09-031-14/+14
| | | | | | | Run autopep8 over the test files in numpy/lib/test and make fixes to the result. Also remove Python5 workaround.
* DEP: Make nansum return 0 for all-NaN or empty axis.Charles Harris2013-08-181-27/+11
| | | | | Make this happen and remove test parts dependent on numpy version < 1.9. Fixes test failures in numpy after 1.8 branch.
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-4/+4
| | | | | | | Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
* DOC: Various fixes.Charles Harris2013-08-141-4/+4
| | | | | | Fix typos and clarify some explanations. Document the changes in the return values of nanargmin and nanargmax for all-NaN slices in the 1.8.0 release notes.
* TST: Add tests for the nansum, nanmean, nanvar, and nanstd.Charles Harris2013-08-121-190/+367
|
* MAINT: Separate nan functions into their own module.Charles Harris2013-08-121-0/+240
New files lib/nanfunctions.py and lib/tests/test_nanfunctions.py are added and both the previous and new nan functions and tests are moved into them. The existing nan functions moved from lib/function_base are: nansum, nanmin, nanmax, nanargmin, nanargmax The added nan functions moved from core/numeric are: nanmean, nanvar, nanstd