MCPcopy Create free account
hub / github.com/numpy/numpy / test_invalid

Method test_invalid

numpy/lib/tests/test_shape_base.py:49–64  ·  view source on GitHub ↗

Test it errors when indices has too few dimensions

(self)

Source from the content-addressed store, hash-verified

47 assert_equal(a_func, take_along_axis(a, ai_func, axis=axis))
48
49 def test_invalid(self):
50 """ Test it errors when indices has too few dimensions """
51 a = np.ones((10, 10))
52 ai = np.ones((10, 2), dtype=np.intp)
53
54 # sanity check
55 take_along_axis(a, ai, axis=1)
56
57 # not enough indices
58 assert_raises(ValueError, take_along_axis, a, np.array(1), axis=1)
59 # bool arrays not allowed
60 assert_raises(IndexError, take_along_axis, a, ai.astype(bool), axis=1)
61 # float arrays not allowed
62 assert_raises(IndexError, take_along_axis, a, ai.astype(float), axis=1)
63 # invalid axis
64 assert_raises(np.AxisError, take_along_axis, a, ai, axis=10)
65
66 def test_empty(self):
67 """ Test everything is ok with empty results, even with inserted dims """

Callers

nothing calls this directly

Calls 3

take_along_axisFunction · 0.90
assert_raisesFunction · 0.90
astypeMethod · 0.80

Tested by

no test coverage detected