summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorseberg <sebastian@sipsolutions.net>2016-11-09 17:36:24 +0100
committerGitHub <noreply@github.com>2016-11-09 17:36:24 +0100
commit0268680e5db25caeeb69bbb2e62ead3405c8f6f0 (patch)
tree9584c8caa137d2b73c8e10fcaba426295a20aac0 /numpy/lib/tests/test_function_base.py
parent3fd2fa1d3a1b627b6a13fe963b2c5b14eafb0fbe (diff)
parent6420f844824cdc327026302870b57dfd8c7481f7 (diff)
downloadnumpy-0268680e5db25caeeb69bbb2e62ead3405c8f6f0.tar.gz
Merge pull request #8194 from alvarosg/scalar-piecewise
BUG: np.piecewise not working for scalars
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index f396e036b..5bba088a8 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2324,9 +2324,19 @@ class TestPiecewise(TestCase):
assert_(y.ndim == 0)
assert_(y == 1)
+ # With 3 ranges (It was failing, before)
+ y = piecewise(x, [False, False, True], [1, 2, 3])
+ assert_array_equal(y, 3)
+
def test_0d_comparison(self):
x = 3
- piecewise(x, [x <= 3, x > 3], [4, 0]) # Should succeed.
+ y = piecewise(x, [x <= 3, x > 3], [4, 0]) # Should succeed.
+ assert_equal(y, 4)
+
+ # With 3 ranges (It was failing, before)
+ x = 4
+ y = piecewise(x, [x <= 3, (x > 3) * (x <= 5), x > 5], [1, 2, 3])
+ assert_array_equal(y, 2)
def test_multidimensional_extrafunc(self):
x = np.array([[-2.5, -1.5, -0.5],