home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where issue = 457716471 and user = 5635139 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

user 1

  • max-sixty · 5 ✖

issue 1

  • apply_ufunc should preemptively broadcast · 5 ✖

author_association 1

  • MEMBER 5
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
503747413 https://github.com/pydata/xarray/issues/3032#issuecomment-503747413 https://api.github.com/repos/pydata/xarray/issues/3032 MDEyOklzc3VlQ29tbWVudDUwMzc0NzQxMw== max-sixty 5635139 2019-06-19T21:09:18Z 2019-06-19T21:09:18Z MEMBER

@shoyer thanks for the clarity

@OriolAbril would you mind if we changed this issue to "apply_ufunc should preemptively broadcast"

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  apply_ufunc should preemptively broadcast 457716471
503652824 https://github.com/pydata/xarray/issues/3032#issuecomment-503652824 https://api.github.com/repos/pydata/xarray/issues/3032 MDEyOklzc3VlQ29tbWVudDUwMzY1MjgyNA== max-sixty 5635139 2019-06-19T17:21:34Z 2019-06-19T17:21:34Z MEMBER

I'm trying to think whether there would be any performance cost there - i.e. are there any arrays where preemptive broadcasting would be both expensive and unnecessary?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  apply_ufunc should preemptively broadcast 457716471
503625092 https://github.com/pydata/xarray/issues/3032#issuecomment-503625092 https://api.github.com/repos/pydata/xarray/issues/3032 MDEyOklzc3VlQ29tbWVudDUwMzYyNTA5Mg== max-sixty 5635139 2019-06-19T16:04:58Z 2019-06-19T16:04:58Z MEMBER

We should probably make apply_ufunc() explicitly broadcast arrays first.

To confirm, so that we have something like this?

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

Out

(7, 3, 5, 6)

(7, 3, 5, 6)

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  apply_ufunc should preemptively broadcast 457716471
503337637 https://github.com/pydata/xarray/issues/3032#issuecomment-503337637 https://api.github.com/repos/pydata/xarray/issues/3032 MDEyOklzc3VlQ29tbWVudDUwMzMzNzYzNw== max-sixty 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
}
  apply_ufunc should preemptively broadcast 457716471
503334445 https://github.com/pydata/xarray/issues/3032#issuecomment-503334445 https://api.github.com/repos/pydata/xarray/issues/3032 MDEyOklzc3VlQ29tbWVudDUwMzMzNDQ0NQ== max-sixty 5635139 2019-06-18T22:24:16Z 2019-06-18T22:24:16Z MEMBER

Thanks for the issue & code sample @OriolAbril

IIUC, func needs to do this broadcasting itself; from the apply_ufunc docstring:

func : callable Function to call like ``func(*args, **kwargs)`` on unlabeled arrays (``.data``) that returns an array or tuple of arrays. If multiple arguments with non-matching dimensions are supplied, this function is expected to vectorize (broadcast) over axes of positional arguments in the style of NumPy universal functions [1]_ (if this is not the case, set ``vectorize=True``). If this function returns multiple outputs, you must set ``output_core_dims`` as well.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  apply_ufunc should preemptively broadcast 457716471

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 125.146ms · About: xarray-datasette