def check_1D_array(self): a = array((1,2,3,4), float64) actual= stats.hmean(a) desired = 4. / (1./1 + 1./2 + 1./3 + 1./4) assert_almost_equal(desired,actual,decimal=14) desired1 = stats.hmean(a,axis=-1) assert_almost_equal(desired1,actual,decimal=14)
def check_2D_array_default(self): a = array(((1,2,3,4), (1,2,3,4), (1,2,3,4))) actual = stats.hmean(a) desired = array((1.,2.,3.,4.)) assert_array_almost_equal(desired,actual,decimal=14) actual1 = stats.hmean(a,axis=0) assert_array_almost_equal(desired,actual1,decimal=14)
def check_2D_array_dim1(self): a = array(((1,2,3,4), (1,2,3,4), (1,2,3,4))) v = 4. / (1./1 + 1./2 + 1./3 + 1./4) desired1 = array((v,v,v)) actual1 = stats.hmean(a, axis=1) assert_array_almost_equal(desired1,actual1,decimal=14)