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

Method test_refcount

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

Source from the content-addressed store, hash-verified

5787
5788 @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
5789 def test_refcount(self):
5790 # includes regression test for reference count error gh-13165
5791 inds = [np.intp(0), np.array([True]*self.a.size), np.array([0]), None]
5792 indtype = np.dtype(np.intp)
5793 rc_indtype = sys.getrefcount(indtype)
5794 for ind in inds:
5795 rc_ind = sys.getrefcount(ind)
5796 for _ in range(100):
5797 try:
5798 self.a.flat[ind]
5799 except IndexError:
5800 pass
5801 assert_(abs(sys.getrefcount(ind) - rc_ind) < 50)
5802 assert_(abs(sys.getrefcount(indtype) - rc_indtype) < 50)
5803
5804 def test_index_getset(self):
5805 it = np.arange(10).reshape(2, 1, 5).flat

Callers

nothing calls this directly

Calls 3

assert_Function · 0.90
absFunction · 0.85
dtypeMethod · 0.45

Tested by

no test coverage detected