summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-09-03 17:01:57 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-09-03 17:01:57 +0200
commit9ef778330a625ccff12b6fa913e1b6306e02eb78 (patch)
tree2c8117abab97e54970d3dcf8c3d5885a34b26364 /numpy/lib/tests
parentfffcb6e2bd45bf423f626ebf77a2e3142de636c4 (diff)
downloadnumpy-9ef778330a625ccff12b6fa913e1b6306e02eb78.tar.gz
TST: Add more tests for `nanmedian`, `nanquantile` and `nanpercentile`
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_nanfunctions.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
index dc14c3ad2..006b81a78 100644
--- a/numpy/lib/tests/test_nanfunctions.py
+++ b/numpy/lib/tests/test_nanfunctions.py
@@ -250,6 +250,7 @@ class TestNanFunctions_NumberTypes:
np.nancumsum: np.cumsum,
np.nancumprod: np.cumprod,
np.nanmean: np.mean,
+ np.nanmedian: np.median,
np.nanvar: np.var,
np.nanstd: np.std,
}
@@ -272,6 +273,22 @@ class TestNanFunctions_NumberTypes:
@pytest.mark.parametrize(
"nanfunc,func",
+ [(np.nanquantile, np.quantile), (np.nanpercentile, np.percentile)],
+ ids=["nanquantile", "nanpercentile"],
+ )
+ def test_nanfunc_q(self, dtype, nanfunc, func):
+ mat = self.mat.astype(dtype)
+ tgt = func(mat, q=1)
+ out = nanfunc(mat, q=1)
+
+ assert_almost_equal(out, tgt)
+ if dtype == "O":
+ assert type(out) is type(tgt)
+ else:
+ assert out.dtype == tgt.dtype
+
+ @pytest.mark.parametrize(
+ "nanfunc,func",
[(np.nanvar, np.var), (np.nanstd, np.std)],
ids=["nanvar", "nanstd"],
)