home / github

Menu
  • Search all tables
  • GraphQL API

issues

Table actions
  • GraphQL API for issues

2 rows where user = 8238804 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)

state 2

  • closed 1
  • open 1

type 1

  • issue 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
557257598 MDU6SXNzdWU1NTcyNTc1OTg= 3731 Repeated coordinates leads to unintuitive (broken?) indexing behaviour ivirshup 8238804 open 0     13 2020-01-30T04:21:57Z 2023-11-30T08:58:22Z   NONE      

MCVE Code Sample

```python import xarray as xr import numpy as np

sample_idx = xr.IndexVariable("sample_id", ["a", "b", "c"]) da = xr.DataArray(np.eye(3), coords=(sample_idx, sample_idx))

da.shape

(3, 3)

da[1, :].shape

(3, 3)

da.loc["a", :].shape

(3, 3)

da.loc[:, "a"].shape

()

da[:, 0].shape

()

da[:, 1]

<xarray.DataArray ()>

array(1.)

Coordinates:

sample_id <U1 'b'

```

Expected Output

I had expected:

```python da.shape

(3, 3)

da[1, :].shape

(3)

da.loc["a", :].shape

(3)

da.loc[:, "a"].shape

(3)

da[:, 1]

<xarray.DataArray (sample_id: 3)>

array([0., 1., 0.])

Coordinates:

sample_id <U1 'a' 'b' 'c'

```

Problem Description

When coordinates are shared between dimensions (as would happen if a pairwise measurement is taken) indexing behaves strangely. It looks like indexing into the initial indices doesn't do anything, while indexing into the last index applies the selection across all dimensions.

```python da3d = xr.DataArray( np.arange(27).reshape((3,3,3)), coords=(sample_idx, sample_idx, sample_idx) )

print(da3d.loc["a"].shape) print(da3d.loc["a", "a"].shape) print(da3d.loc[:, :, "a"].shape)

(3, 3, 3)

(3, 3, 3)

()

```

Output of xr.show_versions()

# Paste the output here xr.show_versions() here ``` INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 (default, Jan 4 2020, 12:18:30) [Clang 11.0.0 (clang-1100.0.33.16)] python-bits: 64 OS: Darwin OS-release: 19.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.3 xarray: 0.14.1+5.gb0064b25 pandas: 0.25.3 numpy: 1.18.1 scipy: 1.4.1 netCDF4: 1.5.2 pydap: None h5netcdf: 0.7.4 h5py: 2.9.0 Nio: None zarr: 2.4.0 cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.9.2 distributed: 2.9.3 matplotlib: 3.0.3 cartopy: None seaborn: 0.10.0 numbagg: None setuptools: 44.0.0 pip: 20.0.2 conda: None pytest: 5.3.4 IPython: 7.11.1 sphinx: 2.3.1 ```

Update, adding link to related issue:

  • https://github.com/pydata/xarray/issues/1378
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3731/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 issue
564555854 MDU6SXNzdWU1NjQ1NTU4NTQ= 3768 Pointwise indexing ivirshup 8238804 closed 0     6 2020-02-13T09:39:27Z 2021-02-16T23:37:29Z 2021-02-16T23:37:29Z NONE      

MCVE Code Sample

```python import xarray as xr import numpy as np

da = xr.DataArray( np.arange(56).reshape((7, 8)), coords={ 'x': list('abcdefg'), 'y': 10 * np.arange(8) }, dims=['x', 'y'] )

Shouldn't this be (2,)?

assert da.isel(x=[0, 1], y=[0, 1]).shape == (2, 2) ```

Expected Output

I had expected da.isel(x=[0, 1], y=[0, 1]) to have shape (2,). I had generally expected indexing with isel to behave more like numpy indexing. It's very possible I'm just missing something, or that this is more of a documentation issue more than a behavior issue.

Problem Description

Going off this example in #507:

python In [3]: da.isel_points(x=[0, 1, 6], y=[0, 1, 0], dim='points') Out[3]: <xray.DataArray (points: 3)> array([ 0, 9, 48]) Coordinates: y (points) int64 0 10 0 x (points) |S1 'a' 'b' 'g' * points (points) int64 0 1 2

and the deprecation of isel_points with isel, I had expected to get numpy-like coordinate indexing using isel.

This was made a little bit more confusing by the documentation for setting values by index. In particular the example:

```python In [68]: da[ind_x, ind_y] = -2 # assign -2 to (ix, iy) = (0, 0) and (1, 1)

In [69]: da Out[69]: <xarray.DataArray (x: 3, y: 4)> array([[-2, -2, -1, -1], [-2, -2, 6, 7], [ 8, 9, 10, 11]]) ```

To me, the comment # assign -2 to (ix, iy) = (0, 0) and (1, 1) makes it sound like values will be assigned at the coordinates (0, 0) and (1, 1), not (0, 0), (0, 1), (1, 0), and (1, 1).

All in all, I'm not sure if this is a bug, or an issue with documentation. If isel is not meant to behave like isel_points, it would be nice to see that in the documentation. If it is possible to get and set points by coordinate (without looping over single coordinates) it would be nice to see an example in the documentation where that's shown.

Output of xr.show_versions()

# Paste the output here xr.show_versions() here INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 (default, Jan 4 2020, 12:18:30) [Clang 11.0.0 (clang-1100.0.33.16)] python-bits: 64 OS: Darwin OS-release: 19.3.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.3 xarray: 0.15.0 pandas: 1.0.1 numpy: 1.18.1 scipy: 1.4.1 netCDF4: 1.5.2 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: 2.4.0 cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.9.2 distributed: 2.9.3 matplotlib: 3.1.3 cartopy: None seaborn: 0.10.0 numbagg: None setuptools: 45.2.0 pip: 20.0.2 conda: None pytest: 5.3.4 IPython: 7.11.1 sphinx: 2.3.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3768/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 23.309ms · About: xarray-datasette