home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 112430028

This data as json

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
112430028 MDU6SXNzdWUxMTI0MzAwMjg= 634 Unexpected behavior by diff when applied to coordinate DataArray 6200806 closed 0     3 2015-10-20T18:26:58Z 2015-12-04T20:40:31Z 2015-12-04T20:40:31Z CONTRIBUTOR      

DataArray.diff, when applied to a coordinate, just returns the coordinate itself with one index truncated. Consider the following:

``` In [5]: arr = xray.DataArray(range(0, 20, 2), dims=['lon'], coords=[range(10)]) In [6]: arr.diff('lon') <xray.DataArray (lon: 9)> array([2, 2, 2, 2, 2, 2, 2, 2, 2]) Coordinates: * lon (lon) int64 1 2 3 4 5 6 7 8 9

In [7]: arr['lon'].diff('lon') <xray.DataArray 'lon' (lon: 9)> array([1, 2, 3, 4, 5, 6, 7, 8, 9]) Coordinates: * lon (lon) int64 1 2 3 4 5 6 7 8 9 ```

Is this the intended behavior? The documentation doesn't mention anything about this, and its counter-intuitive, so I'm wondering if its a bug instead. Even if it is intended, I personally would like to be able to use a coordinate array's diff on itself to get its spacing, e.g. for use as the denominator in finite differencing approximations to derivatives.

Thanks!

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

Links from other tables

  • 1 row from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.772ms · About: xarray-datasette