summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_arraypad.py
diff options
context:
space:
mode:
authorHameer Abbasi <einstein.edison@gmail.com>2019-10-08 02:22:41 +0500
committerHameer Abbasi <einstein.edison@gmail.com>2019-10-08 02:22:41 +0500
commit2246f68b1af3f27bce9cbee3a49aa10e1dd7cb80 (patch)
tree6eaa55f3167512cc044304512be5ac87f215d9ff /numpy/lib/tests/test_arraypad.py
parent750a59e9310ff1226ff2912fc29a815c2ce07ed2 (diff)
parentd2c57616d369fdb5b4ea22b77d314785b1a0508e (diff)
downloadnumpy-2246f68b1af3f27bce9cbee3a49aa10e1dd7cb80.tar.gz
Merge branch 'uarray' into uarray-me
Diffstat (limited to 'numpy/lib/tests/test_arraypad.py')
-rw-r--r--numpy/lib/tests/test_arraypad.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py
index b7630cdcd..b6dd3b31c 100644
--- a/numpy/lib/tests/test_arraypad.py
+++ b/numpy/lib/tests/test_arraypad.py
@@ -469,6 +469,29 @@ class TestStatistic(object):
)
assert_array_equal(a, b)
+ @pytest.mark.filterwarnings("ignore:Mean of empty slice:RuntimeWarning")
+ @pytest.mark.filterwarnings(
+ "ignore:invalid value encountered in (true_divide|double_scalars):"
+ "RuntimeWarning"
+ )
+ @pytest.mark.parametrize("mode", ["mean", "median"])
+ def test_zero_stat_length_valid(self, mode):
+ arr = np.pad([1., 2.], (1, 2), mode, stat_length=0)
+ expected = np.array([np.nan, 1., 2., np.nan, np.nan])
+ assert_equal(arr, expected)
+
+ @pytest.mark.parametrize("mode", ["minimum", "maximum"])
+ def test_zero_stat_length_invalid(self, mode):
+ match = "stat_length of 0 yields no value for padding"
+ with pytest.raises(ValueError, match=match):
+ np.pad([1., 2.], 0, mode, stat_length=0)
+ with pytest.raises(ValueError, match=match):
+ np.pad([1., 2.], 0, mode, stat_length=(1, 0))
+ with pytest.raises(ValueError, match=match):
+ np.pad([1., 2.], 1, mode, stat_length=0)
+ with pytest.raises(ValueError, match=match):
+ np.pad([1., 2.], 1, mode, stat_length=(1, 0))
+
class TestConstant(object):
def test_check_constant(self):