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

Method test_refcounting

numpy/core/tests/test_item_selection.py:51–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

49 assert_(res.shape == (2,) + index_array.shape)
50
51 def test_refcounting(self):
52 objects = [object() for i in range(10)]
53 for mode in ('raise', 'clip', 'wrap'):
54 a = np.array(objects)
55 b = np.array([2, 2, 4, 5, 3, 5])
56 a.take(b, out=a[:6], mode=mode)
57 del a
58 if HAS_REFCOUNT:
59 assert_(all(sys.getrefcount(o) == 3 for o in objects))
60 # not contiguous, example:
61 a = np.array(objects * 2)[::2]
62 a.take(b, out=a[:6], mode=mode)
63 del a
64 if HAS_REFCOUNT:
65 assert_(all(sys.getrefcount(o) == 3 for o in objects))
66
67 def test_unicode_mode(self):
68 d = np.arange(10)

Callers

nothing calls this directly

Calls 3

assert_Function · 0.90
takeMethod · 0.80
allFunction · 0.50

Tested by

no test coverage detected