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

Release: NP2 Overflow Hotfix #2250

Merged
merged 2 commits into from
Jul 11, 2024
Merged

Release: NP2 Overflow Hotfix #2250

merged 2 commits into from
Jul 11, 2024

Conversation

mikedh
Copy link
Owner

@mikedh mikedh commented Jul 11, 2024

  • Numpy 2 has stricter rules about overflowing integers, in an upstream application I was seeing grouping.hashable_rows overflowing an integer.
    • fixed by always promoting float_to_int to an int64 on integer input rather than returning any integer type. I also disabled the "int32 vs int64" choice based on maximum value as it may have provided a speedup in some cases, but making this function simpler and have consistent return types seems more valuable. The type hint will be checked by Beartype in the docker image tests.
  • Removed the prerelease install for Numpy 2 in tests since Numpy 2.0.0 was released June 16.

Traceback for posterity:

File "/home/mikedh/trimesh/trimesh/visual/color.py", line 431, in main_color
    unique, inverse = unique_rows(colors)
                      ^^^^^^^^^^^^^^^^^^^
  File "/home/mikedh/trimesh/trimesh/grouping.py", line 451, in unique_rows
    rows = hashable_rows(data, digits=digits)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikedh/trimesh/trimesh/grouping.py", line 209, in hashable_rows
    bitbang = (as_int.T + threshold).astype(np.uint64)
               ~~~~~~~~~^~~~~~~~~~~
OverflowError: Python integer 32767 out of bounds for uint8

@mikedh mikedh merged commit 85b4bd1 into main Jul 11, 2024
9 checks passed
@mikedh mikedh deleted the np2/overflow branch July 11, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant