Skip to content

keep attrs when reducing xray objects #138

Closed

Description

@jhamman

Reduction operations currently drop all Variable and Dataset attrs when a reduction operation is performed. I'm proposing adding a keyword to these methods to allow for copying of the original Variable or Dataset attrs.

The default value of the keep_attrs keyword would be False.

For example:

new = ds.mean(keep_attrs=True)

returns new with all the Variable and Dataset attrs as ds contained.

Some previous discussion in #131 and #137.

Activity

  1. shoyer commented on May 21, 2014

    @shoyer
    Member

    This seems fine by me.

    @akleeman Your thoughts?

  2. akleeman commented on May 21, 2014

    @akleeman
    Contributor

    Yeah I agree, seems like a great option to have.

  3. ebrevdo commented on May 21, 2014

    @ebrevdo
    Contributor

    Why not options like 'first', 'common', etc?
    On May 20, 2014 11:52 PM, "akleeman" notifications@github.com wrote:

    Yeah I agree, seems like a great option to have.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/138#issuecomment-43718217
    .

  4. shoyer commented on May 21, 2014

    @shoyer
    Member

    @ebrevdo This is for reduce operations like "mean" which are unary operators. But it does seem like a good idea to consider if/how this could be extended to binary operations (e.g., "merge" or "add"). To make this an option for mathematical operations like "add" we would need to add an add method for instead of just relying on overloading the + operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions