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

Method test_empty

numpy/ma/tests/test_extras.py:1198–1225  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1196 ([np.nan] * i) + [inf] * j)
1197
1198 def test_empty(self):
1199 # empty arrays
1200 a = np.ma.masked_array(np.array([], dtype=float))
1201 with suppress_warnings() as w:
1202 w.record(RuntimeWarning)
1203 assert_array_equal(np.ma.median(a), np.nan)
1204 assert_(w.log[0].category is RuntimeWarning)
1205
1206 # multiple dimensions
1207 a = np.ma.masked_array(np.array([], dtype=float, ndmin=3))
1208 # no axis
1209 with suppress_warnings() as w:
1210 w.record(RuntimeWarning)
1211 warnings.filterwarnings('always', '', RuntimeWarning)
1212 assert_array_equal(np.ma.median(a), np.nan)
1213 assert_(w.log[0].category is RuntimeWarning)
1214
1215 # axis 0 and 1
1216 b = np.ma.masked_array(np.array([], dtype=float, ndmin=2))
1217 assert_equal(np.ma.median(a, axis=0), b)
1218 assert_equal(np.ma.median(a, axis=1), b)
1219
1220 # axis 2
1221 b = np.ma.masked_array(np.array(np.nan, dtype=float, ndmin=2))
1222 with warnings.catch_warnings(record=True) as w:
1223 warnings.filterwarnings('always', '', RuntimeWarning)
1224 assert_equal(np.ma.median(a, axis=2), b)
1225 assert_(w[0].category is RuntimeWarning)
1226
1227 def test_object(self):
1228 o = np.ma.masked_array(np.arange(7.))

Callers

nothing calls this directly

Calls 5

suppress_warningsClass · 0.90
assert_array_equalFunction · 0.90
assert_equalFunction · 0.90
recordMethod · 0.80
assert_Function · 0.50

Tested by

no test coverage detected