home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 778341660

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/4898#issuecomment-778341660 https://api.github.com/repos/pydata/xarray/issues/4898 778341660 MDEyOklzc3VlQ29tbWVudDc3ODM0MTY2MA== 367900 2021-02-12T17:44:55Z 2021-02-12T17:55:48Z CONTRIBUTOR

@dcherian it looks like that works. A better test script:

```python import numpy as np import xarray as xr from xarray.tests import raise_if_dask_computes

def worker(da): if da.shape == (0, 0): return da

return da.where(da > 1)

np.random.seed(1023) da = xr.DataArray( np.random.normal(size=(20, 500)), dims=("x", "y"), coords=(np.arange(20), np.arange(500)), )

da = da.chunk(dict(x=5)) lazy = da.map_blocks(worker)

with raise_if_dask_computes(): result = lazy.sum("x", skipna=True, min_count=5)

result.load()

assert np.isnan(result[0]) assert not np.isnan(result[6]) ```

If I then remove the if null_mask.any() check and the following block, and replace it with

python dtype, fill_value = dtypes.maybe_promote(result.dtype) result = result.astype(dtype) result = np.where(null_mask, fill_value, result) it passes. I can start working on a pull request with these tests and changes if that looks acceptable to you.

~~How would you suggest handling the possible type promotion from the current dtype, fill_value = dtypes.maybe_promote(result.dtype) line? Currently it only tries promoting if the mask is True anywhere. Always promote, or just use the fill value and hope it works out?~~

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