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

Method test_keepdims_out

numpy/lib/tests/test_nanfunctions.py:889–904  ·  view source on GitHub ↗
(self, axis)

Source from the content-addressed store, hash-verified

887 )
888 @pytest.mark.filterwarnings("ignore:All-NaN slice:RuntimeWarning")
889 def test_keepdims_out(self, axis):
890 d = np.ones((3, 5, 7, 11))
891 # Randomly set some elements to NaN:
892 w = np.random.random((4, 200)) * np.array(d.shape)[:, None]
893 w = w.astype(np.intp)
894 d[tuple(w)] = np.nan
895 if axis is None:
896 shape_out = (1,) * d.ndim
897 else:
898 axis_norm = normalize_axis_tuple(axis, d.ndim)
899 shape_out = tuple(
900 1 if i in axis_norm else d.shape[i] for i in range(d.ndim))
901 out = np.empty(shape_out)
902 result = np.nanmedian(d, axis=axis, keepdims=True, out=out)
903 assert result is out
904 assert_equal(result.shape, shape_out)
905
906 def test_out(self):
907 mat = np.random.rand(3, 3)

Callers

nothing calls this directly

Calls 4

normalize_axis_tupleFunction · 0.90
assert_equalFunction · 0.90
randomMethod · 0.80
astypeMethod · 0.80

Tested by

no test coverage detected