home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1609090149

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1609090149 I_kwDOAMm_X85f6MRl 7584 `np.multiply` and `dask.array.multiply` trigger graph computation vs using `+` and `*` operators. 44142765 closed 0     3 2023-03-03T18:37:06Z 2023-11-06T08:45:55Z 2023-11-06T08:45:54Z NONE      

What is your issue?

I was trying to implement a simple weighted average function using a few xr.DataArray objects via python def weighted_avg(args, weights): return np.multiply(args, weights).sum() / sum(weights)

To my surprise a call to to this function causes the graph to be computed as I had to wait for quite a bit given the size of the DataArray's. I realised that the graph was being computed. Even replacing np.multiply with dask.array.multiply did not make a difference. So I decided to implement the function using built-in operators like

python def weighted_avg(args, weights): import operator as op return sum(map(op.mul, args, weights)) / sum(weights) and to my surprise this implementation returns immediately suggesting that the graph computation is delayed. Is this expected behaviour? I thought numpy/dask array functions lazily evaluate so this seems odd to me.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7584/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.647ms · About: xarray-datasette