MCPcopy Index your code
hub / github.com/numpy/numpy / test_0d_comparison

Method test_0d_comparison

numpy/lib/tests/test_function_base.py:2946–2959  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2944 assert_array_equal(y, 3)
2945
2946 def test_0d_comparison(self):
2947 x = 3
2948 y = piecewise(x, [x <= 3, x > 3], [4, 0]) # Should succeed.
2949 assert_equal(y, 4)
2950
2951 # With 3 ranges (It was failing, before)
2952 x = 4
2953 y = piecewise(x, [x <= 3, (x > 3) * (x <= 5), x > 5], [1, 2, 3])
2954 assert_array_equal(y, 2)
2955
2956 assert_raises_regex(ValueError, '2 or 3 functions are expected',
2957 piecewise, x, [x <= 3, x > 3], [1])
2958 assert_raises_regex(ValueError, '2 or 3 functions are expected',
2959 piecewise, x, [x <= 3, x > 3], [1, 1, 1, 1])
2960
2961 def test_0d_0d_condition(self):
2962 x = np.array(3)

Callers

nothing calls this directly

Calls 4

piecewiseFunction · 0.90
assert_equalFunction · 0.90
assert_array_equalFunction · 0.90
assert_raises_regexFunction · 0.90

Tested by

no test coverage detected