home / github

Menu
  • GraphQL API
  • Search all tables

issues

Table actions
  • GraphQL API for issues

1 row where type = "pull" and user = 30388627 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 1

  • pull · 1 ✖

state 1

  • closed 1

repo 1

  • xarray 1
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
591643901 MDExOlB1bGxSZXF1ZXN0Mzk2Nzc0MTAw 3924 Coordinates passed to interp have nan values zxdawn 30388627 closed 0     9 2020-04-01T05:46:54Z 2020-08-27T08:51:32Z 2020-08-27T08:51:32Z NONE   0 pydata/xarray/pulls/3924

Problem

Keyerror when the coordinates passed to interp have nan value.

Example

``` import numpy as np import xarray as xr

da = xr.DataArray(np.sin(0.3 * np.arange(20).reshape(5, 4)), [('x', np.arange(5)), ('y', [0.1, 0.2, 0.3, 0.4])])

x = xr.DataArray([[0.5, np.nan], [1.5, 2.5]], dims=['z1', 'z2']) y = xr.DataArray([[0.15, 0.2], [np.nan, 0.35]], dims=['z1', 'z2']) da_nan = da.interp(x=x, y=y) ```

Output

E:\miniconda3\envs\satpy\lib\site-packages\pandas\core\indexes\base.py:2826: RuntimeWarning: invalid value encountered in less op(left_distances, right_distances) | (right_indexer == -1), Traceback (most recent call last): File "C:\Users\Xin\Desktop\test_none.py", line 10, in <module> da_nan = da.interp(x=x, y=y) File "E:\miniconda3\envs\satpy\lib\site-packages\xarray\core\dataarray.py", line 1365, in interp **coords_kwargs, File "E:\miniconda3\envs\satpy\lib\site-packages\xarray\core\dataset.py", line 2610, in interp variables[name] = missing.interp(var, var_indexers, method, **kwargs) File "E:\miniconda3\envs\satpy\lib\site-packages\xarray\core\missing.py", line 611, in interp var, indexes_coords = _localize(var, indexes_coords) File "E:\miniconda3\envs\satpy\lib\site-packages\xarray\core\missing.py", line 552, in _localize imin = index.get_loc(np.min(new_x.values), method="nearest") File "E:\miniconda3\envs\satpy\lib\site-packages\pandas\core\indexes\base.py", line 2654, in get_loc raise KeyError(key) KeyError: nan

Solution

Use np.nanmin and np.nanmax in index.get_loc()

Test

Code

``` import numpy as np import xarray as xr

da = xr.DataArray(np.sin(0.3 * np.arange(20).reshape(5, 4)), [('x', np.arange(5)), ('y', [0.1, 0.2, 0.3, 0.4])])

x = xr.DataArray([[0.5, np.nan], [1.5, 2.5]], dims=['z1', 'z2']) y = xr.DataArray([[0.15, 0.2], [np.nan, 0.35]], dims=['z1', 'z2']) da_nan = da.interp(x=x, y=y)

x = xr.DataArray([[0.5, 1], [1.5, 2.5]], dims=['z1', 'z2']) y = xr.DataArray([[0.15, 0.2], [0.25, 0.35]], dims=['z1', 'z2']) da_nonan = da.interp(x=x, y=y)

print('da_nan \n', da_nan) print('da_nonan \n', da_nonan) ```

Output

E:\miniconda3\envs\satpy\lib\site-packages\scipy\interpolate\interpolate.py:2539: RuntimeWarning: invalid value encountered in less out_of_bounds += x < grid[0] E:\miniconda3\envs\satpy\lib\site-packages\scipy\interpolate\interpolate.py:2540: RuntimeWarning: invalid value encountered in greater out_of_bounds += x > grid[-1] da_nan <xarray.DataArray (z1: 2, z2: 2)> array([[ 0.55626357, nan], [ nan, -0.46643289]]) Coordinates: x (z1, z2) float64 0.5 nan 1.5 2.5 y (z1, z2) float64 0.15 0.2 nan 0.35 Dimensions without coordinates: z1, z2 da_nonan <xarray.DataArray (z1: 2, z2: 2)> array([[ 0.55626357, 0.99749499], [ 0.63496063, -0.46643289]]) Coordinates: x (z1, z2) float64 0.5 1.0 1.5 2.5 y (z1, z2) float64 0.15 0.2 0.25 0.35 Dimensions without coordinates: z1, z2

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3924/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 pull

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