Integer overflow in _radial_profile in metrics\__funcs__.py
See original GitHub issueI am just trying to use porespy and stumbled across an integer overflow error:
File "…\porespy\metrics_funcs_.py
", line 332, in _radial_profile
radial_sum[i] = np.sum(autocorr[mask])/np.sum(mask)OverflowError: Python int too large to convert to C long
It seems this is easily fixable changing line 325 in .\porespy\metrics_funcs_.py from
radial_sum = np.zeros_like(bins)
to
radial_sum = np.zeros_like(bins, np.int64)
The error occured following this example of the documentation using an real data image (8-bit TIFF, 1024x880):
im = cv2.imread( settings["referenceFilePath"], 0 )
data = ps.metrics.two_point_correlation_fft(im)
fig = plt.plot(*data, 'bo-')
plt.ylabel('probability')
plt.xlabel('correlation length [voxels]')
plt.show()
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Most efficient way to calculate radial profile - python
It looks like you could use numpy.bincount here: import numpy as np def radial_profile(data, center): y, x = np.indices((data.shape)) r ...
Read more >Integer overflow - Wikipedia
In computer programming, an integer overflow occurs when an arithmetic operation attempts to create a numeric value that is outside of the range...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Okay, thanks for your fast response and the nice libary!
I see. It’s because on Linux. According to this stackoverflow thread, the default
numpy.int_is C long, but C long isint32even Win64.Thank you for reporting this. We’ll see what we can do to force
int64as the defaultinttype.