home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where issue = 280875330 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 5

  • cvr 1
  • shoyer 1
  • fujiisoup 1
  • stale[bot] 1
  • lanougue 1

author_association 2

  • NONE 3
  • MEMBER 2

issue 1

  • nonzero method for xr.DataArray · 5 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1085742545 https://github.com/pydata/xarray/issues/1772#issuecomment-1085742545 https://api.github.com/repos/pydata/xarray/issues/1772 IC_kwDOAMm_X85Atx3R lanougue 32069530 2022-04-01T10:42:20Z 2022-04-01T10:42:20Z NONE

I wake up this issue, Any news ?

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  nonzero method for xr.DataArray 280875330
791379121 https://github.com/pydata/xarray/issues/1772#issuecomment-791379121 https://api.github.com/repos/pydata/xarray/issues/1772 MDEyOklzc3VlQ29tbWVudDc5MTM3OTEyMQ== cvr 1119116 2021-03-05T12:08:17Z 2021-03-05T12:09:32Z NONE

A possible code for this functionality could be: def nonzero4xarray (da:xarray.DataArray): c = da.where(da, drop=True).coords s = da.sel(c).to_series() s = s[s] o = [] for record in s.index: o.append(dict(list(zip(s.index.names, record)))) return o however the output is sub-optimal, as it yields a list of dicts, each with the corresponding coordinate to the nonzero value.

Consider the following example: ```

import numpy as np import xarray as xr x = np.arange(5) * 100 y = np.arange(4) * 100 z = np.arange(3) * 10 da = xr.DataArray(np.random.randn(z.size, y.size, x.size), dims=('z', 'y', 'x'), coords={'x': x, 'y': y, 'z': z}) da.loc[da.isel({'x':[0, 2], 'y':[1,3], 'z':[0]}).coords] = np.nan da.loc[da.isel({'x':[1, 3], 'y':[0], 'z':[-1]}).coords] = np.nan and imagine I want to capture the locations with NaN values. If I do: coords = da.where(da.isnull(), drop=True).coords da.sel(coords) array([[[ 1.586261, -0.2003 , 0.734872, -1.198746], [ nan, -0.108265, nan, 0.754857], [ nan, 0.700742, nan, -1.514642]],

   [[ 1.109573,       nan, -1.596756,       nan],
    [ 0.031771, -0.341263,  1.358767,  0.221174],
    [-0.671605,  0.923703,  0.085335, -1.672686]]])

``` I will get the coordinates for a mix of NaN and valid values, depending on how these are distributed.

If I want to obtain only the NaN locations: ```

coords = nonzero4xarray(da.isnull()) coords [{'z': 0, 'y': 100, 'x': 0}, {'z': 0, 'y': 100, 'x': 200}, {'z': 0, 'y': 300, 'x': 0}, {'z': 0, 'y': 300, 'x': 200}, {'z': 20, 'y': 0, 'x': 100}, {'z': 20, 'y': 0, 'x': 300}] vals = [da.sel(c).values[()] for c in coords] vals [nan, nan, nan, nan, nan, nan] `` whose functionality is similar tonumpy.nonzero, although sub-optimal as we cannot issueda.sel(coords)` directly.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  nonzero method for xr.DataArray 280875330
553705751 https://github.com/pydata/xarray/issues/1772#issuecomment-553705751 https://api.github.com/repos/pydata/xarray/issues/1772 MDEyOklzc3VlQ29tbWVudDU1MzcwNTc1MQ== stale[bot] 26384082 2019-11-14T03:18:57Z 2019-11-14T03:18:57Z NONE

In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity

If this issue remains relevant, please comment here or remove the stale label; otherwise it will be marked as closed automatically

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  nonzero method for xr.DataArray 280875330
351594036 https://github.com/pydata/xarray/issues/1772#issuecomment-351594036 https://api.github.com/repos/pydata/xarray/issues/1772 MDEyOklzc3VlQ29tbWVudDM1MTU5NDAzNg== fujiisoup 6815844 2017-12-14T02:58:02Z 2017-12-14T02:58:02Z MEMBER

For the above example, I consider the following output,

python <xarray.Dataset> Dimensions: (nz_points: 11) Dimensions without coordinates: nz_points Data variables: x (nz_points) int64 0 0 1 1 1 2 2 2 3 3 3 y (nz_points) int64 1 2 0 1 2 0 1 2 0 1 2

It would return a xr.Dataset each keys of which are the dimension names and their values are xr.DataArray of valid indices. da[da.nonzero()] or da.isel(**da.nonzero()) would return a 1d-DataArray with non-dimensional coordinates, x and y. (nz_points is the default dimension, equivalent to da.nonzero(dim='nz_points'))

nonzero method for Dataset is not obvious, but the return of xr.DataArray.nonzero should be passed to xr.Dataset.isel().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  nonzero method for xr.DataArray 280875330
351585455 https://github.com/pydata/xarray/issues/1772#issuecomment-351585455 https://api.github.com/repos/pydata/xarray/issues/1772 MDEyOklzc3VlQ29tbWVudDM1MTU4NTQ1NQ== shoyer 1217238 2017-12-14T02:03:21Z 2017-12-14T02:03:21Z MEMBER

What exactly should the result of DataArray.nonzero() or Dataset.nonzero() be?

In NumPy, nonzero() returns a tuple of 1D integer arrays suitable for indexing. It's not obvious to me how that generalizes to xarray.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  nonzero method for xr.DataArray 280875330

Advanced export

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

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 163.135ms · About: xarray-datasette