diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2022-05-02 15:43:08 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-05-02 16:15:09 +0200 |
commit | 0a9634c87b04b15b75e2906387b56892cd91b656 (patch) | |
tree | 934ade54324f00bf5501215484eb016fe403b9b1 /numpy/lib/tests | |
parent | b6ffbdaf42caba608e9e43f8309730b9a60d6584 (diff) | |
download | numpy-0a9634c87b04b15b75e2906387b56892cd91b656.tar.gz |
TST: Make `test_large_archive` robust against memory issues [wheel build]
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_format.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 78e67a89b..cf35e1563 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -285,6 +285,7 @@ from numpy.testing import ( assert_, assert_array_equal, assert_raises, assert_raises_regex, assert_warns, ) +from numpy.testing._private.utils import requires_memory from numpy.lib import format @@ -879,11 +880,13 @@ def test_large_file_support(tmpdir): @pytest.mark.skipif(np.dtype(np.intp).itemsize < 8, reason="test requires 64-bit system") @pytest.mark.slow +@requires_memory(free_bytes=2 * 2**30) def test_large_archive(tmpdir): # Regression test for product of saving arrays with dimensions of array # having a product that doesn't fit in int32. See gh-7598 for details. + shape = (2**30, 2) try: - a = np.empty((2**30, 2), dtype=np.uint8) + a = np.empty(shape, dtype=np.uint8) except MemoryError: pytest.skip("Could not create large file") @@ -892,10 +895,12 @@ def test_large_archive(tmpdir): with open(fname, "wb") as f: np.savez(f, arr=a) + del a + with open(fname, "rb") as f: new_a = np.load(f)["arr"] - assert_(a.shape == new_a.shape) + assert new_a.shape == shape def test_empty_npz(tmpdir): |