@@ -713,10 +713,10 @@ def _calculate_curvature(list_metric):
713713
714714 # work mostly on CPU here - we have very small arrays here
715715 list1 = cp .asnumpy (list_metric [min_pos - radi : min_pos + radi + 1 ])
716- list1 [ np . isnan ( list1 )] = list1 [ ~ np .isnan ( list1 )]. mean ()
717- list1 [ np . isinf ( list1 )] = list1 [ ~ np . isinf ( list1 )]. mean ()
718-
719- # afact1 = np.polyfit(np.arange(0, 2 * radi + 1), list1, 2)[0]
716+ if not all ( map ( np .isfinite , list1 )):
717+ raise ValueError (
718+ "The list of metrics (list1) contains nan's or infs. Check your input data"
719+ )
720720
721721 series1 = Polynomial .fit (np .arange (0 , 2 * radi + 1 ), list1 , deg = 2 )
722722 afact1 = series1 .convert ().coef [- 1 ]
@@ -725,7 +725,10 @@ def _calculate_curvature(list_metric):
725725 list2 [np .isnan (list2 )] = list2 [~ np .isnan (list2 )].mean ()
726726 list2 [np .isinf (list2 )] = list2 [~ np .isinf (list2 )].mean ()
727727
728- # (afact2, bfact2, _) = np.polyfit(np.arange(min_pos - 1, min_pos + 2), list2, 2)
728+ if not all (map (np .isfinite , list2 )):
729+ raise ValueError (
730+ "The list of metrics (list2) contains nan's or infs. Check your input data"
731+ )
729732
730733 series2 = Polynomial .fit (np .arange (min_pos - 1 , min_pos + 2 ), list2 , deg = 2 )
731734 afact2 = series2 .convert ().coef [- 1 ]
0 commit comments