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

Method test_subclass_repr

numpy/ma/tests/test_subclassing.py:338–347  ·  view source on GitHub ↗

test that repr uses the name of the subclass and 'array' for np.ndarray

(self)

Source from the content-addressed store, hash-verified

336 assert_(isinstance(mxcsub_nomask[0], ComplicatedSubArray))
337
338 def test_subclass_repr(self):
339 """test that repr uses the name of the subclass
340 and 'array' for np.ndarray"""
341 x = np.arange(5)
342 mx = masked_array(x, mask=[True, False, True, False, False])
343 assert_startswith(repr(mx), 'masked_array')
344 xsub = SubArray(x)
345 mxsub = masked_array(xsub, mask=[True, False, True, False, False])
346 assert_startswith(repr(mxsub),
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"""

Callers

nothing calls this directly

Calls 2

assert_startswithFunction · 0.85
SubArrayClass · 0.85

Tested by

no test coverage detected