-
-
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
enable xr.ALL_DIMS in xr.dot #3424
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
24cffaf
enable xr.ALL_DIMS in xr.dot
mathause fb01a13
trailing whitespace
mathause 87b6f8f
Merge remote-tracking branch 'origin' into feature/dot_ALL_DIMS
mathause 75ebcb0
Merge branch 'master' into feature/dot_ALL_DIMS
mathause ce71868
Merge branch 'master' into feature/dot_ALL_DIMS
mathause 7544251
move whats new to other ellipsis work
mathause 74ef2d1
xr.ALL_DIMS -> Ellipsis
mathause File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -25,6 +25,7 @@ | |||||
|
||||||
from . import duck_array_ops, utils | ||||||
from .alignment import deep_align | ||||||
from .common import ALL_DIMS | ||||||
from .merge import merge_coordinates_without_align | ||||||
from .pycompat import dask_array_type | ||||||
from .utils import is_dict_like | ||||||
|
@@ -1055,7 +1056,7 @@ def dot(*arrays, dims=None, **kwargs): | |||||
---------- | ||||||
arrays: DataArray (or Variable) objects | ||||||
Arrays to compute. | ||||||
dims: str or tuple of strings, optional | ||||||
dims: xarray.ALL_DIMS, str or tuple of strings, optional | ||||||
Which dimensions to sum over. | ||||||
If not speciified, then all the common dimensions are summed over. | ||||||
**kwargs: dict | ||||||
|
@@ -1070,7 +1071,7 @@ def dot(*arrays, dims=None, **kwargs): | |||||
-------- | ||||||
|
||||||
>>> import numpy as np | ||||||
>>> import xarray as xp | ||||||
>>> import xarray as xr | ||||||
>>> da_a = xr.DataArray(np.arange(3 * 2).reshape(3, 2), dims=['a', 'b']) | ||||||
>>> da_b = xr.DataArray(np.arange(3 * 2 * 2).reshape(3, 2, 2), | ||||||
... dims=['a', 'b', 'c']) | ||||||
|
@@ -1117,6 +1118,14 @@ def dot(*arrays, dims=None, **kwargs): | |||||
[273, 446, 619]]) | ||||||
Dimensions without coordinates: a, d | ||||||
|
||||||
>>> xr.dot(da_a, da_b) | ||||||
<xarray.DataArray (c: 2)> | ||||||
array([110, 125]) | ||||||
Dimensions without coordinates: c | ||||||
|
||||||
>>> xr.dot(da_a, da_b, dims=xr.ALL_DIMS) | ||||||
<xarray.DataArray ()> | ||||||
array(235) | ||||||
""" | ||||||
from .dataarray import DataArray | ||||||
from .variable import Variable | ||||||
|
@@ -1141,7 +1150,9 @@ def dot(*arrays, dims=None, **kwargs): | |||||
einsum_axes = "abcdefghijklmnopqrstuvwxyz" | ||||||
dim_map = {d: einsum_axes[i] for i, d in enumerate(all_dims)} | ||||||
|
||||||
if dims is None: | ||||||
if dims is ALL_DIMS: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
dims = all_dims | ||||||
elif dims is None: | ||||||
# find dimensions that occur more than one times | ||||||
dim_counts = Counter() | ||||||
for arr in arrays: | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2747,7 +2747,7 @@ def dot( | |||||
---------- | ||||||
other : DataArray | ||||||
The other array with which the dot product is performed. | ||||||
dims: hashable or sequence of hashables, optional | ||||||
dims: xarray.ALL_DIMS, hashable or sequence of hashables, optional | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Along which dimensions to be summed over. Default all the common | ||||||
dimensions are summed over. | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.