-
-
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
Should NamedArray be interchangeable with other array types? or Should we support the axis
kwarg?
#8333
Comments
Please weigh this quite low give the amount of context I have — but I would vote "no". Arguably good APIs are limiting as well as permissive, and ideally users shouldn't rely on axis order. (I would also vote to deprecate this from xarray) That said, if there are real use-cases or compatibility concerns, I would override purity for practicality. |
Perhaps the real question is "Should NamedArray be interchangeable with other array types?" If so, we'd want to support all the various array protocols and the |
Yes, that's very fair. Maybe the synthesis of these is |
axis
kwarg for NamedArray reductions?axis
kwarg?
I've been thinking that's what |
Fair point. Another thought: Like numpy, we could provide both an array api interface, and the Xarray type interface So cc @shoyer |
I might be being dense, but what is the purpose of supporting EDIT: I guess here xarray at least would be able to act as general wrapper for other array types (including chunked arrays)... But even then, why bother? The whole point of the array API standard is to make array types interchangeable, so |
Not at all! This is the core question. It's whether we think there's value in allowing users to seamlessly stick in There's some precedence here in that we expect users to call |
What would the user really gain by replacing |
IMO the entire point of named dimensions has always been to remove a whole class of possible user errors: transposition errors. Supporting axis integers anywhere means code that uses xarray becomes vulnerable to such errors again, negating the benefit of using named dimensions. |
There's a lot of appetite for computational functions that handle anything including DataArrays. |
Okay fair, now you say it I have seen that pattern also in MetPy. I have to say personally I've always viewed it as an antipattern though...
Propagating a DataArray through @dopplershift do you want to state your case? 😁
If we do choose to support axis integers then I prefer this solution, because it allows us to keep support for array-API-style functions a "hidden feature", without cluttering the xarray-method-chaining-style API. |
Yeah we should release EDIT: Or does it just work today with all numpy inputs? |
I don't think NamedArray should be interchangeable with other arrays types. Xarray has different semantics than other array API objects, most notably boardcasting by dimension name rather than dimension order. There is room for another array type with named dimensions that is more minimal and intentionally doesn't change any behavior from NumPy, but that array type isn't NamedArray. |
Just recapping our discussion at the last meeting. There's general agreement that NamedArray should not offer an array-API compatible interface. However currently we still rely on scalar ufuncs like @andersy005 can you raise an issue upstream in the array API repo? |
@dcherian, a glance at the Array-API documentation under the purpose and scope sections reveals that ufuncs and gufuncs are marked as out of scope:
this piece of information seems to address our question regarding the Array API's vision on permitting partial implementations, especially centered around scalar ufuncs, doesn’t it? |
I guess the term is "elementwise funcs" https://data-apis.org/array-api/latest/API_specification/elementwise_functions.html |
for those interested, here's the issue: |
This can be closed can't it? Wasn't the conclusion that NamedArray should not try to obey the array API standard and should not support the |
What is your issue?
Raising @Illviljan's comment from #8304 (comment).
The text was updated successfully, but these errors were encountered: