(self)
| 2620 | class TestPiecewise: |
| 2621 | |
| 2622 | def test_simple(self): |
| 2623 | # Condition is single bool list |
| 2624 | x = piecewise([0, 0], [True, False], [1]) |
| 2625 | assert_array_equal(x, [1, 0]) |
| 2626 | |
| 2627 | # List of conditions: single bool list |
| 2628 | x = piecewise([0, 0], [[True, False]], [1]) |
| 2629 | assert_array_equal(x, [1, 0]) |
| 2630 | |
| 2631 | # Conditions is single bool array |
| 2632 | x = piecewise([0, 0], np.array([True, False]), [1]) |
| 2633 | assert_array_equal(x, [1, 0]) |
| 2634 | |
| 2635 | # Condition is single int array |
| 2636 | x = piecewise([0, 0], np.array([1, 0]), [1]) |
| 2637 | assert_array_equal(x, [1, 0]) |
| 2638 | |
| 2639 | # List of conditions: int array |
| 2640 | x = piecewise([0, 0], [np.array([1, 0])], [1]) |
| 2641 | assert_array_equal(x, [1, 0]) |
| 2642 | |
| 2643 | x = piecewise([0, 0], [[False, True]], [lambda x:-1]) |
| 2644 | assert_array_equal(x, [0, -1]) |
| 2645 | |
| 2646 | assert_raises_regex(ValueError, '1 or 2 functions are expected', |
| 2647 | piecewise, [0, 0], [[False, True]], []) |
| 2648 | assert_raises_regex(ValueError, '1 or 2 functions are expected', |
| 2649 | piecewise, [0, 0], [[False, True]], [1, 2, 3]) |
| 2650 | |
| 2651 | def test_two_conditions(self): |
| 2652 | x = piecewise([1, 2], [[True, False], [False, True]], [3, 4]) |
nothing calls this directly
no test coverage detected