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

Method test_invalid

numpy/lib/tests/test_shape_base.py:118–133  ·  view source on GitHub ↗

Test invalid inputs

(self)

Source from the content-addressed store, hash-verified

116 assert_equal(take_along_axis(a, ai, axis=1), 20)
117
118 def test_invalid(self):
119 """ Test invalid inputs """
120 a_base = np.array([[10, 30, 20], [60, 40, 50]])
121 indices = np.array([[0], [1]])
122 values = np.array([[2], [1]])
123
124 # sanity check
125 a = a_base.copy()
126 put_along_axis(a, indices, values, axis=0)
127 assert np.all(a == [[2, 2, 2], [1, 1, 1]])
128
129 # invalid indices
130 a = a_base.copy()
131 with assert_raises(ValueError) as exc:
132 put_along_axis(a, indices, values, axis=None)
133 assert "single dimension" in str(exc.exception)
134
135
136class TestApplyAlongAxis:

Callers

nothing calls this directly

Calls 4

put_along_axisFunction · 0.90
assert_raisesFunction · 0.90
copyMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected