estimate_skew_contours: ensure retval is always float

This commit is contained in:
Robert Sachunsky 2026-05-22 12:37:07 +02:00
parent 26afc5ddab
commit 9801129aa6

View file

@ -330,7 +330,7 @@ def estimate_skew_contours(contours):
if not np.any(usable): if not np.any(usable):
raise ValueError("not enough contours with consistent length") raise ValueError("not enough contours with consistent length")
if np.count_nonzero(usable) == 1: if np.count_nonzero(usable) == 1:
return angle_in[usable] return angle_in[usable][0]
# 4. there is no way to distinguish between +90 and -89.9 here, # 4. there is no way to distinguish between +90 and -89.9 here,
# so map to [0,180] when calculating averages, then map back to [-90,90] # so map to [0,180] when calculating averages, then map back to [-90,90]
# (we don't want -90 and +89 to average zero, or +1 and +179 to average 90) # (we don't want -90 and +89 to average zero, or +1 and +179 to average 90)