diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/format.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_format.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py index fd5496e96..c411715d8 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -464,7 +464,7 @@ def read_array(fp): # non-chunked case count < max_read_count, so only one read is # performed. - max_read_count = BUFFER_SIZE // dtype.itemsize + max_read_count = BUFFER_SIZE // min(BUFFER_SIZE, dtype.itemsize) array = numpy.empty(count, dtype=dtype) diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 91643e559..485947764 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -428,6 +428,9 @@ def test_roundtrip(): arr2 = roundtrip(arr) yield assert_array_equal, arr, arr2 +def test_long_str(): + long_str_arr = np.ones(1, dtype=np.dtype((str, format.BUFFER_SIZE+1))) + long_str_arr2 = roundtrip(long_str_arr) @dec.slow def test_memmap_roundtrip(): |