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

Method test_keepdims_out

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

Source from the content-addressed store, hash-verified

1130 ]
1131 )
1132 def test_keepdims_out(self, axis):
1133 mask = np.zeros((3, 5, 7, 11), dtype=bool)
1134 # Randomly set some elements to True:
1135 w = np.random.random((4, 200)) * np.array(mask.shape)[:, None]
1136 w = w.astype(np.intp)
1137 mask[tuple(w)] = np.nan
1138 d = masked_array(np.ones(mask.shape), mask=mask)
1139 if axis is None:
1140 shape_out = (1,) * d.ndim
1141 else:
1142 axis_norm = normalize_axis_tuple(axis, d.ndim)
1143 shape_out = tuple(
1144 1 if i in axis_norm else d.shape[i] for i in range(d.ndim))
1145 out = masked_array(np.empty(shape_out))
1146 result = median(d, axis=axis, keepdims=True, out=out)
1147 assert result is out
1148 assert_equal(result.shape, shape_out)
1149
1150 def test_single_non_masked_value_on_axis(self):
1151 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