diff options
author | Aditya Panchal <apanchal@bastula.org> | 2016-01-29 18:44:59 -0600 |
---|---|---|
committer | Aditya Panchal <apanchal@bastula.org> | 2016-01-29 18:44:59 -0600 |
commit | 0e65b7166a6265a2047cb3ca47f487f3de19f0a6 (patch) | |
tree | e473af69f29f1bfb987be14ca206a3130ddc2b2b /numpy/lib/tests/test_function_base.py | |
parent | e2805398f9a63b825f4a2aab22e9f169ff65aae9 (diff) | |
download | numpy-0e65b7166a6265a2047cb3ca47f487f3de19f0a6.tar.gz |
BUG: Fixed regressions in np.piecewise in ref to #5737 and #5729.
Added unit tests for these conditions.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index d6a838f3a..878d00bdf 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1862,6 +1862,10 @@ class TestPiecewise(TestCase): x = piecewise([1, 2], [[True, False], [False, True]], [3, 4]) assert_array_equal(x, [3, 4]) + def test_scalar_domains_three_conditions(self): + x = piecewise(3, [True, False, False], [4, 2, 0]) + assert_equal(x, 4) + def test_default(self): # No value specified for x[1], should be 0 x = piecewise([1, 2], [True, False], [2]) @@ -1886,6 +1890,13 @@ class TestPiecewise(TestCase): x = 3 piecewise(x, [x <= 3, x > 3], [4, 0]) # Should succeed. + def test_multidimensional_extrafunc(self): + x = np.array([[-2.5, -1.5, -0.5], + [0.5, 1.5, 2.5]]) + y = piecewise(x, [x < 0, x >= 2], [-1, 1, 3]) + assert_array_equal(y, np.array([[-1., -1., -1.], + [3., 3., 1.]])) + class TestBincount(TestCase): |