-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support alignment/broadcasting with unlabeled dimensions of size 1 #2171
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
Comments
We'd really like to be able to do this for broadcastable matrix multiplication. See e.g. spacetx/starfish#983 Do you have a sense of how this might be implemented, or a suggested work around in the mean time? |
I think there are three places where you would need to fix this: Index based alignment in xarray/xarray/core/alignment.py Line 143 in 6d20766
Unified dimensions for broadcasting variables, which is defined in two places: xarray/xarray/core/variable.py Line 1978 in 6d20766
xarray/xarray/core/computation.py Line 441 in 6d20766
The easiest work around is probably to call |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the |
Sometimes, it's convenient to include placeholder dimensions of size 1, which allows for removing any ambiguity related to the order of output dimensions.
Currently, this is not supported with xarray:
However, these operations aren't really ambiguous. With size 1 dimensions, we could logically do broadcasting like NumPy arrays, e.g.,
This would be particularly convenient if we add
keepdims=True
to xarray operations (#2170).The text was updated successfully, but these errors were encountered: