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 to output datasets #1625

Merged
merged 5 commits into from
Jan 26, 2024
Merged

Option to output datasets #1625

merged 5 commits into from
Jan 26, 2024

Conversation

aulemahal
Copy link
Collaborator

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
  • 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?

  • New option : as_dataset. When True, indicators return Datasets instead of DataArrays or tuples thereof.

Does this PR introduce a breaking change?

No.

Other information:

@github-actions github-actions bot added the CI Automation and Contiunous Integration label Jan 25, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@aulemahal aulemahal requested a review from tlogan2000 January 25, 2024 19:38
@github-actions github-actions bot added the docs Improvements to documenation label Jan 25, 2024
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.

Cool!

Is there a particular reason why we wouldn't want to offer this as a method/call signature of Indicator objects? e.g. some_indicator(..., as_dataset=True)?

@aulemahal
Copy link
Collaborator Author

It's simply that I didn't want to add another argument to the indicators, as to now overcrowd the signature with parameters that do not impact the computation itself.

But, it could be done easily.

@Zeitsperre
Copy link
Collaborator

That's a good point. The workflow example is clear enough, so I don't see any harm from keeping this as an option set via context.

The only other way I could see this being implemented (for conventional xarray users, anyway) would involve extending xarray.DataArray.to_dataset(), but that could be either very easy or an absolute nightmare. Is extending a DataArray class method an acceptable/desirable thing to do?

@tlogan2000
Copy link
Collaborator

LGTM ... I think the context / set_options mode is a decent compromise

@github-actions github-actions bot added the approved Approved for additional tests label Jan 26, 2024
@Zeitsperre
Copy link
Collaborator

New black came out. I'll see what can be done.

@aulemahal
Copy link
Collaborator Author

Oh! I thought this was a python 3.8 issue...

@Zeitsperre
Copy link
Collaborator

FYI: https://github.com/psf/black/releases/tag/24.1.0

Looks like a bunch of breaking changes. I think I'm going to pin black to the pre-commit latest version so we don't run into this again. Will happen in a new PR.

@Zeitsperre Zeitsperre merged commit 2dc5062 into master Jan 26, 2024
18 checks passed
@Zeitsperre Zeitsperre deleted the opt-dataset branch January 26, 2024 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved for additional tests CI Automation and Contiunous Integration docs Improvements to documenation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return Datasets
3 participants