Skip to content

Commit

Permalink
MNT: Fix with xarray 0.10.2 (Fixes #192)
Browse files Browse the repository at this point in the history
XArray reworked some of the classes that support our backend, so we need
to update. This also means that this (admittedly under exposed) code
only works with xarray >=0.10.2, so bump the requirements for it.
  • Loading branch information
dopplershift committed Mar 20, 2018
1 parent d605722 commit 65d6842
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ dependencies:
- flake8-quotes
- pep8-naming
- matplotlib
- xarray
- xarray >=0.10.2
- cartopy
- beautifulsoup4
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'flake8-copyright', 'flake8-docstrings', 'flake8-import-order',
'flake8-mutable', 'flake8-pep3101', 'flake8-print', 'flake8-quotes',
'pep8-naming',
'vcrpy~=1.5,!=1.7.0,!=1.7.1,!=1.7.2,!=1.7.3', 'xarray>=0.6'],
'vcrpy~=1.5,!=1.7.0,!=1.7.1,!=1.7.2,!=1.7.3', 'xarray>=0.10.2'],
'doc': ['sphinx>=1.3,!=1.6.4', 'sphinx-gallery', 'doc8', 'recommonmark'],
# SciPy needed for cartopy; we don't use cartopy[plotting] because
# that will pull in GDAL.
Expand Down
14 changes: 10 additions & 4 deletions siphon/cdmr/xarray_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ def get_array(self):

def __getitem__(self, item):
"""Wrap getitem around the data."""
item = indexing.unwrap_explicit_indexer(
item, self, allow=(indexing.BasicIndexer, indexing.OuterIndexer))
return self.get_array()[item]
item, np_inds = indexing.decompose_indexer(item, self.shape,
indexing.IndexingSupport.BASIC)
with self.datastore:
array = self.get_array()[item.tuple]

if len(np_inds.tuple) > 0:
array = indexing.NumpyIndexingAdapter(array)[np_inds]

return array


class CDMRemoteStore(AbstractDataStore):
Expand All @@ -45,7 +51,7 @@ def __init__(self, url, deflate=None):

def open_store_variable(self, name, var):
"""Turn CDMRemote variable into something like a numpy.ndarray."""
data = indexing.LazilyIndexedArray(CDMArrayWrapper(name, self))
data = indexing.LazilyOuterIndexedArray(CDMArrayWrapper(name, self))
return Variable(var.dimensions, data, {a: getattr(var, a) for a in var.ncattrs()})

def get_variables(self):
Expand Down

0 comments on commit 65d6842

Please sign in to comment.