home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 278325492

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
278325492 MDExOlB1bGxSZXF1ZXN0MTU1NzYwMzQz 1751 Indexing Variable objects with a mask 1217238 closed 0     11 2017-12-01T01:12:03Z 2017-12-18T05:39:18Z 2017-12-18T05:38:13Z MEMBER   0 pydata/xarray/pulls/1751

This will be useful for multi-dimensional reindexing: marking masked items with -1 is exactly the convention used by pandas.Index.get_indexer().

Example usage:

In [6]: variable = xr.Variable(('x',), [1, 2, 3])

In [7]: variable._getitem_with_mask([0, 1, 2, -1])
Out[7]:
<xarray.Variable (x: 4)>
array([  1.,   2.,   3.,  nan])

In [8]: variable._getitem_with_mask(xr.Variable(('x', 'y'), [[0, -1], [-1, 1]]), fill_value=-99)
Out[8]:
<xarray.Variable (x: 2, y: 2)>
array([[  1, -99],
       [-99,   2]])

This uses where() so it isn't the most efficient (there is some wasted effort doing indexing, as noted in the TODOs), but the implementation is pretty clean and already works with dask.

For now, I'm leaving this as private API, but let's expose it publicly in the future if we are happy with it. I would probably leave it as a Variable method since this is pretty low-level.

  • [x] Tests added / passed
  • [x] Passes git diff upstream/master **/*py | flake8 --diff

cc @fujiisoup @mraspaud

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

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 11 rows from issue in issue_comments
Powered by Datasette · Queries took 4.031ms · About: xarray-datasette