def _tstat_generic(value1, value2, std_diff, dof, alternative, diff=0):
 tstat = (((value1 - value2) - diff) / std_diff)
 if (alternative in ['two-sided', '2-sided', '2s']):
  pvalue = (stats.t.sf(np.abs(tstat), dof) * 2)
 elif (alternative in ['larger', 'l']):
  pvalue = stats.t.sf(tstat, dof)
 elif (alternative in ['smaller', 's']):
  pvalue = stats.t.cdf(tstat, dof)
 else:
  raise ValueError('invalid alternative')
 return (tstat, pvalue)

def _tstat_generic ( value1 , value2 , std_diff , dof , alternative , diff = 0 ) : tstat = ( ( ( value1 - value2 ) - diff ) / std_diff ) if ( alternative in [ 'two-sided' , '2-sided' , '2s' ] ) : pvalue = ( stats . t . sf ( np . abs ( tstat ) , dof ) * 2 ) elif ( alternative in [ 'larger' , 'l' ] ) : pvalue = stats . t . sf ( tstat , dof ) elif ( alternative in [ 'smaller' , 's' ] ) : pvalue = stats . t . cdf ( tstat , dof ) else : raise ValueError ( 'invalid alternative' ) return ( tstat , pvalue )
generic ttest to save typing .