Skielex / structure-tensor

Structure tensor 2D and 3D implementation for Python.
MIT License
47 stars 14 forks source link

np.prod overflow #13

Closed rdengate closed 1 year ago

rdengate commented 1 year ago

This fixes an issue where RawArray throws an exception because it's initialized with a negative size due to an overflow. This issue only occurs with large datasets.

Quick reproduction:

import numpy as np
eigenvalues_shape = (3, 500, 6500, 1300)
np.prod(eigenvalues_shape)
# result = -209901888
np.prod(eigenvalues_shape, dtype=np.int64)
# result = 12675000000
rdengate commented 1 year ago

Thank you!

Skielex commented 1 year ago

FYI, I've been working on a new multithreading module, but haven't had time to merge it yet.

rdengate commented 1 year ago

Looks interesting. Unfortunately, I must use an old version of numpy (1.16), so I will have stick with multiprocessing for now.