Test it translates from arg to
(self)
| 29 | |
| 30 | class 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 """ |
nothing calls this directly
no test coverage detected