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

def _zstat_generic ( value1 , value2 , std_diff , alternative , diff = 0 ) : zstat = ( ( ( value1 - value2 ) - diff ) / std_diff ) if ( alternative in [ 'two-sided' , '2-sided' , '2s' ] ) : pvalue = ( stats . norm . sf ( np . abs ( zstat ) ) * 2 ) elif ( alternative in [ 'larger' , 'l' ] ) : pvalue = stats . norm . sf ( zstat ) elif ( alternative in [ 'smaller' , 's' ] ) : pvalue = stats . norm . cdf ( zstat ) else : raise ValueError ( 'invalid alternative' ) return ( zstat , pvalue )
generic z-test to save typing can be used as ztest based on summary statistics .