From 81a511d2f12b5a7dd8f1fe8df47e59d39228dcac Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Fri, 12 Apr 2019 13:14:05 -0400 Subject: [PATCH] Add helpful error when unsupported slice item used. #128. --- ndcube/tests/test_ndcube.py | 2 ++ ndcube/utils/wcs.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ndcube/tests/test_ndcube.py b/ndcube/tests/test_ndcube.py index 1eb7f4988..d6b6d931d 100644 --- a/ndcube/tests/test_ndcube.py +++ b/ndcube/tests/test_ndcube.py @@ -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", [ diff --git a/ndcube/utils/wcs.py b/ndcube/utils/wcs.py index d48ebaeaa..ed4973f8e 100644 --- a/ndcube/utils/wcs.py +++ b/ndcube/utils/wcs.py @@ -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]