def run_group_significance_test(data_generator, test, test_choices, reps=1000):
 (pvals, test_stats, means) = ([], [], [])
 for row in data_generator:
  if (test == 'nonparametric_t_test'):
   (test_stat, _, _, pval) = test_choices[test](row[0], row[1], permutations=reps)
  elif (test == 'bootstrap_mann_whitney_u'):
   (test_stat, pval) = test_choices[test](row[0], row[1], num_reps=reps)
  elif (test in ['parametric_t_test', 'mann_whitney_u']):
   (test_stat, pval) = test_choices[test](row[0], row[1])
  else:
   try:
    (test_stat, pval) = test_choices[test](row)
   except ValueError:
    test_stat = nan
    pval = nan
  test_stats.append(test_stat)
  pvals.append(pval)
  means.append([i.mean() for i in row])
 return (test_stats, pvals, means)

def run_group_significance_test ( data_generator , test , test_choices , reps = 1000 ) : ( pvals , test_stats , means ) = ( [ ] , [ ] , [ ] ) for row in data_generator : if ( test == 'nonparametric_t_test' ) : ( test_stat , _ , _ , pval ) = test_choices [ test ] ( row [ 0 ] , row [ 1 ] , permutations = reps ) elif ( test == 'bootstrap_mann_whitney_u' ) : ( test_stat , pval ) = test_choices [ test ] ( row [ 0 ] , row [ 1 ] , num_reps = reps ) elif ( test in [ 'parametric_t_test' , 'mann_whitney_u' ] ) : ( test_stat , pval ) = test_choices [ test ] ( row [ 0 ] , row [ 1 ] ) else : try : ( test_stat , pval ) = test_choices [ test ] ( row ) except ValueError : test_stat = nan pval = nan test_stats . append ( test_stat ) pvals . append ( pval ) means . append ( [ i . mean ( ) for i in row ] ) return ( test_stats , pvals , means )
run any of the group significance tests .