Skip to content

Commit

Permalink
Merge pull request #158 from DanRyanIrish/slice_error_message
Browse files Browse the repository at this point in the history
Add helpful error when unsupported slice item used.
  • Loading branch information
DanRyanIrish authored May 8, 2019
2 parents d421dee + 81a511d commit bb7e125
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
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

0 comments on commit bb7e125

Please sign in to comment.