8000 Cast array size to int64 when loading from archive by drasmuss · Pull Request #7598 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Cast array size to int64 when loading from archive #7598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/lib/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def read_array(fp, allow_pickle=True, pickle_kwargs=None):
if len(shape) == 0:
count = 1
else:
count = numpy.multiply.reduce(shape)
count = numpy.multiply.reduce(shape, dtype=numpy.int64)

# Now read the actual data.
if dtype.hasobject:
Expand Down
14 changes: 14 additions & 0 deletions numpy/lib/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,5 +836,19 @@ def test_large_file_support():
assert_array_equal(r, d)


@dec.slow
def test_large_archive():
a = np.empty((2 ** 30, 2), dtype=np.uint8)
fname = os.path.join(tempdir, "large_archive")

with open(fname, "wb") as f:
np.savez(f, arr=a)

with open(fname, "rb") as f:
new_a = np.load(f)["arr"]

assert a.shape == new_a.shape


if __name__ == "__main__":
run_module_suite()
0