diff options
author | alvarosg <as12513@imperial.ac.uk> | 2016-10-21 14:51:56 +0100 |
---|---|---|
committer | Alvaro Sanchez <sanchezgnzlz.alvaro@gmail.com> | 2016-10-26 10:15:12 +0100 |
commit | 6420f844824cdc327026302870b57dfd8c7481f7 (patch) | |
tree | 7a5babcd427220aaded463d5604350cb912ad5fe /numpy/lib/tests/test_function_base.py | |
parent | 77ce5f48506c6305cd8987683291275726cde623 (diff) | |
download | numpy-6420f844824cdc327026302870b57dfd8c7481f7.tar.gz |
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.py | 12 |
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 6327aaf7c..4482ee2ca 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2299,9 +2299,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], |