home / github

Menu
  • GraphQL API
  • Search all tables

issues

Table actions
  • GraphQL API for issues

2 rows where assignee = 4160723 and state = "open" sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

type 1

  • issue 2

state 1

  • open · 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
1319724885 I_kwDOAMm_X85OqWdV 6838 sel by slice not working for multi-index containing float-values nunupeke 57088171 open 0 benbovy 4160723   3 2022-07-27T15:22:07Z 2022-09-27T10:37:44Z   NONE      

What happened?

python da = xr.DataArray(np.random.rand(4), {'x': np.arange(4)}) da = da.assign_coords(y=('x', np.linspace(0, 1, 4))) da = da.assign_coords(z=('x', np.arange(4) + 4)) da.set_index(x=["y", "z"]).sel(y=slice(None, 0.5)) fails with TypeError: float() argument must be a string or a real number, not 'slice'

What did you expect to happen?

In v2022.3, this yields the correct sliced selection. Also, in v2022.6 this works for Multiindices without float-Values python da = xr.DataArray(np.random.rand(4), {'x': np.arange(4)}) da = da.assign_coords(y=('x', np.arange(4))) da = da.assign_coords(z=('x', np.arange(4) + 4)) da.set_index(x=["y", "z"]).sel(y=slice(None, 2), z=slice(5, None)) (only that the resulting coordinates look a bit weird, containing slices). Also, the sliced selection for a regular float-based index works in v2202.6 python da = xr.DataArray(np.random.rand(4), {'x': np.linspace(0, 1, 4)}) da.sel(x=slice(None, 0.5))

Minimal Complete Verifiable Example

```Python import numpy as np import xarray as xr

da = xr.DataArray(np.random.rand(4), {'x': np.arange(4)}) da = da.assign_coords(y=('x', np.linspace(0, 1, 4))) da = da.assign_coords(z=('x', np.arange(4) + 4)) da.set_index(x=["y", "z"]).sel(y=slice(None, 0.5)) ```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [X] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

```Python File c:\mambaforge\envs\dev\lib\site-packages\xarray\core\dataarray.py:1420, in DataArray.sel(self, indexers, method, tolerance, drop, indexers_kwargs) 1310 def sel( 1311 self: T_DataArray, 1312 indexers: Mapping[Any, Any] = None, (...) 1316 indexers_kwargs: Any, 1317 ) -> T_DataArray: 1318 """Return a new DataArray whose data is given by selecting index 1319 labels along the specified dimension(s). 1320 (...) 1418 Dimensions without coordinates: points 1419 """ -> 1420 ds = self._to_temp_dataset().sel( 1421 indexers=indexers, 1422 drop=drop, 1423 method=method, 1424 tolerance=tolerance, ... 197 # see https://github.com/pydata/xarray/issues/5727 --> 198 value = np.asarray(value, dtype=dtype) 199 return value

TypeError: float() argument must be a string or a real number, not 'slice' ```

Anything else we need to know?

Maybe related to #6836

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 06:57:19) [MSC v.1929 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder: little LC_ALL: None LANG: de_DE.UTF-8 LOCALE: ('de_DE', 'cp1252') libhdf5: None libnetcdf: None xarray: 2022.6.0 pandas: 1.4.3 numpy: 1.23.1 scipy: 1.8.1 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.5.2 cartopy: None seaborn: 0.11.2 numbagg: None fsspec: None cupy: None pint: 0.19.2 sparse: None flox: None numpy_groupies: None setuptools: 63.2.0 pip: 22.2 conda: None pytest: 7.1.2 IPython: 8.4.0 sphinx: 4.5.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6838/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 issue
1318826485 I_kwDOAMm_X85Om7H1 6835 Using a tuple as a sequence in DataArray.sel no longer supported? momchil-flex 92756559 open 0 benbovy 4160723   2 2022-07-26T22:51:19Z 2022-08-31T16:22:30Z   NONE      

What happened?

Version 2022.6.0 produces an error when I try something like data_array.sel(coordintate=(val1, val2)). Now this only works if the sequence values are provided as a list instead.

What did you expect to happen?

In previous versions, tuples could also be supplied. However, I've been digging into this a bit, and I understand that there are generally some limitations on using tuples (or rather, they are sometimes overloaded). For example, it seems that in any version, I can't use a tuple as an input coordinate to initialize a DataArray, as I get an error Could not convert tuple of form (dims, data[, attrs, encoding]) (this is known). I wanted to report the current bug however since the behavior is different in 2022.6.0 compared to previous versions, and to clarify whether not supporting tuples as sel coordinates is expected or not. It is not very clear from the error message and from the docs. The example below works on < 2022.6.0 but raises an error on 2022.6.0.

Minimal Complete Verifiable Example

Python import xarray as xr import numpy as np arr = xr.DataArray(data=np.random.rand(10), coords={"c1": np.arange(10, dtype=np.float64)}) item = arr.sel(c1=(1, 2))

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [X] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

No response

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.9.12 (main, Jun 1 2022, 11:38:51) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 5.13.0-52-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.2 libnetcdf: None xarray: 2022.6.0 pandas: 1.4.3 numpy: 1.23.0 scipy: 1.8.1 netCDF4: None pydap: None h5netcdf: None h5py: 3.7.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2022.6.1 distributed: None matplotlib: 3.5.2 cartopy: None seaborn: None numbagg: None fsspec: 2022.5.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 61.2.0 pip: 21.2.4 conda: None pytest: 7.1.2 IPython: 8.4.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6835/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    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 263.319ms · About: xarray-datasette