You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
15 years ago
|
from wafo.transform.models import TrHermite, TrOchi, TrLinear
|
||
12 years ago
|
import numpy as np
|
||
15 years ago
|
def test_trhermite():
|
||
|
|
||
12 years ago
|
std = 7./4
|
||
|
g = TrHermite(sigma=std, ysigma=std)
|
||
|
assert(np.abs(g.dist2gauss()- 0.88230868748851554)<1e-7)
|
||
|
|
||
|
assert( g.mean == 0.0)
|
||
|
assert(g.sigma == 1.75)
|
||
|
vals = g.dat2gauss([0,1,2,3])
|
||
|
true_vals = np.array([ 0.04654321, 1.03176393, 1.98871279, 2.91930895])
|
||
|
assert((np.abs(vals-true_vals)<1e-7).all())
|
||
15 years ago
|
|
||
|
def test_trochi():
|
||
12 years ago
|
|
||
|
std = 7./4
|
||
|
g = TrOchi(sigma=std, ysigma=std)
|
||
|
assert(g.dist2gauss()== 1.4106988010566603)
|
||
|
assert(g.mean== 0.0)
|
||
|
assert(g.sigma==1.75)
|
||
|
vals = g.dat2gauss([0,1,2,3])
|
||
|
true_vals = np.array([ 6.21927960e-04, 9.90237621e-01, 1.96075606e+00,
|
||
15 years ago
|
2.91254576e+00])
|
||
12 years ago
|
assert((np.abs(vals-true_vals)<1e-7).all())
|
||
|
|
||
15 years ago
|
def test_trlinear():
|
||
12 years ago
|
|
||
|
std = 7./4
|
||
|
g = TrLinear(sigma=std, ysigma=std)
|
||
|
assert(g.dist2gauss() == 0.0)
|
||
|
assert(g.mean == 0.0)
|
||
|
assert(g.sigma== 1.75)
|
||
|
vals = g.dat2gauss([0,1,2,3])
|
||
|
true_vals = np.array([ 0., 1., 2., 3.])
|
||
|
assert((np.abs(vals-true_vals)<1e-7).all())
|
||
|
|
||
15 years ago
|
if __name__=='__main__':
|
||
12 years ago
|
import nose
|
||
|
nose.run()
|