Fix concat_<side>_guards coords assignment - #332
Merged
Merged
Conversation
Coords are read only by default. This meant the existing assignment method raises a ValueError. The fix ensures that coords are assigned properly for each of the four concat functions.
Collaborator
|
Just for historical interest: the mentioned issues were closed as duplicates, not fixed. The original issue is still open (pydata/xarray#2180) but has no update since 2018, so guess it won't ever be fixed. This PR looks like a different workaround for the same issue, but that's not a problem as long as it works! |
dschwoerer
approved these changes
Feb 11, 2026
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.
Fixes #331.
In short,
_concat_upper_guardsand its 3 friends forlower,outerandinnerguards had coord assignments of this type:xBOUT/xbout/region.py
Lines 1345 to 1353 in 9c634a4
According to the comment, this approach was chosen due to a bug. I'm not sure if I've followed the Xarray issue chain properly, but it now seems fixed: pydata/xarray#4393
This approach doesn't work anymore because coordinates are read only by default.... and I am very confused why it worked for me not that long ago! I have replaced it with the proper Xarray assignment.
I based this PR off a commit before #317 because that PR breaks loading any simulations for me (#329). Let's merge this one after #329 is resolved.