home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 483802699

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/525#issuecomment-483802699 https://api.github.com/repos/pydata/xarray/issues/525 483802699 MDEyOklzc3VlQ29tbWVudDQ4MzgwMjY5OQ== 1217238 2019-04-16T19:02:37Z 2019-04-16T19:02:37Z MEMBER

Your first example dispatches to dask.array.__mul__, which doesn't know anything about pint and doesn't know how to compose its operations because there are no hooks--the pint array just gets coerced to a numpy array. The second goes to pint.Quantity.__mul__, which assumes it can wrap the dask.array (because it duck typing) and seems to succeed in doing so.

Unfortunately I don't think either dask or pint handle this properly right now.

There is a protocol for Python's * operator, which involves calling __mul__ and __rmul__ methods. But if both dask and pint always returns the result instead of NotImplemented, it is impossible to ensure a consistent result for a * b and b * a if a and b are different types. (This exact same issue exists for __array_function__, too, because the dispatching protocol is copied from Python.)

Dask and pint need some system -- either opt-in or opt-out -- for recognizing that they cannot handle operations with some argument types.

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