File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ def _ss(data, c=None):
234234 # The sum will be a NAN or INF. We can ignore all the finite
235235 # partials, and just look at this special one.
236236 ssd = c = sx_partials [None ]
237- assert not _isfinite (total )
237+ assert not _isfinite (ssd )
238238 else :
239239 sx = sum (Fraction (n , d ) for d , n in sx_partials .items ())
240240 sxx = sum (Fraction (n , d * d ) for d , n in sxx_partials .items ())
@@ -945,7 +945,11 @@ def _mean_stdev(data):
945945 if n < 2 :
946946 raise StatisticsError ('stdev requires at least two data points' )
947947 mss = ss / (n - 1 )
948- return float (xbar ), _float_sqrt_of_frac (mss .numerator , mss .denominator )
948+ try :
949+ return float (xbar ), _float_sqrt_of_frac (mss .numerator , mss .denominator )
950+ except AttributeError :
951+ # Handle Nans and Infs gracefully
952+ return float (xbar ), float (xbar ) / float (ss )
949953
950954
951955# === Statistics for relations between two inputs ===
You can’t perform that action at this time.
0 commit comments