home / github

Menu
  • GraphQL API
  • Search all tables

issues

Table actions
  • GraphQL API for issues

2 rows where user = 6431831 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date), closed_at (date)

type 2

  • issue 1
  • pull 1

state 1

  • closed 2

repo 1

  • xarray 2
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
1085394378 PR_kwDOAMm_X84wHDwj 6089 Fix dataarray determination in map_blocks tcchiao 6431831 closed 0     5 2021-12-21T03:18:15Z 2021-12-29T16:54:18Z 2021-12-29T16:54:17Z CONTRIBUTOR   0 pydata/xarray/pulls/6089
  • [x] Closes #6052
  • [x] Tests added
  • [x] Passes pre-commit run --all-files
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6089/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 pull
1073635991 I_kwDOAMm_X84__mKX 6052 map_blocks not converting dataarrays correctly tcchiao 6431831 closed 0     2 2021-12-07T18:17:21Z 2021-12-29T16:54:17Z 2021-12-29T16:54:17Z CONTRIBUTOR      

What happened: When using map_blocks with a function which has non-xarray arguments before arguments that are xarray dataarray (e.g. arg1 is a xarray object, arg2 is not xarray, and arg3 is a xarray dataarray), the code fails to convert the dataarray argument to dataset and triggers downstream failure. The downstream failure occurs because ds.chunks returns a dict, whereas da.chunks returns a tuple.

What you expected to happen: The code intends to convert dataarrays to datasets before calling .chunks, and I expect it to do so.

Minimal Complete Verifiable Example:

``` import xarray as xr import pandas as pd import numpy as np import string

def random_point_data(n_points=1, n_times=100): size = (n_times, n_points) dims = ('time', 'point') times = pd.date_range('1979-01-01', freq='1D', periods=n_times) da = xr.DataArray(np.random.random(size=size), dims=(dims), coords={'time': times}) return da

def mock_function(da1, non_xarray_input, da2): return da1

X = random_point_data(n_points=3).chunk({'point': 1}) out = xr.map_blocks(mock_function, X, args=['random_string', X]) ```

gives an error of

```

ValueError Traceback (most recent call last) <ipython-input-65-dea560baad18> in <module> 14 15 X = random_point_data(n_points=3).chunk({'point': 1}) ---> 16 out = xr.map_blocks(mock_function, X, args=['random_string', X])

/srv/conda/envs/notebook/lib/python3.8/site-packages/xarray/core/parallel.py in map_blocks(func, obj, args, kwargs, template) 363 for arg in xarray_objs[1:]: 364 assert_chunks_compatible(npargs[0], arg) --> 365 input_chunks.update(arg.chunks) 366 input_indexes.update(arg.indexes) 367

ValueError: dictionary update sequence element #0 has length 1; 2 is required ```

Anything else we need to know?: This should be fixed with a one line change here

from xarray_objs = tuple( dataarray_to_dataset(arg) if is_da else arg for is_da, arg in zip(is_array, aligned) ) to xarray_objs = tuple( dataarray_to_dataset(arg) if isinstance(arg, xr.DataArray) else arg for arg in aligned )

This is because is_array is determined on all args regardless of whether the arg is a xarray object, and aligned has already been filtered down to xarray objects only.

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 23:21:18) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 4.14.177-139.253.amzn2.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: C.UTF-8 LANG: C.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.16.2 pandas: 1.2.1 numpy: 1.20.0 scipy: 1.6.0 netCDF4: 1.5.5.1 pydap: installed h5netcdf: 0.8.1 h5py: 3.1.0 Nio: None zarr: 2.10.3 cftime: 1.4.1 nc_time_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.2.0 cfgrib: 0.9.8.5 iris: None bottleneck: 1.3.2 dask: 2021.01.1 distributed: 2021.01.1 matplotlib: 3.3.4 cartopy: 0.18.0 seaborn: None numbagg: None pint: 0.16.1 setuptools: 49.6.0.post20210108 pip: 20.3.4 conda: None pytest: 6.2.5 IPython: 7.20.0 sphinx: 3.4.3
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6052/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 21.358ms · About: xarray-datasette