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

Method test_subclass

numpy/core/tests/test_multiarray.py:6415–6432  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6413 assert_equal(np.std(a, where=False), np.nan)
6414
6415 def test_subclass(self):
6416 class TestArray(np.ndarray):
6417 def __new__(cls, data, info):
6418 result = np.array(data)
6419 result = result.view(cls)
6420 result.info = info
6421 return result
6422
6423 def __array_finalize__(self, obj):
6424 self.info = getattr(obj, "info", '')
6425
6426 dat = TestArray([[1, 2, 3, 4], [5, 6, 7, 8]], 'jubba')
6427 res = dat.mean(1)
6428 assert_(res.info == dat.info)
6429 res = dat.std(1)
6430 assert_(res.info == dat.info)
6431 res = dat.var(1)
6432 assert_(res.info == dat.info)
6433
6434
6435class TestVdot:

Callers

nothing calls this directly

Calls 5

assert_Function · 0.90
TestArrayClass · 0.70
meanMethod · 0.45
stdMethod · 0.45
varMethod · 0.45

Tested by

no test coverage detected