Skip to content

Commit

Permalink
Fix indexing error for data loaded with open_rasterio (pydata#2456)
Browse files Browse the repository at this point in the history
xref GH2454
  • Loading branch information
shoyer authored Oct 8, 2018
1 parent 5f09deb commit 5b4d160
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Bug fixes
By `Deepak Cherian <https://github.com/dcherian>`_.


- Fix a bug that caused some indexing operations on arrays opened with
``open_rasterio`` to error (:issue:`2454`).
By `Stephan Hoyer <https://github.com/shoyer>`_.

.. _whats-new.0.10.9:

v0.10.9 (21 September 2018)
Expand All @@ -86,7 +90,7 @@ This minor release contains a number of backwards compatible enhancements.
Announcements of note:

- Xarray is now a NumFOCUS fiscally sponsored project! Read
`the anouncment <https://numfocus.org/blog/xarray-joins-numfocus-sponsored-projects>`_
`the anouncement <https://numfocus.org/blog/xarray-joins-numfocus-sponsored-projects>`_
for more details.
- We have a new :doc:`roadmap` that outlines our future development plans.

Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/rasterio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _get_indexer(self, key):

if isinstance(key[1], np.ndarray) and isinstance(key[2], np.ndarray):
# do outer-style indexing
np_inds[1:] = np.ix_(*np_inds[1:])
np_inds[-2:] = np.ix_(*np_inds[-2:])

return band_key, tuple(window), tuple(squeeze_axis), tuple(np_inds)

Expand Down
4 changes: 4 additions & 0 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2925,6 +2925,10 @@ def test_indexing(self):
assert_allclose(expected.isel(**ind), actual.isel(**ind))
assert not actual.variable._in_memory

ind = {'band': 0, 'x': np.array([0, 0]), 'y': np.array([1, 1, 1])}
assert_allclose(expected.isel(**ind), actual.isel(**ind))
assert not actual.variable._in_memory

# minus-stepped slice
ind = {'band': np.array([2, 1, 0]),
'x': slice(-1, None, -1), 'y': 0}
Expand Down

0 comments on commit 5b4d160

Please sign in to comment.