(self)
| 2883 | class TestPiecewise: |
| 2884 | |
| 2885 | def test_simple(self): |
| 2886 | # Condition is single bool list |
| 2887 | x = piecewise([0, 0], [True, False], [1]) |
| 2888 | assert_array_equal(x, [1, 0]) |
| 2889 | |
| 2890 | # List of conditions: single bool list |
| 2891 | x = piecewise([0, 0], [[True, False]], [1]) |
| 2892 | assert_array_equal(x, [1, 0]) |
| 2893 | |
| 2894 | # Conditions is single bool array |
| 2895 | x = piecewise([0, 0], np.array([True, False]), [1]) |
| 2896 | assert_array_equal(x, [1, 0]) |
| 2897 | |
| 2898 | # Condition is single int array |
| 2899 | x = piecewise([0, 0], np.array([1, 0]), [1]) |
| 2900 | assert_array_equal(x, [1, 0]) |
| 2901 | |
| 2902 | # List of conditions: int array |
| 2903 | x = piecewise([0, 0], [np.array([1, 0])], [1]) |
| 2904 | assert_array_equal(x, [1, 0]) |
| 2905 | |
| 2906 | x = piecewise([0, 0], [[False, True]], [lambda x:-1]) |
| 2907 | assert_array_equal(x, [0, -1]) |
| 2908 | |
| 2909 | assert_raises_regex(ValueError, '1 or 2 functions are expected', |
| 2910 | piecewise, [0, 0], [[False, True]], []) |
| 2911 | assert_raises_regex(ValueError, '1 or 2 functions are expected', |
| 2912 | piecewise, [0, 0], [[False, True]], [1, 2, 3]) |
| 2913 | |
| 2914 | def test_two_conditions(self): |
| 2915 | x = piecewise([1, 2], [[True, False], [False, True]], [3, 4]) |
nothing calls this directly
no test coverage detected