GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
223 stars 105 forks source link

Unsigned integer in-place addition problems with numpy=2 #1292

Closed erykoff closed 2 months ago

erykoff commented 3 months ago

Using numpy=2 I am seeing problems in test_image.py because of _addValue in image.py. Specifically, the usage arr[y, x] += value now apparently does strict type/bounds checking such that trying to add a negative value to an unsigned integer array is an OverflowError. (With numpy=1 arr += value would fail in the same way, but doing the specific index would not for ... reasons.).

A possible workaround is to force unsafe casting such that the RHS can be np.array(value).astype(self._array.dtype, casting="unsafe"). I don't know if this has performance implications or if somebody has a cleverer idea.

rmjarvis commented 2 months ago

Fixed in #1297.