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

Method test_subclass_str

numpy/ma/tests/test_subclassing.py:349–361  ·  view source on GitHub ↗

test str with subclass that has overridden str, setitem

(self)

Source from the content-addressed store, hash-verified

347 f'masked_{SubArray.__name__}(data=[--, 1, --, 3, 4]')
348
349 def test_subclass_str(self):
350 """test str with subclass that has overridden str, setitem"""
351 # first without override
352 x = np.arange(5)
353 xsub = SubArray(x)
354 mxsub = masked_array(xsub, mask=[True, False, True, False, False])
355 assert_equal(str(mxsub), '[-- 1 -- 3 4]')
356
357 xcsub = ComplicatedSubArray(x)
358 assert_raises(ValueError, xcsub.__setitem__, 0,
359 np.ma.core.masked_print_option)
360 mxcsub = masked_array(xcsub, mask=[True, False, True, False, False])
361 assert_equal(str(mxcsub), 'myprefix [-- 1 -- 3 4] mypostfix')
362
363 def test_pure_subclass_info_preservation(self):
364 # Test that ufuncs and methods conserve extra information consistently;

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
assert_raisesFunction · 0.90
SubArrayClass · 0.85
ComplicatedSubArrayClass · 0.85

Tested by

no test coverage detected