()
| 2748 | |
| 2749 | @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts") |
| 2750 | def 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 | |
| 2767 | def test_load_multiple_arrays_until_eof(): |
| 2768 | f = BytesIO() |
nothing calls this directly
no test coverage detected