Skip to content

propagate attrs on coords in Dataset.map #10602

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented Aug 4, 2025

This makes sure we propagate attrs in coords in Dataset.map if keep_attrs == True. It uses the same semantics as for the data variables, which means that keep_attrs=True will overwrite any changes to the attrs by the mapped function.

This hides the use of the division operator in some of the weighted operations, which are solely affected by the global keep_attrs property.

Alternative implementation options:

  • Instead of collecting and merging the coords then copying over coordinate attrs we could also make DataArray._copy_attrs_from iterate over the coordinates.
  • Instead of modifying Dataset.map, we could also make all weighted ops receive a keep_attrs parameter

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.

Missing coordinate attributes after weighted mean
1 participant