Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix robustness fractions and categories attributes #1535

Merged
merged 6 commits into from
Nov 29, 2023
Merged

Conversation

aulemahal
Copy link
Collaborator

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
    • This PR fixes #xyz
  • Tests for the changes have been added (for bug fixes / features)
    • (If applicable) Documentation has been added / updated (for bug fixes / features)
  • CHANGES.rst has been updated (with summary of main changes)
    • Link to issue (:issue:number) and pull request (:pull:number) has been added

What kind of change does this PR introduce?

  • This is a simple PR that fixes a problem with overwritten attributes on coordinates when calling robustness_fractions and robustness_categories.

Does this PR introduce a breaking change?

No

Other information:

@aulemahal aulemahal requested a review from Zeitsperre November 22, 2023 20:08
Copy link
Collaborator

@Zeitsperre Zeitsperre left a comment

Choose a reason for hiding this comment

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

Not sure what's going on but LGTM

@github-actions github-actions bot added the approved Approved for additional tests label Nov 22, 2023
@aulemahal
Copy link
Collaborator Author

héhé sorry, it's kinda undocumented...

robustness_fractions seems to drop the attributes of the source data is some cases. I explicitly add them back at the end of the function.

Same thing for robustness_categories, but here I understood what was going one. I first initialize the inputs from a copy of the source to ensure further in-place changes are not propagated back to the source. I also inverted the xr.where order because xarray takes the attributes from the second argument which was an integer in the previous code, leading to the attributes being lost.

@aulemahal aulemahal merged commit f5b000a into master Nov 29, 2023
12 checks passed
@aulemahal aulemahal deleted the fix-rob-attrs branch November 29, 2023 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved for additional tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants