MCPcopy
hub / github.com/numpy/numpy / test_subclasspreservation

Method test_subclasspreservation

numpy/ma/tests/test_subclassing.py:272–297  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

270 assert_equal(mxsub.info, xsub.info)
271
272 def test_subclasspreservation(self):
273 # Checks that masked_array(...,subok=True) preserves the class.
274 x = np.arange(5)
275 m = [0, 0, 1, 0, 0]
276 xinfo = list(zip(x, m))
277 xsub = MSubArray(x, mask=m, info={'xsub': xinfo})
278 #
279 mxsub = masked_array(xsub, subok=False)
280 assert_(not isinstance(mxsub, MSubArray))
281 assert_(isinstance(mxsub, MaskedArray))
282 assert_equal(mxsub._mask, m)
283 #
284 mxsub = asarray(xsub)
285 assert_(not isinstance(mxsub, MSubArray))
286 assert_(isinstance(mxsub, MaskedArray))
287 assert_equal(mxsub._mask, m)
288 #
289 mxsub = masked_array(xsub, subok=True)
290 assert_(isinstance(mxsub, MSubArray))
291 assert_equal(mxsub.info, xsub.info)
292 assert_equal(mxsub._mask, xsub._mask)
293 #
294 mxsub = asanyarray(xsub)
295 assert_(isinstance(mxsub, MSubArray))
296 assert_equal(mxsub.info, xsub.info)
297 assert_equal(mxsub._mask, m)
298
299 def test_subclass_items(self):
300 """test that getter and setter go via baseclass"""

Callers

nothing calls this directly

Calls 5

assert_Function · 0.90
assert_equalFunction · 0.90
asarrayFunction · 0.90
asanyarrayFunction · 0.90
MSubArrayClass · 0.85

Tested by

no test coverage detected