home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 192122307

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
192122307 MDU6SXNzdWUxOTIxMjIzMDc= 1140 sel with method 'nearest' fails with AssertionError 3404817 closed 0     10 2016-11-28T21:30:43Z 2017-03-30T19:18:34Z 2017-03-30T19:18:34Z CONTRIBUTOR      

The following fails

``python def test_sel_nearest(): """Testsel` with method='nearest'""" # create test data times = pd.date_range('2000-01-01', periods=4) foo = xr.DataArray([1,2,3,4], coords=dict(time=times), dims='time')

# works
expected = foo.sel(time='2000-01-01')

# fails
assert foo.sel(time='2000-01-01', method='nearest') == expected

```

with an AssertionError in xarray/core/variable.py:

``` C:\Users\uuu\AppData\Local\Continuum\Miniconda2\lib\site-packages\xarray\core\dataarray.pyc in sel(self, method, tolerance, indexers) 623 self, indexers, method=method, tolerance=tolerance 624 ) --> 625 return self.isel(pos_indexers)._replace_indexes(new_indexes) 626 627 def isel_points(self, dim='points', **indexers):

C:\Users\uuu\AppData\Local\Continuum\Miniconda2\lib\site-packages\xarray\core\dataarray.pyc in isel(self, indexers) 608 DataArray.sel 609 """ --> 610 ds = self._to_temp_dataset().isel(indexers) 611 return self._from_temp_dataset(ds) 612

C:\Users\uuu\AppData\Local\Continuum\Miniconda2\lib\site-packages\xarray\core\dataset.pyc in isel(self, indexers) 910 for name, var in iteritems(self._variables): 911 var_indexers = dict((k, v) for k, v in indexers if k in var.dims) --> 912 variables[name] = var.isel(var_indexers) 913 return self._replace_vars_and_dims(variables) 914

C:\Users\uuu\AppData\Local\Continuum\Miniconda2\lib\site-packages\xarray\core\variable.pyc in isel(self, **indexers) 539 if dim in indexers: 540 key[i] = indexers[dim] --> 541 return self[tuple(key)] 542 543 def _shift_one_dim(self, dim, count):

C:\Users\uuu\AppData\Local\Continuum\Miniconda2\lib\site-packages\xarray\core\variable.pyc in getitem(self, key) 377 # orthogonal indexing should ensure the dimensionality is consistent 378 if hasattr(values, 'ndim'): --> 379 assert values.ndim == len(dims), (values.ndim, len(dims)) 380 else: 381 assert len(dims) == 0, len(dims)

AssertionError: (0, 1) ```

It does not matter which type the dimension has that is indexed:

``python def test_sel_nearest_int(): """Testsel` with method='nearest'""" bar = xr.DataArray([1, 2, 3, 4], coords=dict(dummy=range(4)), dims='dummy')

# works
expected = bar.sel(dummy=3)

# fails
assert bar.sel(dummy=3, method='nearest') == expected

```

This is on Miniconda for Windows 64 bit with conda-forge and IOOS builds and * xarray=0.8.2 * pandas=0.19.1 * numpy=1.11.2

Why might this be? Am I doing something wrong?

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1140/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
  • 10 rows from issue in issue_comments
Powered by Datasette · Queries took 0.625ms · About: xarray-datasette