Skip to content

Don't warn about a missing _FillValue for CF coordinate variables - #11524

Open
NoiceHax wants to merge 7 commits into
pydata:mainfrom
NoiceHax:fix/issue-10305
Open

Don't warn about a missing _FillValue for CF coordinate variables#11524
NoiceHax wants to merge 7 commits into
pydata:mainfrom
NoiceHax:fix/issue-10305

Conversation

@NoiceHax

Copy link
Copy Markdown

Description

Closes #10305.

When a float variable is encoded to an integer dtype, NonStringCoder.encode warns that there is no _FillValue to use for NaNs. That warning also fired for CF coordinate variables, meaning 1D variables named after their own dimension. CF says missing data is not allowed in coordinate variables, so those variables are not supposed to carry a _FillValue at all. The warning pushed people toward adding one, which a CF checker then flags.

The fix skips the warning when a variable's dims are exactly (name,), which is the check @kmuehlbauer suggested on the issue. Rounding and the dtype cast are left alone, so the encoded output is the same as before. Data variables and multidimensional auxiliary coordinates still warn, and there are tests for both cases.

This covers only the first part of the issue. The other part, what to do when someone sets _FillValue = None and the float data really does contain NaN, is left out on purpose. @kmuehlbauer noted that the cast result there depends on the platform, so it seems better to handle it separately.

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR. Tools: Claude Code. I used it to write the fix and the tests from the issue and from kmuehlbauer's suggested check, and I reviewed and ran everything myself.

NoiceHax and others added 7 commits August 15, 2026 04:54
NonStringCoder.encode warns when float data is written to an integer dtype
without a _FillValue. CF coordinate variables (1D variables named after their
dimension) are not allowed to hold missing values, so they never need a
_FillValue and the warning is misleading there.

Skip the warning when the variable's dims are exactly (name,). Rounding and
the dtype cast are untouched, so the encoded output is the same as before.
Data variables and multidimensional auxiliary coordinates still warn.

Co-authored-by: Claude <noreply@anthropic.com>
The typos hook rejects the handle in the attribution line, so add it to
the people's names allowlist alongside the existing entries, and restore
the handle the autofix rewrote.

Co-authored-by: Claude <noreply@anthropic.com>
The typos allowlist entry is in place now, so the hook accepts it.

Co-authored-by: Claude <noreply@anthropic.com>
The autofix was rewriting Hax to Hex in the attribution line. Noice was
already allowlisted but Hax was not, so add it and restore the handle.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SerializationWarning for coordinate variables goes against CF conventions

1 participant