@@ -460,7 +460,7 @@ def __init__(self, control, test, effect_size,
460460 'statistic_wilcoxon': nan}
461461 """
462462
463- from numpy import array , isnan
463+ from numpy import array , isnan , isinf
464464 from numpy import sort as npsort
465465 from numpy .random import choice , seed
466466
@@ -522,6 +522,20 @@ def __init__(self, control, test, effect_size,
522522 control , test , is_paired , effect_size ,
523523 resamples , random_seed )
524524 self .__bootstraps = npsort (bootstraps )
525+
526+ # Added in v0.2.6.
527+ # Raises a UserWarning if there are any infiinities in the bootstraps.
528+ num_infinities = len (self .__bootstraps [isinf (self .__bootstraps )])
529+
530+ if num_infinities > 0 :
531+ warn_msg = "There are {} bootstrap(s) that are not defined. " \
532+ "This is likely due to smaple sample sizes. " \
533+ "The values in a bootstrap for a group will be more likely " \
534+ "to be all equal, with a resulting variance of zero. " \
535+ "The computation of Cohen's d and Hedges' g thus " \
536+ "involved a division by zero. "
537+ warnings .warn (warn_msg .format (num_infinities ),
538+ category = UserWarning )
525539
526540 self .__bias_correction = ci2g .compute_meandiff_bias_correction (
527541 self .__bootstraps , self .__difference )
0 commit comments