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

Add helpful error when unsupported slice item used. #158

Merged
merged 1 commit into from
May 8, 2019
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
2 changes: 2 additions & 0 deletions ndcube/tests/test_ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ def test_slicing_error(test_input):
test_input[None]
with pytest.raises(IndexError):
test_input[0, None]
with pytest.raises(NotImplementedError):
test_input[[0, 1]]


@pytest.mark.parametrize("test_input,expected", [
Expand Down
2 changes: 2 additions & 0 deletions ndcube/utils/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ def _wcs_slicer(wcs, missing_axis, item):
for i, it in enumerate(item_checked):
if isinstance(it, int):
missing_axis[i] = True
else:
raise NotImplementedError("Slicing FITS-WCS by {0} not supported.".format(type(item)))
# returning the reverse list of missing axis as in the item here was reverse of
# what was inputed so we had a reverse missing_axis.
return new_wcs, missing_axis[::-1]
Expand Down