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

Method test_replace_max

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

Source from the content-addressed store, hash-verified

81
82class TestPutAlongAxis:
83 def test_replace_max(self):
84 a_base = np.array([[10, 30, 20], [60, 40, 50]])
85
86 for axis in list(range(a_base.ndim)) + [None]:
87 # we mutate this in the loop
88 a = a_base.copy()
89
90 # replace the max with a small value
91 i_max = _add_keepdims(np.argmax)(a, axis=axis)
92 put_along_axis(a, i_max, -99, axis=axis)
93
94 # find the new minimum, which should max
95 i_min = _add_keepdims(np.argmin)(a, axis=axis)
96
97 assert_equal(i_min, i_max)
98
99 def test_broadcast(self):
100 """ 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