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

Method test_replace_max

numpy/lib/tests/test_shape_base.py:95–109  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

93
94class TestPutAlongAxis:
95 def test_replace_max(self):
96 a_base = np.array([[10, 30, 20], [60, 40, 50]])
97
98 for axis in list(range(a_base.ndim)) + [None]:
99 # we mutate this in the loop
100 a = a_base.copy()
101
102 # replace the max with a small value
103 i_max = _add_keepdims(np.argmax)(a, axis=axis)
104 put_along_axis(a, i_max, -99, axis=axis)
105
106 # find the new minimum, which should max
107 i_min = _add_keepdims(np.argmin)(a, axis=axis)
108
109 assert_equal(i_min, i_max)
110
111 def test_broadcast(self):
112 """ Test that non-indexing dimensions are broadcast in both directions """

Callers

nothing calls this directly

Calls 4

put_along_axisFunction · 0.90
assert_equalFunction · 0.90
_add_keepdimsFunction · 0.85
copyMethod · 0.45

Tested by

no test coverage detected