Skip to content
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

Update leaf.py #1010

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update leaf.py #1010

wants to merge 1 commit into from

Conversation

wony-zheng
Copy link

avoid RuntimeWarning: overflow encountered in long_scalars

avoid RuntimeWarning: overflow encountered in long_scalars
@@ -316,7 +316,7 @@ def _calc_chunkshape(self, expectedrows, rowsize, itemsize):

# Compute the chunksize
MB = 1024 * 1024
expected_mb = (expectedrows * rowsize) // MB
expected_mb = np.int32((np.int64(expectedrows) * rowsize) // MB)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I have not analysed the problem in depth but the need of a double casting looks very strange to me.
What is the data type of expectedrows normally?
In any case Python int should never be subject to overflow. Is it not enough to have a single cast to int?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wony-zheng could you please confirm that the following path works for you?

-        expected_mb = (expectedrows * rowsize) // MB
+        expected_mb = (int(expectedrows) * rowsize) // MB)

@avalentino avalentino added this to the 3.8.1 milestone Mar 22, 2023
@@ -316,7 +316,7 @@ def _calc_chunkshape(self, expectedrows, rowsize, itemsize):

# Compute the chunksize
MB = 1024 * 1024
expected_mb = (expectedrows * rowsize) // MB
expected_mb = np.int32((np.int64(expectedrows) * rowsize) // MB)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wony-zheng could you please confirm that the following path works for you?

-        expected_mb = (expectedrows * rowsize) // MB
+        expected_mb = (int(expectedrows) * rowsize) // MB)

@avalentino avalentino modified the milestones: 3.9.0, 3.9.1, 3.9.2 Oct 6, 2023
@ivilata ivilata modified the milestones: 3.9.2, 3.9.3 Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants