Skip to content

Updated Dataset Arithmetic Methods to Support 'keep_attrs' Option#3

Open
fumedev[bot] wants to merge 1 commit intotest3from
add_keep_attrs_to_dataset_arithmetic
Open

Updated Dataset Arithmetic Methods to Support 'keep_attrs' Option#3
fumedev[bot] wants to merge 1 commit intotest3from
add_keep_attrs_to_dataset_arithmetic

Conversation

@fumedev
Copy link
Copy Markdown

@fumedev fumedev bot commented Mar 24, 2024

CHANGED

  • Updated the _binary_op method in xarray/core/dataset.py to incorporate logic for handling the keep_attrs option. The method now includes checks for keep_attrs and preserves attributes accordingly during binary operations with Dataset objects.
  • Modified the arithmetic methods in the Dataset class, such as __add__ and __sub__, to accept a keep_attrs parameter which is passed through to the _binary_op method. This enhancement allows end-users to control attribute preservation on a per-operation basis.
  • Added new tests in xarray/tests/test_dataset.py to verify the functionality of keep_attrs during binary operations with Dataset objects. These tests ensure that attributes are preserved as expected when performing arithmetic operations on datasets.
  • All changes have been made with adherence to PEP8/flake8 standards, and comprehensive unit tests have been included to cover the new logic. Local tests have been successfully executed to identify and rectify any errors before submitting the PR.

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.

0 participants