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

Option for combine_attrs with conflicting values silently dropped #4749

Closed
shoyer opened this issue Jan 1, 2021 · 0 comments · Fixed by #4827
Closed

Option for combine_attrs with conflicting values silently dropped #4749

shoyer opened this issue Jan 1, 2021 · 0 comments · Fixed by #4827
Labels
topic-metadata Relating to the handling of metadata (i.e. attrs and encoding)

Comments

@shoyer
Copy link
Member

shoyer commented Jan 1, 2021

merge() currently supports four options for merging attrs:

    combine_attrs : {"drop", "identical", "no_conflicts", "override"}, \
                    default: "drop"
        String indicating how to combine attrs of the objects being merged:
        - "drop": empty attrs on returned Dataset.
        - "identical": all attrs must be the same on every object.
        - "no_conflicts": attrs from all objects are combined, any that have
          the same name must also have the same value.
        - "override": skip comparing and copy attrs from the first dataset to
          the result.

It would be nice to have an option to combine attrs from all objects like "no_conflicts", but that drops attributes with conflicting values rather than raising an error. We might call this combine_attrs="drop_conflicts" or combine_attrs="matching".

This is similar to how xarray currently handles conflicting values for DataArray.name and would be more suitable to consider for the default behavior of merge and other functions/methods that merge coordinates (e.g., apply_ufunc, concat, where, binary arithmetic).

cc @keewis

@shoyer shoyer added the topic-metadata Relating to the handling of metadata (i.e. attrs and encoding) label Jan 1, 2021
@shoyer shoyer changed the title Combine attrs with conflicting values silently dropped Option for combine_attrs with conflicting values silently dropped Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-metadata Relating to the handling of metadata (i.e. attrs and encoding)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant