question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integer overflow in _radial_profile in metrics\__funcs__.py

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kleinerELMcommented, Apr 29, 2020

Okay, thanks for your fast response and the nice libary!

0reactions
ma-sadeghicommented, Apr 29, 2020

I see. It’s because on Linux. According to this stackoverflow thread, the default numpy.int_ is C long, but C long is int32 even Win64.

Thank you for reporting this. We’ll see what we can do to force int64 as the default int type.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found