home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 290948916

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/1053#issuecomment-290948916 https://api.github.com/repos/pydata/xarray/issues/1053 290948916 MDEyOklzc3VlQ29tbWVudDI5MDk0ODkxNg== 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
}
  184238633
Powered by Datasette · Queries took 233.095ms · About: xarray-datasette