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

Method test_keepdims_out

numpy/ma/tests/test_extras.py:1044–1060  ·  view source on GitHub ↗
(self, axis)

Source from the content-addressed store, hash-verified

1042 ]
1043 )
1044 def test_keepdims_out(self, axis):
1045 mask = np.zeros((3, 5, 7, 11), dtype=bool)
1046 # Randomly set some elements to True:
1047 w = np.random.random((4, 200)) * np.array(mask.shape)[:, None]
1048 w = w.astype(np.intp)
1049 mask[tuple(w)] = np.nan
1050 d = masked_array(np.ones(mask.shape), mask=mask)
1051 if axis is None:
1052 shape_out = (1,) * d.ndim
1053 else:
1054 axis_norm = normalize_axis_tuple(axis, d.ndim)
1055 shape_out = tuple(
1056 1 if i in axis_norm else d.shape[i] for i in range(d.ndim))
1057 out = masked_array(np.empty(shape_out))
1058 result = median(d, axis=axis, keepdims=True, out=out)
1059 assert result is out
1060 assert_equal(result.shape, shape_out)
1061
1062 def test_single_non_masked_value_on_axis(self):
1063 data = [[1., 0.],

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected