Skip to content

Commit dccabff

Browse files
committed
Add HACK for singleton dimension scales
If the axis array is size 1 or smaller, apply a scale of 1.
1 parent 4910814 commit dccabff

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/imagej/dims.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,13 @@ def _get_scale(axis):
284284
:return: The scale for this axis or None if it is a non-numeric scale.
285285
"""
286286
try:
287-
return axis.values[1] - axis.values[0]
287+
# HACK: This axis length check is a work around for singleton dimensions.
288+
# You can't calculate the slope of a singleton dimension.
289+
# This section will be removed when axis-scale-logic is merged.
290+
if len(axis) <= 1:
291+
return 1
292+
else:
293+
return axis.values[1] - axis.values[0]
288294
except TypeError:
289295
return None
290296

0 commit comments

Comments
 (0)