Repository navigation
FIX: Require plausible dtype for coordinate regex fallback - #4174
Open
thaliamontreux wants to merge 1 commit into
Open
thaliamontreux wants to merge 1 commit into
thaliamontreux wants to merge 1 commit into
Conversation
The non-CF name-based fallback in check_axis matched any variable whose name fit the coordinate regexes, so a string-valued auxiliary coordinate like 'longseason' was misidentified as a longitude candidate and made da.metpy.longitude fail (Unidata#3860). Now only apply the regex fallback when the variable has a plausible dtype: numeric for spatial/vertical axes, or numeric/datetimelike for time.
thaliamontreux
force-pushed
the
fix-coord-regex-dtype
branch
from
October 24, 2026 23:49
9e730b2 to
cad5fdb
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #3860, following the direction suggested by the reporter. The non-CF name-based regex fallback in
check_axismatched any variable whose name fit, so a string-valued auxiliary coordinate likelongseason=('isobaric', ['DJF', 'MAM'])was misidentified as a longitude candidate and.metpy.longitudeaccess failed.Now the regex fallback only applies when the variable's dtype is plausible for a coordinate: numeric for spatial/vertical axes, or numeric/datetimelike for
time. CF-standard attributes and unit checks are unaffected and still take precedence.Checklist
longseasonreproducer)tests/test_xarray.pypasses except 5 pre-existing xarray>=2025.12Dataset.mapattrs failures tracked in Incompatibility with xarray 2025.12.0 #3978 (fixed upstream in Refactor Dataset.map to merge attrs instead of copying pydata/xarray#11020)