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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy 2.0 support #233

Closed
pllim opened this issue Nov 29, 2023 · 2 comments 路 Fixed by #238
Closed

numpy 2.0 support #233

pllim opened this issue Nov 29, 2023 · 2 comments 路 Fixed by #238

Comments

@pllim
Copy link
Contributor

pllim commented Nov 29, 2023

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
Copy link
Contributor Author

pllim commented Apr 11, 2024

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
Copy link
Contributor Author

pllim commented Apr 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant