Skip to content

Commit 1b3c05c

Browse files
Cadairmeeseeksmachine
authored andcommitted
Backport PR sunpy#869: Made error message more helpful when cropping to a single pixel
1 parent 0657b39 commit 1b3c05c

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

changelog/869.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarified an error message that cropping to single pixel is not supported only when ``keepdims=False`` (the default value).

docs/explaining_ndcube/slicing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ But if :code:`keepdims=True`, a valid NDCube is returned with N length-1 dimensi
168168
>>> my_cube_roi = my_cube.crop(lower_left, upper_right, lower_right, upper_left)
169169
Traceback (most recent call last):
170170
...
171-
ValueError: Input points causes cube to be cropped to a single pixel. This is not supported.
171+
ValueError: Input points causes cube to be cropped to a single pixel. This is not supported when keepdims=False.
172172
>>> my_cube_roi_keep = my_cube.crop(lower_left, upper_right, lower_right, upper_left,
173173
... keepdims=True)
174174
>>> my_cube_roi_keep.shape

ndcube/utils/cube.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def get_crop_item_from_points(points, wcs, crop_by_values, keepdims):
125125
Denotes whether cropping is done using high-level objects or "values",
126126
i.e. low-level objects.
127127
128-
keep_dims : `bool`
128+
keepdims : `bool`
129129
If `False`, returned item will drop length-1 dimensions otherwise, item will keep length-1 dimensions.
130130
131131
Returns
@@ -205,7 +205,7 @@ def get_crop_item_from_points(points, wcs, crop_by_values, keepdims):
205205
# If item will result in a scalar cube, raise an error as this is not currently supported.
206206
if result_is_scalar:
207207
raise ValueError("Input points causes cube to be cropped to a single pixel. "
208-
"This is not supported.")
208+
"This is not supported when keepdims=False.")
209209
return tuple(item)
210210

211211

0 commit comments

Comments
 (0)