Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no attribute 'LazilyIndexedArray' #192

Closed
jrleeman opened this issue Mar 19, 2018 · 3 comments
Closed

no attribute 'LazilyIndexedArray' #192

jrleeman opened this issue Mar 19, 2018 · 3 comments
Assignees
Milestone

Comments

@jrleeman
Copy link
Contributor

Looks like a new Xarray version has broken master.

=================================== FAILURES ===================================
_____________________________ test_xarray_dataset ______________________________
    @recorder.use_cassette('rap_compressed')
    def test_xarray_dataset():
        """Test getting data using xarray open_dataset over CDMRemote."""
        store = CDMRemoteStore('http://thredds-dev.unidata.ucar.edu/thredds/cdmremote/'
                               'grib/NCEP/RAP/CONUS_13km/RR_CONUS_13km_20150518_1200.grib2/GC')
>       ds = open_dataset(store)
siphon/cdmr/tests/test_xarray.py:20: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/xarray/backends/api.py:326: in open_dataset
    return maybe_decode_store(store)
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/xarray/backends/api.py:238: in maybe_decode_store
    drop_variables=drop_variables)
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/xarray/conventions.py:594: in decode_cf
    vars, attrs = obj.load()
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/xarray/backends/common.py:217: in load
    for k, v in self.get_variables().items())
siphon/cdmr/xarray_support.py:54: in get_variables
    for k, v in self.ds.variables.items())
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/xarray/core/utils.py:308: in FrozenOrderedDict
    return Frozen(OrderedDict(*args, **kwargs))
siphon/cdmr/xarray_support.py:54: in <genexpr>
    for k, v in self.ds.variables.items())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <siphon.cdmr.xarray_support.CDMRemoteStore object at 0x7f6b36eea6d8>
name = 'Geopotential_height_isobaric'
var = <siphon.cdmr.dataset.Variable object at 0x7f6b36ec0860>
    def open_store_variable(self, name, var):
        """Turn CDMRemote variable into something like a numpy.ndarray."""
>       data = indexing.LazilyIndexedArray(CDMArrayWrapper(name, self))
E       AttributeError: module 'xarray.core.indexing' has no attribute 'LazilyIndexedArray'
siphon/cdmr/xarray_support.py:48: AttributeError
==================== 1 failed, 289 passed in 137.13 seconds ====================

@jrleeman
Copy link
Contributor Author

I can confirm that this works in Xarray 0.10.1, but not 0.10.2. Release notes didn't give up anything at first glance.

@dopplershift
Copy link
Member

I think it's pydata/xarray#1899.

@fujiisoup
Copy link

fujiisoup commented Mar 19, 2018

Please rename LazilyIndexedArray to LazilyOuterIndexedArray.
We also updated indexing path for backend arrays (unwrap_explicit_indexer no longer exists).
Do something like this

def __getitem__(self, item):
    key, np_inds = indexing.decompose_indexer(
        key, self.shape, indexing.IndexingSupport.OUTER)
    with self.datastore.ensure_open(autoclose=True):
        array = self.get_array()[key.tuple]

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

    return array

See an example backend wrapper
https://github.com/pydata/xarray/blob/a1fa397c48698b3434e513d480a8a2e8ad04dd58/xarray/backends/h5netcdf_.py#L18-L33

(Sorry for the inconvenience.)

dopplershift added a commit to dopplershift/siphon that referenced this issue Mar 20, 2018
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.
jrleeman added a commit that referenced this issue Mar 20, 2018
MNT: Fix with xarray 0.10.2 (Fixes #192)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants