Skip to content

fix(sgli_l1b): Unwrap one-item array attributes on numpy >=2.4 and up… - #3475

Open
cshatto wants to merge 1 commit into
pytroll:mainfrom
cshatto:fix-sgli-numpy-scalar-attrs
Open

cshatto wants to merge 1 commit into
pytroll:mainfrom
cshatto:fix-sgli-numpy-scalar-attrs

Conversation

@cshatto

@cshatto cshatto commented Sep 17, 2026

Copy link
Copy Markdown

JAXA stores Resampling_interval, Number_of_lines and Number_of_pixels as one-element arrays, which the SGLI reader passed to numpy unchanged — relying on the implicit array-to-scalar conversion removed in numpy 2.4, so every real GCOM-C/SGLI granule now fails with TypeError: only 0-dimensional arrays can be converted to Python scalars. This PR calls .item() at the three read sites and rebuilds the test fixtures with one-item arrays so they match real files.

Closes #3470

@cshatto

cshatto commented Sep 21, 2026

Copy link
Copy Markdown
Author

Hello, I just wanted to check-in on the status here. Thanks in advance!

@mraspaud mraspaud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the fix! Looks good to me.

@mraspaud

Copy link
Copy Markdown
Member

@cshatto sorry for the late reaction, I'm the author of this reader and am currently travelling (EUM conference).
The changes look good to me, however I have a question: I'm pretty sure that when I developped the reader, the scalars were not arrays. Do you know if that is a recent addition, and if old data from sgli have the same format? Otherwise, we might need to support both formats...

@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.36%. Comparing base (3ef3599) to head (4566dbc).
⚠️ Report is 74 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3475   +/-   ##
=======================================
  Coverage   96.36%   96.36%           
=======================================
  Files         465      465           
  Lines       59382    59382           
=======================================
  Hits        57225    57225           
  Misses       2157     2157           
Flag Coverage Δ
behaviourtests 3.57% <0.00%> (ø)
unittests 96.45% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cshatto

cshatto commented Sep 23, 2026

Copy link
Copy Markdown
Author

Hi @mraspaud thank you and no problem at all! This small change was blocking our numpy upgrade to > 2 so that is why I poked the issue again. Numpy 2.4 changed the behavior of a 1D array being converted to a scalar, so it could be that the data always behaved as a scalar because numpy was converting it silently from 1D array to scalar.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reading any real GCOM-C/SGLI L1B granule fails with numpy >= 2.4

2 participants