Skip to content

Fix indexing error for data loaded with open_rasterio #2456

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

Merged
merged 1 commit into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,21 @@ Bug fixes
(:issue:`2240`)
By `Keisuke Fujii <https://github.com/fujiisoup>`_.

- 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 2019)
v0.10.9 (21 September 2018)
---------------------------

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 @@ -2928,6 +2928,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