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

Numpy 2.0.0 doesn't allow out of range integers when casting to np.uint64 #803

Open
ehiggins0 opened this issue Jun 18, 2024 · 1 comment · May be fixed by #805
Open

Numpy 2.0.0 doesn't allow out of range integers when casting to np.uint64 #803

ehiggins0 opened this issue Jun 18, 2024 · 1 comment · May be fixed by #805
Assignees
Labels
bug Something isn't working numpy 2.0 compat

Comments

@ehiggins0
Copy link

As of June 16, numpy 2.0.0 was released with breaking changes regarding the handling of out of bounds values when casting. This breaks the below line since python's native hash function can output out of bound values:

datahash = np.uint64(hash(str(raster.data.get())))

2024-06-18T22:51:25.961Z	File "/usr/local/lib/python3.10/dist-packages/xrspatial/viewshed.py", line 1663, in viewshed
2024-06-18T22:51:25.961Z	return viewshed_gpu(raster, x, y, observer_elev, target_elev)
2024-06-18T22:51:25.961Z	File "/usr/local/lib/python3.10/dist-packages/xrspatial/gpu_rtx/viewshed.py", line 280, in viewshed_gpu
2024-06-18T22:51:25.961Z	scale = create_triangulation(raster, optix)
2024-06-18T22:51:25.961Z	File "/usr/local/lib/python3.10/dist-packages/xrspatial/gpu_rtx/mesh_utils.py", line 7, in create_triangulation
2024-06-18T22:51:25.961Z	datahash = np.uint64(hash(str(raster.data.get())))
2024-06-18T22:51:25.961Z	OverflowError: Python integer -2413162623232959393 out of bounds for uint64

The easy workaround for now is to pin the local numpy version to 1.26.4, but it might be a good idea to a) add this to readme/dependencies for now, and/or b) move to a better hash function that does not result in negative numbers.

@brendancol
Copy link
Contributor

@ehiggins0 hey thanks so much for the info and we'll look to upgrade the datahash above

@brendancol brendancol added bug Something isn't working numpy 2.0 compat labels Jul 16, 2024
@brendancol brendancol self-assigned this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working numpy 2.0 compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants