spacetelescope / stginga

Ginga products specific to STScI data analysis.
https://stginga.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6 stars 10 forks source link

numpy 2.0 support #233

Closed pllim closed 7 months ago

pllim commented 1 year ago

Currently devdeps does not use numpy 2.0.dev nightly wheel. Not sure if I can get to this before numpy 2.0 is released for real next month. We'll find out for sure when it is released and CI starts to fail. 😬

pllim commented 7 months ago

Fails in rc-testing now: https://github.com/spacetelescope/stginga/actions/runs/8653500942/job/23728786780

__________________ TestStuffWithFITS.test_scale_image_with_dq __________________

self = <stginga.tests.test_utils.TestStuffWithFITS object at 0x7faf7ba95650>

    def test_scale_image_with_dq(self):
        """Test scaling with mask."""
        outfile = self.filename.replace('test.fits', 'out_masked.fits')
        parsedq = DQParser(
            get_pkg_data_filename('data/dqflags_jwst.txt', package='stginga'))
>       scale_image_with_dq(
            self.filename, outfile, 0.5, parsedq, kernel_width=5,
            sci_ext='SCI', dq_ext='DQ', bad_flag=self.bad_flag,
            ignore_edge_pixels=1)

stginga/tests/test_utils.py:161: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
stginga/utils.py:504: in scale_image_with_dq
    dqs_by_flags = dq_parser.interpret_array(dq)
stginga/utils.py:241: in interpret_array
    list(map(_one_flag, self._valid_flags[1:]))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

vf = np.uint64(1)

    def _one_flag(vf):
>       dqs_by_flag[vf] = np.where((data & vf) != 0)
E       TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

stginga/utils.py:238: TypeError
________________________________ test_dq_parser ________________________________

    def test_dq_parser():
        parsedq = DQParser(
            get_pkg_data_filename('data/dqflags_acs.txt', package='stginga'))

        # One pixel
        dqs = parsedq.interpret_dqval(16658)
        assert sorted(dqs['DQFLAG']) == [2, 16, 256, 16384]

        # Array
>       dqs = parsedq.interpret_array([1, 1, 16658, 0])

stginga/tests/test_utils.py:184: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
stginga/utils.py:241: in interpret_array
    list(map(_one_flag, self._valid_flags[1:]))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

vf = np.uint64(1)

    def _one_flag(vf):
>       dqs_by_flag[vf] = np.where((data & vf) != 0)
E       TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

stginga/utils.py:238: TypeError
pllim commented 7 months ago

I think in numpy 2, something got "upgraded" from int to float, maybe, or could be uint and int cannot be bitwise like that anymore.