Skip to content

Commit dc3a05e

Browse files
committed
Move sanitzation of length-1 crop inputs to sanitize_crop_inputs.
1 parent 45ee5ae commit dc3a05e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

ndcube/utils/cube.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def sanitize_crop_inputs(points, wcs):
8181
# Confirm whether point contains at least one None entry.
8282
if all(coord is None for coord in points[i]):
8383
values_are_none[i] = True
84+
# Squeeze length-1 coordinate objects to scalars.
85+
points[i] = [coord.squeeze() if hasattr(coord, "squeeze") else coord for coord in points[i]]
8486
# If no points contain a coord, i.e. if all entries in all points are None,
8587
# set no-op flag to True and exit.
8688
if all(values_are_none):
@@ -142,12 +144,6 @@ def get_crop_item_from_points(points, wcs, crop_by_values, keepdims):
142144
wcs = high_level_wcs.low_level_wcs
143145
# For each point compute the corresponding array indices.
144146
for point in points:
145-
# Sanitize input format
146-
# Make point a tuple if given as a single high level coord object valid for this WCS.
147-
if isinstance(point, tuple(v[0] for v in wcs.world_axis_object_classes.values())):
148-
point = (point,)
149-
# If point is a length-1 object, convert it to scalar.
150-
point = tuple(p.squeeze() if hasattr(p, "squeeze") else p for p in point)
151147
# Get the arrays axes associated with each element in point.
152148
if crop_by_values:
153149
point_inputs_array_axes = []

0 commit comments

Comments
 (0)