-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Consistent naming for xarray's methods that apply functions #1251
Comments
Sounds good. It breaks the consistency with pandas' |
Another option is to keep We could even do the |
I would be +1 for |
Would we accept this? I'd be up for doing the PR to deprecate |
-1 for pandas incompatibility. I would like to rename |
+0.5 if |
I don't think we should consider ourselves beholden to pandas's bad names, but we should definitely try to preserve backwards compatibility and interpretability for users. Going back to Python itself:
For xarray, we need:
Currently, we call both (1) and (2) So long term, it could make sense to rename the current That said, I'm trying to imagine what the transition process for switching to new behavior for I suppose we could do this by adding a
We would end up with an extra extraneous |
I put the change for I think those are probably the two easiest decisions to make (and hopefully will kick off moving this issue forwards) Edit: the reason I hesitated for |
@max-sixty thanks for pushing this along! I think I'm coming to appreciate backwards compatibility as an important consideration more and more these days. It's just really painful to reuse methods for something entirely different. This makes me lean towards adding separate |
OK. Does that inform your view on I more strongly think that I'm keener to offer What are your thoughts re:
|
This is a fair point.
I would support this. |
@max-sixty I like your proposal! |
FYI the We still don't have an |
We currently have two types of methods that take a function to apply to xarray objects:
pipe
(onDataArray
andDataset
): apply a function to this entire object (array.pipe(func)
->func(array)
)apply
(onDataset
andGroupBy
): apply a function to each labeled object in this object (e.g.,ds.apply(func)
->ds({k: func(v) for k, v in ds.data_vars.items()})
).And one more method that we want to add but isn't finalized yet -- currently named
apply_ufunc
:I'd like to have three distinct names that makes it clear what these methods do and how they are different. This has come up a few times recently, e.g., #1130
One proposal: rename
apply
tomap
, and then useapply
only for methods that act on unlabeled arrays. This would require a deprecation cycle, but eventually it would let us add.apply
methods for handling raw arrays to both Dataset and DataArray. (We could use a separate apply method fromapply_ufunc
to convertdim
arguments toaxis
and not do automatic broadcasting.)The text was updated successfully, but these errors were encountered: