home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

4 rows where issue = 597785475 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 3

  • dcherian 2
  • Illviljan 1
  • stale[bot] 1

author_association 2

  • MEMBER 3
  • NONE 1

issue 1

  • Interpolation - Support extrapolation method "clip" · 4 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1114752371 https://github.com/pydata/xarray/issues/3962#issuecomment-1114752371 https://api.github.com/repos/pydata/xarray/issues/3962 IC_kwDOAMm_X85CccVz stale[bot] 26384082 2022-05-02T11:37:48Z 2022-05-02T11:37:48Z 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
}
  Interpolation - Support extrapolation method "clip" 597785475
612080638 https://github.com/pydata/xarray/issues/3962#issuecomment-612080638 https://api.github.com/repos/pydata/xarray/issues/3962 MDEyOklzc3VlQ29tbWVudDYxMjA4MDYzOA== dcherian 2448579 2020-04-10T15:32:18Z 2020-04-10T15:32:18Z MEMBER

As noted in #3956 fill_value="extrapolate" is what we need for 1D.

xarray could use the same interpolation function for both 1d and nd.

Not sure if there's a big performance gain. @jhamman implemented these interpolators originally AFAIK. Perhaps he remembers why we use both.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Interpolation - Support extrapolation method "clip" 597785475
612077587 https://github.com/pydata/xarray/issues/3962#issuecomment-612077587 https://api.github.com/repos/pydata/xarray/issues/3962 MDEyOklzc3VlQ29tbWVudDYxMjA3NzU4Nw== Illviljan 14371165 2020-04-10T15:25:30Z 2020-04-10T15:30:05Z MEMBER

Nice find! The documentation doesn't explain that at all currently.

But that solution doesn't work for 1d DataArrays. You have to use this kwargs instead: python kwargs = dict(fill_value=(np.min(da.data), np.max(da.data))) So it still isn't as convenient as I would like it to be. The wrapper function can now be simplified to this however:

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

def interp(da, coords, extrapolation='clip'): """ Linear interpolation that clips the inputs to the coords min and max value.

Parameters
----------
da : DataArray
    DataArray to interpolate.
coords : dict
    Coordinates for the interpolated value.
"""
if extrapolation == 'clip':
    if len(da.coords) > 1:
        kwargs = dict(fill_value=None)
    else:
        kwargs = dict(fill_value=(np.min(da.data), np.max(da.data)))
return da.interp(coords, kwargs=kwargs)

Create coordinates:

x = np.linspace(1000, 6000, 4) y = np.linspace(100, 1200, 3) z = np.linspace(1, 2, 2)

Create 1D DataArray:

da1 = xr.DataArray(data=2*x, coords=[('x', x)])

Create 2D DataArray:

X = np.meshgrid(*[x, y], indexing='ij') data = X[0] * X[1] da2 = xr.DataArray(data=data, coords=[('x', x), ('y', y)])

Create 3D DataArray:

X = np.meshgrid(*[x, y, z], indexing='ij') data = X[0] * X[1] * X[2] da3 = xr.DataArray(data=data, coords=[('x', x), ('y', y), ('z', z)])

Attempt to extrapolate:

print(interp(da1, {'x': 7000})) print(interp(da2, {'x': 7000, 'y': 375})) print(interp(da3, {'x': 7000, 'y': 375, 'z': 1})) ````

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Interpolation - Support extrapolation method "clip" 597785475
612024066 https://github.com/pydata/xarray/issues/3962#issuecomment-612024066 https://api.github.com/repos/pydata/xarray/issues/3962 MDEyOklzc3VlQ29tbWVudDYxMjAyNDA2Ng== dcherian 2448579 2020-04-10T13:17:36Z 2020-04-10T13:17:36Z MEMBER

Scipy will do this for you if you ask it to:

da.interp(x=7000, y=375, method="linear", kwargs=dict(fill_value=None))

See https://github.com/pydata/xarray/pull/3956 .

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Interpolation - Support extrapolation method "clip" 597785475

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