home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 630387515

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/3883#issuecomment-630387515 https://api.github.com/repos/pydata/xarray/issues/3883 630387515 MDEyOklzc3VlQ29tbWVudDYzMDM4NzUxNQ== 10194086 2020-05-18T19:21:55Z 2020-10-27T14:27:50Z MEMBER

```python %load_ext line_profiler

import numpy as np import xarray as xr

from xarray.core.weighted import Weighted as w

shape_weights = (1000, 1000) shape_data = (1000, 1000, 10) add_nans = False

def lprun_weighted(shape_weights, shape_data, add_nans, skipna=None):

weights = xr.DataArray(np.random.randn(*shape_weights))

data = np.random.randn(*shape_data)

# add approximately 25 % NaNs
if add_nans:
    c = int(data.size * 0.25)
    data.ravel()[np.random.choice(data.size, c, replace=False)] = np.NaN

data = xr.DataArray(data)


return data.weighted(weights).mean(skipna=skipna)

%lprun -f w._reduce -f w._weighted_mean -f w._sum_of_weights -f w._weighted_sum -f w.init -f lprun_weighted -u 1e-03 lprun_weighted(shape_weights, shape_data, add_nans, skipna=None)

```

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