home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

4 rows where author_association = "MEMBER" and issue = 947796627 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 2

  • max-sixty 2
  • keewis 2

issue 1

  • `xr.where()` does not work like `np.where()`on meshgrids · 4 ✖

author_association 1

  • MEMBER · 4 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
883232093 https://github.com/pydata/xarray/issues/5620#issuecomment-883232093 https://api.github.com/repos/pydata/xarray/issues/5620 IC_kwDOAMm_X840pQ1d keewis 14808389 2021-07-20T09:09:31Z 2021-07-20T09:44:42Z MEMBER

Actually, I can reproduce this with the example "rasm" dataset: python In [2]: import xarray as xr ...: ...: rasm = xr.tutorial.open_dataset("rasm").load() ...: ...: min_lat = 17 ...: max_lat = 18 ...: min_lon = 189 ...: max_lon = 190 ...: ...: mask = ( ...: (rasm.xc <= max_lon) & (rasm.xc > min_lon) ...: & (rasm.yc <= max_lat) & (rasm.yc > min_lat) ...: ) ...: ...: subset = rasm.xc.where(mask, drop=True) ...: display(subset.max(), subset.xc.max()) ...: display(subset, subset.xc) <xarray.DataArray 'xc' ()> array(189.89982737) <xarray.DataArray 'xc' ()> array(190.07286203) <xarray.DataArray 'xc' (y: 3, x: 4)> array([[189.55836619, 189.72833384, 189.89982737, nan], [189.30253733, 189.47184886, 189.64270151, 189.81509531], [189.04515208, 189.21383799, 189.38403452, nan]]) Coordinates: xc (y, x) float64 189.6 189.7 189.9 190.1 ... 189.0 189.2 189.4 189.6 yc (y, x) float64 17.02 17.27 17.51 17.76 ... 17.34 17.59 17.84 18.08 Dimensions without coordinates: y, x Attributes: long_name: longitude of grid cell center units: degrees_east <xarray.DataArray 'xc' (y: 3, x: 4)> array([[189.55836619, 189.72833384, 189.89982737, 190.07286203], [189.30253733, 189.47184886, 189.64270151, 189.81509531], [189.04515208, 189.21383799, 189.38403452, 189.55578745]]) Coordinates: xc (y, x) float64 189.6 189.7 189.9 190.1 ... 189.0 189.2 189.4 189.6 yc (y, x) float64 17.02 17.27 17.51 17.76 ... 17.34 17.59 17.84 18.08 Dimensions without coordinates: y, x Attributes: long_name: longitude of grid cell center units: degrees_east

which makes it pretty obvious why this fails: drop=True drops as much as possible, but to really drop everything we would have to collapse the result to 1D. To work around that, .where sets the data to nan where necessary, but only for data variables (as coordinates still need to label the masked values).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  `xr.where()` does not work like `np.where()`on meshgrids 947796627
883226384 https://github.com/pydata/xarray/issues/5620#issuecomment-883226384 https://api.github.com/repos/pydata/xarray/issues/5620 IC_kwDOAMm_X840pPcQ keewis 14808389 2021-07-20T09:01:34Z 2021-07-20T09:01:34Z MEMBER

@meteoDaniel, it ultimately comes down to how much time a maintainer is willing to spend on a single issue, with self-contained, small examples being much easier to debug (and there are a few other reasons in the blog post linked to by @max-sixty).

That said, I can reproduce your issue, which apparently is independent of the way the mask is constructed: ```python mask = ( (latitudes <= maxLat) & (latitudes > minLat) & (longitudes <= maxLon) & (longitudes > minLon) )

ds.where(xr.DataArray(mask, dims=("y", "x")), drop=True).latitude.max() # 49.30 latitudes[mask].max() # 48.92 ```

However, if I do python subset = ds.latitude.where(xr.DataArray(mask, dims=("y", "x")), drop=True) subset.max() I get the same result as with pure numpy.

Interestingly, xr.testing.assert_identical(subset, subset.latitude) raises...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  `xr.where()` does not work like `np.where()`on meshgrids 947796627
883085722 https://github.com/pydata/xarray/issues/5620#issuecomment-883085722 https://api.github.com/repos/pydata/xarray/issues/5620 IC_kwDOAMm_X840otGa max-sixty 5635139 2021-07-20T05:50:39Z 2021-07-20T05:50:48Z MEMBER

No stress — I know it can be unclear at first — but can you show the same result without requiring downloading data and with a smaller example? Here's the link in the issue template I was referring to: http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  `xr.where()` does not work like `np.where()`on meshgrids 947796627
883071124 https://github.com/pydata/xarray/issues/5620#issuecomment-883071124 https://api.github.com/repos/pydata/xarray/issues/5620 IC_kwDOAMm_X840opiU max-sixty 5635139 2021-07-20T05:29:50Z 2021-07-20T05:29:50Z MEMBER

Hi @meteoDaniel — please could you add a minimal example as per the link in the issue template?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  `xr.where()` does not work like `np.where()`on meshgrids 947796627

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 12.691ms · About: xarray-datasette