home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

6 rows where author_association = "MEMBER" and issue = 403378297 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

  • shoyer 6

issue 1

  • Extra dimension on first argument passed into apply_ufunc · 6 ✖

author_association 1

  • MEMBER · 6 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
457799714 https://github.com/pydata/xarray/issues/2714#issuecomment-457799714 https://api.github.com/repos/pydata/xarray/issues/2714 MDEyOklzc3VlQ29tbWVudDQ1Nzc5OTcxNA== shoyer 1217238 2019-01-26T04:05:58Z 2019-01-26T04:07:24Z MEMBER

I think this would also work (due to the intrinsic broadcasting behavior of numpy functions): python def get_chebyshev_distances_xarray_ufunc(array, dye_array): return abs(array - dye_array).max(axis=-2)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Extra dimension on first argument passed into apply_ufunc 403378297
457799469 https://github.com/pydata/xarray/issues/2714#issuecomment-457799469 https://api.github.com/repos/pydata/xarray/issues/2714 MDEyOklzc3VlQ29tbWVudDQ1Nzc5OTQ2OQ== shoyer 1217238 2019-01-26T04:02:09Z 2019-01-26T04:07:00Z MEMBER

OK, I think you're doing this right. You want an output with shape ['all_sites', 'dye_sites'] right?

My suggestion would be to add an explicit call to np.broadcast_arrays() at the start of your applied function. This will make the dimensions a little easier to understand. ```python def get_chebyshev_distances_xarray_ufunc(array, dye_array): array, dye_array = np.broadcast_arrays(array, dye_array) # array is a 3D numpy array with logical dimensions ['all_sites', 'dye_sites', 'dim_1'] # dye_array is a 3D numpy array with logical dimensions ['all_sites', 'dye_sites', 'dim_1']

# compute the distance matrix
# return a numpy array with logical dimensions ['all_sites', 'dye_sites']

``` (edit note: fixed dimensions)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Extra dimension on first argument passed into apply_ufunc 403378297
457799701 https://github.com/pydata/xarray/issues/2714#issuecomment-457799701 https://api.github.com/repos/pydata/xarray/issues/2714 MDEyOklzc3VlQ29tbWVudDQ1Nzc5OTcwMQ== shoyer 1217238 2019-01-26T04:05:43Z 2019-01-26T04:05:43Z MEMBER

actually, scratch that

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Extra dimension on first argument passed into apply_ufunc 403378297
457794714 https://github.com/pydata/xarray/issues/2714#issuecomment-457794714 https://api.github.com/repos/pydata/xarray/issues/2714 MDEyOklzc3VlQ29tbWVudDQ1Nzc5NDcxNA== shoyer 1217238 2019-01-26T02:48:01Z 2019-01-26T03:40:29Z MEMBER

The notion of "core dimensions" in apply_ufunc() is definitely quite tricky to understand.

That said, I think this is (mostly) doing the right thing: - Your inputs have dimensions ['row_a', 'dim_1'] and ['row_b', 'dim_1'] - Xarray broadcasts over dimensions that aren't included in "core dimensions" , so inputs are broadcast to have dimensions like ['row_a', 'row_b', 'dim_1'] and ['row_a', 'row_b', 'dim_1'].

This is probably especially confusing because the unlabeled versions of da and db are given "broadcastable" shapes (1000, 1, 100) and (1000, 100) rather than the fully "broadcast" shapes of (1000, 1000, 100) and (1000, 1000, 100), which would make it more obvious what is going on.

For your specific use case: maybe you meant to specify input_core_dims=[['row_a'], ['row_b']] instead? That version would give inputs with dimensions like ['dim_1', 'row_a'] and ['dim_1', 'row_b'].

More generally: I think we really need a version of apply() that doesn't do this confusing broadcasting and dimension reordering. See https://github.com/pydata/xarray/issues/1130 for discussion about that.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Extra dimension on first argument passed into apply_ufunc 403378297
457798131 https://github.com/pydata/xarray/issues/2714#issuecomment-457798131 https://api.github.com/repos/pydata/xarray/issues/2714 MDEyOklzc3VlQ29tbWVudDQ1Nzc5ODEzMQ== shoyer 1217238 2019-01-26T03:40:14Z 2019-01-26T03:40:14Z MEMBER

unlabeled versions of da and db are given "broadcastable" shapes (1, 1000, 100) and (1000, 100)

Is it (1000, 1, 100) as my code seems to return, or, as you said (1, 1000, 100)? Is it deterministic?

That was a typo (I'll fix it). It should be (1000, 1, 100).

The behavior is definitely deterministic, if hard to understand!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Extra dimension on first argument passed into apply_ufunc 403378297
457798018 https://github.com/pydata/xarray/issues/2714#issuecomment-457798018 https://api.github.com/repos/pydata/xarray/issues/2714 MDEyOklzc3VlQ29tbWVudDQ1Nzc5ODAxOA== shoyer 1217238 2019-01-26T03:38:20Z 2019-01-26T03:38:20Z MEMBER

Maybe it would help to describe what you were trying to do here. What should "one unit" of your calculation look like?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Extra dimension on first argument passed into apply_ufunc 403378297

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 12.674ms · About: xarray-datasette