home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

9 rows where issue = 184238633 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 4

  • shoyer 4
  • dhimmel 3
  • Hoeze 1
  • max-sixty 1

author_association 2

  • MEMBER 5
  • NONE 4

issue 1

  • Support __matmul__ operator (@) · 9 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
505992633 https://github.com/pydata/xarray/issues/1053#issuecomment-505992633 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDUwNTk5MjYzMw== max-sixty 5635139 2019-06-26T18:28:31Z 2019-06-26T18:28:31Z MEMBER

Closed by #2987

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
405645739 https://github.com/pydata/xarray/issues/1053#issuecomment-405645739 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDQwNTY0NTczOQ== shoyer 1217238 2018-07-17T16:32:45Z 2018-07-17T16:32:45Z MEMBER

Yes, we could definitely make @ between two xarray objects equivalent to xarray.dot().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
405635314 https://github.com/pydata/xarray/issues/1053#issuecomment-405635314 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDQwNTYzNTMxNA== Hoeze 1200058 2018-07-17T16:00:44Z 2018-07-17T16:04:32Z NONE

How about just keeping the current behavior? Currently a @ b just returns a new numpy array if either a or b is no xr.DataArray. This makes perfectly sense to me.

If both arrays are xr.DataArrays, I get an error which was rather unexpected. Here, xarray could simply stick to xr.DataArray.dot().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
290954513 https://github.com/pydata/xarray/issues/1053#issuecomment-290954513 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDI5MDk1NDUxMw== shoyer 1217238 2017-04-01T23:40:06Z 2017-04-01T23:40:06Z MEMBER

My intuition was that we use @ on a DataArray in cases where DataArray.values @ numpy.ndarray or numpy.ndarray @ DataArray.values would work.

Suppose data_array is a DataArray with dimensions ['x', 'y'] and numpy_array is a numpy.ndarray with a compatible shape. What should data_array @ numpy_array look like? The first dimension should be labeled x, but the second dimension doesn't have a name, so we'd need to come up with one somehow (every dimension in an DataArray must have a name).

However, it appears that xarray may do some inference based aligning dimensions/coordinates... and that I need to understand this process a bit more.

Indeed, see http://xarray.pydata.org/en/stable/computation.html#broadcasting-by-dimension-name

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
290951551 https://github.com/pydata/xarray/issues/1053#issuecomment-290951551 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDI5MDk1MTU1MQ== dhimmel 1117703 2017-04-01T22:34:12Z 2017-04-01T23:29:31Z NONE

First let me say, I know python, but I don't know linear algebra (I rely on @kkloste for algebra). I'm also new to xarray and recently used it for the first time to represent a hetnet (network with multiple node and relationship types) as a xarray.DataSet where each DataArray is an adjacency matrix (0 or 1 for whether an edge exists) for a specific edge type. I was drawn to xarray because it allows us to:

  1. assign row/column labels (representing node identity) to 2D arrays (adjacency matrixes in our case)
  2. reason across multiple adjacency matrixes by assigning dimension identities (node types)

The operations that we're using for our project are dot-product multiplying 2D arrays by 2D arrays and 1D arrays by 2D arrays. Currently, our arrays are numpy.ndarrays, but we may switch some of our 2D arrays to scipy.sparse matrices.

I'm intrigued, but how would this work? data_array + numpy_array yields a result with well-defined labels as long as numpy_array broadcasts against data_array.data, but data_array @ numpy_array does not if numpy_array has 2 or more dimensions.

My intuition was that we use @ on a DataArray in cases where DataArray.values @ numpy.ndarray or numpy.ndarray @ DataArray.values would work. In these situations, the user would be responsible for ensuring numpy.ndarray had the correct coordinates and dimensions. We're also interested in DataArray.values @ scipy.sparse.

However, it appears that xarray may do some inference based aligning dimensions/coordinates... and that I need to understand this process a bit more. Sorry if this reply doesn't help you move forward with this issue. I hopefully will be able to be more helpful as I become more familiar with xarray.

It also gets messy on Dataset objects

For clarity, I wasn't thinking of using @ on Datasets.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
290948916 https://github.com/pydata/xarray/issues/1053#issuecomment-290948916 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDI5MDk0ODkxNg== shoyer 1217238 2017-04-01T21:40:04Z 2017-04-01T21:40:04Z MEMBER

More specifically, I'd like to be able to do matrix multiplication between numpy ndarrays / matrices, scipy sparse matrices, and xarray DataArrays.

I'm intrigued, but how would this work? data_array + numpy_array yields a result with well-defined labels as long as numpy_array broadcasts against data_array.data, but data_array @ numpy_array does not if numpy_array has 2 or more dimensions.

I guess we could prohibit @ with non-vector other arguments, but I still am concerned that the suggested meaning of @ per PEP 465 and numpy depends on the order of array dimensions. Basically, the last dimension of the left-hand-side argument should be matched against the second-to-last (or last, for 1D) dimension of the right-hand-side for the tensor contraction. In xarray terms, we could match the last dimension of the left-hand-side with any matching dimensions (by name) of the right-hand-side, but it's still messily inconsistent with other xarray operations, which are generally agnostic to to dimension order.

It also gets messy on Dataset objects, because the order of dimensions now becomes a bit more ambiguous: there's the order of dimensions on the Dataset itself, and the order on each DataArray in the dataset.

For these reasons, I'm leaning towards thinking that @ should be defined differently for xarray, and work like tensordot over all matching dimensions.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
290940281 https://github.com/pydata/xarray/issues/1053#issuecomment-290940281 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDI5MDk0MDI4MQ== dhimmel 1117703 2017-04-01T19:01:57Z 2017-04-01T19:01:57Z NONE

More specifically, I'd like to be able to do matrix multiplication between numpy ndarrays / matrices, scipy sparse matrices, and xarray DataArrays. @ seems like the most natural operator to enable this cross-package compatibility.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
290939565 https://github.com/pydata/xarray/issues/1053#issuecomment-290939565 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDI5MDkzOTU2NQ== dhimmel 1117703 2017-04-01T18:49:50Z 2017-04-01T18:49:50Z NONE

Would love support for PEP 465 @ notation.

Recently, @ came in handy when multiplying numpy.ndarray with scipy.sparse matrices. We're considering xarray for our project and compatibility with this unified operator would be a real plus!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633
255126864 https://github.com/pydata/xarray/issues/1053#issuecomment-255126864 https://api.github.com/repos/pydata/xarray/issues/1053 MDEyOklzc3VlQ29tbWVudDI1NTEyNjg2NA== shoyer 1217238 2016-10-20T14:44:58Z 2016-10-20T14:44:58Z MEMBER

For xarray, probably the right choice is for @ to be an alias for .dot(): http://xarray.pydata.org/en/stable/generated/xarray.DataArray.dot.html

The broadcasting semantics of np.matmul don't quite make sense because it broadcasts based on axis position, not name.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Support __matmul__ operator (@) 184238633

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