@@ -447,8 +447,11 @@ def display_changed(self):
447447 self .order = list (range (len (self .stats )))
448448 criterion = self ._sorting_criteria_attrs [self .compare ]
449449 if criterion :
450- self .order = sorted (
451- self .order , key = lambda i : getattr (self .stats [i ], criterion ))
450+ vals = [getattr (stat , criterion ) for stat in self .stats ]
451+ overmax = max ((val for val in vals if val is not None ), default = 0 ) \
452+ + 1
453+ vals = [val if val is not None else overmax for val in vals ]
454+ self .order = sorted (self .order , key = vals .__getitem__ )
452455
453456 heights = 90 if self .show_annotations else 60
454457
@@ -553,6 +556,8 @@ def compute_tests(self):
553556 # The non-parametric tests can't do this, so we use statistics.tests
554557 def stat_ttest ():
555558 d1 , d2 = self .stats
559+ if d1 .n == 0 or d2 .n == 0 :
560+ return np .nan , np .nan
556561 pooled_var = d1 .var / d1 .n + d2 .var / d2 .n
557562 df = pooled_var ** 2 / \
558563 ((d1 .var / d1 .n ) ** 2 / (d1 .n - 1 ) +
@@ -566,6 +571,8 @@ def stat_ttest():
566571 # TODO: Check this function
567572 # noinspection PyPep8Naming
568573 def stat_ANOVA ():
574+ if any (stat .n == 0 for stat in self .stats ):
575+ return np .nan , np .nan
569576 n = sum (stat .n for stat in self .stats )
570577 grand_avg = sum (stat .n * stat .mean for stat in self .stats ) / n
571578 var_between = sum (stat .n * (stat .mean - grand_avg ) ** 2
@@ -892,8 +899,11 @@ def line(y0, y1):
892899 y_up = - len (self .stats ) * height + 10
893900 for pos , box_index in enumerate (self .order ):
894901 stat = self .stats [box_index ]
895- x = getattr (stat , crit_line ) * self .scale_x
896- xs .append (x )
902+ x = getattr (stat , crit_line )
903+ if x is None :
904+ continue
905+ x *= self .scale_x
906+ xs .append (x * self .scale_x )
897907 by = y_up + pos * height
898908 line (by + 12 , 3 )
899909 line (by - 12 , by - 25 )
0 commit comments