home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 427195935

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/1626#issuecomment-427195935 https://api.github.com/repos/pydata/xarray/issues/1626 427195935 MDEyOklzc3VlQ29tbWVudDQyNzE5NTkzNQ== 23484003 2018-10-04T22:59:19Z 2018-10-08T15:10:54Z NONE

I just got bit with this as well. I was basically using tuples of indices as coordinates in order to implement a multidimensional sparse array .

My workaround is to use plain dimension index_dim to index the points in the N-dimensional space that I actually populate, and to have several coordinates (say X,Y) that all have index_dim as their only dimension. It's easy enough to see what the coordinates are once you select a value along index_dim, but I have to go outside xarray to locate a populated point based on it's X,Y-coordinates, because I can't slice along those arrays as (A) they aren't aliased to a dimension (B) they have non-unique values.

I've come up with an ugly method for selecting by tuples of X,Y-coordinates:

pairs = zip(x_wanted,y_wanted)

pair2index = {(dataset.x[i].item(), dataset.y[i].item()):i for i in dataset.index_dim.data}

try:

     found_indices = [pair2index[p] for p in pairs]

     found = dataset.isel(index_dim=found_indices)

except KeyError:

     print "Coordinate {} not found in dataset.".format(p)

     raise
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  264582338
Powered by Datasette · Queries took 0.76ms · About: xarray-datasette