Skip to content

Allow repeated, leading and trailing spaces in coordinates and ancillary_variables - #693

Open
ZackaryLoevseth wants to merge 1 commit into
xarray-contrib:mainfrom
ZackaryLoevseth:fix/blank-separated-lists
Open

ZackaryLoevseth wants to merge 1 commit into
xarray-contrib:mainfrom
ZackaryLoevseth:fix/blank-separated-lists

Conversation

@ZackaryLoevseth

Copy link
Copy Markdown

CF 1.12 §2.6 allows a blank-separated list to have more than one space between names and to begin or end with spaces. get_associated_variable_names splits coordinates and ancillary_variables with split(" "), so these produce empty names: with coordinates=" lat lon ", ds.cf["temp"] raises UnboundLocalError, and a doubled space warns that a variable named '' is missing.

This changes both to split(). The new test covers both attributes, in attrs and encoding, with repeated, leading and trailing spaces, and checks the associated names, the selection, that no warning is raised and that the input is unchanged. 16 of its 20 cases fail on main; all pass with the change, and the full suite passes.

flag_meanings has the same problem ("low high" raises a ValueError); I can send that separately.

CF allows blank-separated lists to use several spaces between names and
to start or end with spaces. Splitting coordinates and
ancillary_variables with split(" ") produced empty names.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant