home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 203571994

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/811#issuecomment-203571994 https://api.github.com/repos/pydata/xarray/issues/811 203571994 MDEyOklzc3VlQ29tbWVudDIwMzU3MTk5NA== 4295853 2016-03-30T18:39:12Z 2016-03-30T18:39:12Z CONTRIBUTOR

More detail on the genesis of this issue:

acase.sel(Np=np.where(idx)[0]) works but acase.sel(Np=idx) does not returning the following error:

``` In [73]: acase.sel(Np=idx)


ValueError Traceback (most recent call last) <ipython-input-73-abb4dc27ed02> in <module>() ----> 1 acase.sel(Np=idx)

/users/pwolfram/envs/LIGHT_analysis/lib/python2.7/site-packages/xarray/core/dataset.pyc in sel(self, method, tolerance, indexers) 974 """ 975 return self.isel(indexing.remap_label_indexers( --> 976 self, indexers, method=method, tolerance=tolerance)) 977 978 def isel_points(self, dim='points', **indexers):

/users/pwolfram/envs/LIGHT_analysis/lib/python2.7/site-packages/xarray/core/indexing.pyc in remap_label_indexers(data_obj, indexers, method, tolerance) 189 return dict((dim, convert_label_indexer(data_obj[dim].to_index(), label, 190 dim, method, tolerance)) --> 191 for dim, label in iteritems(indexers)) 192 193

/users/pwolfram/envs/LIGHT_analysis/lib/python2.7/site-packages/xarray/core/indexing.pyc in <genexpr>((dim, label)) 189 return dict((dim, convert_label_indexer(data_obj[dim].to_index(), label, 190 dim, method, tolerance)) --> 191 for dim, label in iteritems(indexers)) 192 193

/users/pwolfram/envs/LIGHT_analysis/lib/python2.7/site-packages/xarray/core/indexing.pyc in convert_label_indexer(index, label, index_name, method, tolerance) 168 'the index is unsorted or non-unique') 169 else: --> 170 label = _asarray_tuplesafe(label) 171 if label.ndim == 0: 172 indexer = index.get_loc(label.item(), **kwargs)

/users/pwolfram/envs/LIGHT_analysis/lib/python2.7/site-packages/xarray/core/indexing.pyc in _asarray_tuplesafe(values) 131 if result.ndim == 2: 132 result = np.empty(len(values), dtype=object) --> 133 result[:] = values 134 135 return result

ValueError: could not broadcast input array from shape (92000) into shape (1)

```

with

``` In [76]: acase

Out[76]:

<xarray.Dataset> Dimensions: (Nb: 11, Np: 92000, Nr: 1, Nt-1: 27, Time: 28) Coordinates: yearoffset |S4 '1700' * Nb (Nb) float64 1.028e+03 1.029e+03 1.029e+03 1.029e+03 ... rlzn (Nr) int64 0 time (Time) datetime64[ns] 1724-01-01 1724-01-02 1724-01-03 ... * Np (Np) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... * Nr (Nr) int64 0 * Nt-1 (Nt-1) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... * Time (Time) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... Data variables: lat (Nr, Time, Nb, Np) float64 8.66e+03 8.66e+03 8.66e+03 ... notoutcropped (Nr, Time, Nb, Np) int64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... lon (Nr, Time, Nb, Np) float64 5e+03 1e+04 1.5e+04 2e+04 ... dtdays (Nr, Nt-1) float64 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ... ```

``` In [75]: idx

Out[75]:

<xarray.DataArray (Nr: 1, Np: 92000)> array([[ True, True, True, ..., False, False, False]], dtype=bool) Coordinates: yearoffset |S4 '1700' Nb float64 1.029e+03 rlzn (Nr) int64 0 time datetime64[ns] 1724-01-01 * Np (Np) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... * Nr (Nr) int64 0 Time int64 0

```

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