home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 509851476

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
509851476 MDU6SXNzdWU1MDk4NTE0NzY= 3423 add `ALL_DIMS` in `xr.dot` 10194086 closed 0     0 2019-10-21T09:45:24Z 2019-10-29T19:12:51Z 2019-10-29T19:12:51Z MEMBER      

MCVE Code Sample

```python import numpy as np 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'])

xr.dot(da_a, da_b, dims=None)

This sums over the common dimensions:python <xarray.DataArray (c: 2)> array([110, 125]) Dimensions without coordinates: c ```

To sum over all dimensions: ```python xr.dot(da_a, da_b, dims=['a', 'b', 'c'])

python <xarray.DataArray (c: 2)> array([110, 125]) Dimensions without coordinates: c ```

Problem Description

xr.dot with dims=None currently sums over all the common dimensions. However, there are cases when a sum over all dimensions is desired. E.g. xr.dot(da_a, da_b, dims=['a', 'b', 'c']) is a a memory efficient way to compute (da_a * da_b).sum() (if a and b don't share the same dimensions). This is currently used in #2922 (example).

Therefore I suggest to allow xr.dot(da_a, da_b, dims=xr.ALL_DIMS) as shortcut to sum over all dimensions.

I assume there is no intent to change the behavior of xr.dot(..., dims=None)? (As it is a bit in contrast to other functions that are mostly applied over all dimensions.)

@fujiisoup @max-sixty

Output of xr.show_versions()

# Paste the output here xr.show_versions() here
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3423/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.538ms · About: xarray-datasette