Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf047da

Browse files
committed
TST: Add deprecation testcase for quantile interpolation rename
1 parent 5358bb3 commit bf047da

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

numpy/core/tests/test_deprecations.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,3 +1230,23 @@ def test_deprecated_module(self):
12301230
def test_deprecated_attr(self):
12311231
finfo = np.finfo(float)
12321232
self.assert_deprecated(lambda: getattr(finfo, "machar"))
1233+
1234+
1235+
class TestQuantileInterpolationDeprecation(_DeprecationTestCase):
1236+
# Deprecated 2021-11-08, NumPy 1.22
1237+
@pytest.mark.parametrize("func",
1238+
[np.percentile, np.quantile, np.nanpercentile, np.nanquantile])
1239+
def test_deprecated(self, func):
1240+
self.assert_deprecated(
1241+
lambda: func([0., 1.], 0., interpolation="linear"))
1242+
self.assert_deprecated(
1243+
lambda: func([0., 1.], 0., interpolation="nearest"))
1244+
1245+
@pytest.mark.parametrize("func",
1246+
[np.percentile, np.quantile, np.nanpercentile, np.nanquantile])
1247+
def test_both_passed(self, func):
1248+
with warnings.catch_warnings():
1249+
# catch the warning, but make sure it does not raise:
1250+
warnings.simplefilter("always", DeprecationWarning)
1251+
with pytest.raises(TypeError):
1252+
func([0., 1.], 0., interpolation="nearest", method="nearest")

0 commit comments

Comments
 (0)