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

Method test_invalid

numpy/lib/tests/test_shape_base.py:59–76  ·  view source on GitHub ↗

Test it errors when indices has too few dimensions

(self)

Source from the content-addressed store, hash-verified

57 assert_equal(a_func, take_along_axis(a, ai_func, axis=axis))
58
59 def test_invalid(self):
60 """ Test it errors when indices has too few dimensions """
61 a = np.ones((10, 10))
62 ai = np.ones((10, 2), dtype=np.intp)
63
64 # sanity check
65 take_along_axis(a, ai, axis=1)
66
67 # not enough indices
68 assert_raises(ValueError, take_along_axis, a, np.array(1), axis=1)
69 # bool arrays not allowed
70 assert_raises(IndexError, take_along_axis, a, ai.astype(bool), axis=1)
71 # float arrays not allowed
72 assert_raises(IndexError, take_along_axis, a, ai.astype(float), axis=1)
73 # invalid axis
74 assert_raises(AxisError, take_along_axis, a, ai, axis=10)
75 # invalid indices
76 assert_raises(ValueError, take_along_axis, a, ai, axis=None)
77
78 def test_empty(self):
79 """ 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