Skip to content

Commit 9ef7783

Browse files
author
Bas van Beek
committed
TST: Add more tests for nanmedian, nanquantile and nanpercentile
1 parent fffcb6e commit 9ef7783

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

numpy/lib/tests/test_nanfunctions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ class TestNanFunctions_NumberTypes:
250250
np.nancumsum: np.cumsum,
251251
np.nancumprod: np.cumprod,
252252
np.nanmean: np.mean,
253+
np.nanmedian: np.median,
253254
np.nanvar: np.var,
254255
np.nanstd: np.std,
255256
}
@@ -270,6 +271,22 @@ def test_nanfunc(self, dtype, nanfunc, func):
270271
else:
271272
assert out.dtype == tgt.dtype
272273

274+
@pytest.mark.parametrize(
275+
"nanfunc,func",
276+
[(np.nanquantile, np.quantile), (np.nanpercentile, np.percentile)],
277+
ids=["nanquantile", "nanpercentile"],
278+
)
279+
def test_nanfunc_q(self, dtype, nanfunc, func):
280+
mat = self.mat.astype(dtype)
281+
tgt = func(mat, q=1)
282+
out = nanfunc(mat, q=1)
283+
284+
assert_almost_equal(out, tgt)
285+
if dtype == "O":
286+
assert type(out) is type(tgt)
287+
else:
288+
assert out.dtype == tgt.dtype
289+
273290
@pytest.mark.parametrize(
274291
"nanfunc,func",
275292
[(np.nanvar, np.var), (np.nanstd, np.std)],

0 commit comments

Comments
 (0)