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

Method test_argequivalent

numpy/lib/tests/test_shape_base.py:31–47  ·  view source on GitHub ↗

Test it translates from arg to

(self)

Source from the content-addressed store, hash-verified

29
30class TestTakeAlongAxis:
31 def test_argequivalent(self):
32 """ Test it translates from arg<func> to <func> """
33 from numpy.random import rand
34 a = rand(3, 4, 5)
35
36 funcs = [
37 (np.sort, np.argsort, dict()),
38 (_add_keepdims(np.min), _add_keepdims(np.argmin), dict()),
39 (_add_keepdims(np.max), _add_keepdims(np.argmax), dict()),
40 (np.partition, np.argpartition, dict(kth=2)),
41 ]
42
43 for func, argfunc, kwargs in funcs:
44 for axis in list(range(a.ndim)) + [None]:
45 a_func = func(a, axis=axis, **kwargs)
46 ai_func = argfunc(a, axis=axis, **kwargs)
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 """

Callers

nothing calls this directly

Calls 5

assert_equalFunction · 0.90
take_along_axisFunction · 0.90
randFunction · 0.85
_add_keepdimsFunction · 0.85
funcFunction · 0.50

Tested by

no test coverage detected