Skip to content

Commit

Permalink
MNT: Update CDM xarray backend for newer xarray
Browse files Browse the repository at this point in the history
Makes use of some newer xarray helpers to meet the typing expectations
xarray has these days. Also remove some unneeded fallback code.
  • Loading branch information
dopplershift committed Nov 6, 2024
1 parent 46f1e29 commit 1124d75
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/siphon/cdmr/xarray_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
from xarray import Variable
from xarray.backends.common import AbstractDataStore, BackendArray
from xarray.core import indexing

try:
from xarray.core.utils import FrozenDict
except ImportError:
from xarray.core.utils import FrozenOrderedDict as FrozenDict
from xarray.core.utils import FrozenDict

from . import Dataset

Expand All @@ -33,15 +29,11 @@ def get_array(self):

def __getitem__(self, item):
"""Wrap getitem around the data."""
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
arr = self.get_array()
return indexing.explicit_indexing_adapter(item, self.shape,
indexing.IndexingSupport.BASIC,
arr.__getitem__)


class CDMRemoteStore(AbstractDataStore):
Expand Down

0 comments on commit 1124d75

Please sign in to comment.