home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 503337637

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/3032#issuecomment-503337637 https://api.github.com/repos/pydata/xarray/issues/3032 503337637 MDEyOklzc3VlQ29tbWVudDUwMzMzNzYzNw== 5635139 2019-06-18T22:37:42Z 2019-06-18T22:42:14Z MEMBER

Because func receives unlabelled arrays, apply_ufunc aligns the axes order. So if they share a dimension:

```python In [8]: import xarray as xr ...: import numpy as np ...: ...: a = xr.DataArray(data=np.random.normal(size=(7, 3)), dims=["dim1", "dim2"]) ...: c = xr.DataArray(data=np.random.normal(size=(7, 6)), dims=["dim1", "dim4"]) # <- change here ...: ...: def func(x,y): ...: print(x.shape) ...: print(y.shape) ...: return x ...:

In [9]: xr.apply_ufunc(func, a, c) (7, 3, 1) (7, 1, 6) ```

...otherwise func wouldn't know how to align.

Another option would be for your original example to put lengths of 1 in all axes, rather than only 'forward filling', e.g.

``` xr.apply_ufunc(func, a, c)

Out

(7, 3, 1, 1)

(1, 1, 5, 6) # <- change here

```

I think it operates without that step because functions 'in the wild' generally will handle that themselves, but that's a guess and needs someone who knows this better to weight in

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  457716471
Powered by Datasette · Queries took 0.559ms · About: xarray-datasette