spacetelescope / jwst

Python library for science observations from the James Webb Space Telescope
https://jwst-pipeline.readthedocs.io/en/latest/
Other
545 stars 158 forks source link

Refpix output array math incompatible with numpy 2.0 #8578

Open braingram opened 2 weeks ago

braingram commented 2 weeks ago

Refpix when run with numpy 2.0 produces errors:

 >           offset = output[row] * (nx // 5)                # nx // 5 is 640
E           OverflowError: Python integer 640 out of bounds for uint8

https://github.com/spacetelescope/jwst/actions/runs/9570099916/job/26384136420?pr=8576#step:10:533

This is due to different type promotion in numpy 2.0.

For numpy < 2

>> np.uint8(6) * 640
3840

For numpy 2:

>> np.uint8(6) * 640
OverflowError: Python integer 640 out of bounds for uint8

The output referred to above appears to be from the IRS2Model with a schema that defines it's datatype as 'uint8': https://github.com/spacetelescope/stdatamodels/blob/18d07d732892ddcdbb8f13098468491edac3d473/src/stdatamodels/jwst/datamodels/schemas/irs2.schema.yaml#L37 This does not match the docstring for the function: https://github.com/spacetelescope/jwst/blob/8c27f16cafc7b3af6e440719c79785e8dc5d40f4/jwst/refpix/irs2_subtract_reference.py#L331-L333