xarray-spatial
xarray-spatial copied to clipboard
Numpy 2.0.0 doesn't allow out of range integers when casting to np.uint64
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:
https://github.com/makepath/xarray-spatial/blob/555706cca8b1fdcd03837c10c3ed77f2b586cd6b/xrspatial/gpu_rtx/mesh_utils.py#L7
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.
@ehiggins0 hey thanks so much for the info and we'll look to upgrade the datahash above