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

Function test_load_refcount

numpy/lib/tests/test_io.py:2750–2765  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2748
2749@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
2750def test_load_refcount():
2751 # Check that objects returned by np.load are directly freed based on
2752 # their refcount, rather than needing the gc to collect them.
2753
2754 f = BytesIO()
2755 np.savez(f, [1, 2, 3])
2756 f.seek(0)
2757
2758 with assert_no_gc_cycles():
2759 np.load(f)
2760
2761 f.seek(0)
2762 dt = [("a", 'u1', 2), ("b", 'u1', 2)]
2763 with assert_no_gc_cycles():
2764 x = np.loadtxt(TextIO("0 1 2 3"), dtype=dt)
2765 assert_equal(x, np.array([((0, 1), (2, 3))], dtype=dt))
2766
2767def test_load_multiple_arrays_until_eof():
2768 f = BytesIO()

Callers

nothing calls this directly

Calls 4

assert_no_gc_cyclesFunction · 0.90
assert_equalFunction · 0.90
TextIOClass · 0.85
seekMethod · 0.80

Tested by

no test coverage detected