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

Method test_subclasspreservation

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

Source from the content-addressed store, hash-verified

261 assert_equal(mxsub.info, xsub.info)
262
263 def test_subclasspreservation(self):
264 # Checks that masked_array(...,subok=True) preserves the class.
265 x = np.arange(5)
266 m = [0, 0, 1, 0, 0]
267 xinfo = [(i, j) for (i, j) in zip(x, m)]
268 xsub = MSubArray(x, mask=m, info={'xsub':xinfo})
269 #
270 mxsub = masked_array(xsub, subok=False)
271 assert_(not isinstance(mxsub, MSubArray))
272 assert_(isinstance(mxsub, MaskedArray))
273 assert_equal(mxsub._mask, m)
274 #
275 mxsub = asarray(xsub)
276 assert_(not isinstance(mxsub, MSubArray))
277 assert_(isinstance(mxsub, MaskedArray))
278 assert_equal(mxsub._mask, m)
279 #
280 mxsub = masked_array(xsub, subok=True)
281 assert_(isinstance(mxsub, MSubArray))
282 assert_equal(mxsub.info, xsub.info)
283 assert_equal(mxsub._mask, xsub._mask)
284 #
285 mxsub = asanyarray(xsub)
286 assert_(isinstance(mxsub, MSubArray))
287 assert_equal(mxsub.info, xsub.info)
288 assert_equal(mxsub._mask, m)
289
290 def test_subclass_items(self):
291 """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