home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1078656323

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
1078656323 I_kwDOAMm_X85ASv1D 6075 Broadcasting doesn't respect scalar coordinates 4502 open 0     1 2021-12-13T15:18:22Z 2021-12-13T22:10:14Z   NONE      

Usually if I apply a broadcasting operation to two arrays, the result only includes values for coordinates present in both. A simple example:

python In [160]: data_array = xarray.DataArray(dims=("x",), data=[1,2,3], coords={"x": [1,2,3]}) In [161]: data_array.sel(x=[2]) * data_array Out[161]: <xarray.DataArray (x: 1)> array([4]) Coordinates: * x (x) int64 2 However if I do the same thing but select a scalar value for the x coordinate (.sel(x=1)) yielding a scalar coordinate for x:

python In [164]: data_array.sel(x=2) Out[164]: <xarray.DataArray ()> array(2) Coordinates: x int64 2 In [165]: data_array.sel(x=2) * data_array Out[165]: <xarray.DataArray (x: 3)> array([2, 4, 6]) Coordinates: * x (x) int64 1 2 3

Here the result includes values at all the coordinates [1,2,3], all of which have been broadcast against the scalar value taken at coordinate 2. This doesn't seem correct in general -- values from different coordinates shouldn't be broadcast against eachother by default, even if one of them is a scalar.

I would expect this either to result in an error or warning, or to select only the corresponding value at the scalar coordinate in question to broadcast against, resulting in e.g.:

python <xarray.DataArray ()> array(4) Coordinates: x int64 2

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6075/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

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