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

Method test_argequivalent

numpy/lib/tests/test_shape_base.py:41–57  ·  view source on GitHub ↗

Test it translates from arg to

(self)

Source from the content-addressed store, hash-verified

39
40class TestTakeAlongAxis:
41 def test_argequivalent(self):
42 """ Test it translates from arg<func> to <func> """
43 from numpy.random import rand
44 a = rand(3, 4, 5)
45
46 funcs = [
47 (np.sort, np.argsort, {}),
48 (_add_keepdims(np.min), _add_keepdims(np.argmin), {}),
49 (_add_keepdims(np.max), _add_keepdims(np.argmax), {}),
50 #(np.partition, np.argpartition, dict(kth=2)),
51 ]
52
53 for func, argfunc, kwargs in funcs:
54 for axis in list(range(a.ndim)) + [None]:
55 a_func = func(a, axis=axis, **kwargs)
56 ai_func = argfunc(a, axis=axis, **kwargs)
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 """

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