test str with subclass that has overridden str, setitem
(self)
| 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; |
nothing calls this directly
no test coverage detected