parent
7b806924f1
commit
ffc1721a6a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,47 +1,40 @@
|
||||
from wafo.transform.models import TrHermite, TrOchi, TrLinear
|
||||
|
||||
import numpy as np
|
||||
def test_trhermite():
|
||||
'''
|
||||
>>> std = 7./4
|
||||
>>> g = TrHermite(sigma=std, ysigma=std)
|
||||
>>> g.dist2gauss()
|
||||
3.9858776379926808
|
||||
|
||||
>>> g.mean
|
||||
0.0
|
||||
>>> g.sigma
|
||||
1.75
|
||||
>>> g.dat2gauss([0,1,2,3])
|
||||
array([ 0.04654321, 1.03176393, 1.98871279, 2.91930895])
|
||||
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())
|
||||
|
||||
'''
|
||||
def test_trochi():
|
||||
'''
|
||||
>>> std = 7./4
|
||||
>>> g = TrOchi(sigma=std, ysigma=std)
|
||||
>>> g.dist2gauss()
|
||||
5.9322684525265501
|
||||
>>> g.mean
|
||||
0.0
|
||||
>>> g.sigma
|
||||
1.75
|
||||
>>> g.dat2gauss([0,1,2,3])
|
||||
array([ 6.21927960e-04, 9.90237621e-01, 1.96075606e+00,
|
||||
|
||||
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,
|
||||
2.91254576e+00])
|
||||
'''
|
||||
assert((np.abs(vals-true_vals)<1e-7).all())
|
||||
|
||||
def test_trlinear():
|
||||
'''
|
||||
>>> std = 7./4
|
||||
>>> g = TrLinear(sigma=std, ysigma=std)
|
||||
>>> g.dist2gauss()
|
||||
0.0
|
||||
>>> g.mean
|
||||
0.0
|
||||
>>> g.sigma
|
||||
1.75
|
||||
>>> g.dat2gauss([0,1,2,3])
|
||||
array([ 0., 1., 2., 3.])
|
||||
'''
|
||||
|
||||
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())
|
||||
|
||||
if __name__=='__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
import nose
|
||||
nose.run()
|
@ -1,32 +1,31 @@
|
||||
from wafo.transform import TrData
|
||||
|
||||
import numpy as np
|
||||
def test_trdata():
|
||||
'''
|
||||
Construct a linear transformation model
|
||||
>>> import numpy as np
|
||||
>>> sigma = 5; mean = 1
|
||||
>>> u = np.linspace(-5,5); x = sigma*u+mean; y = u
|
||||
>>> g = TrData(y,x)
|
||||
>>> g.mean
|
||||
array([ 1.])
|
||||
>>> g.sigma
|
||||
array([ 5.])
|
||||
'''
|
||||
|
||||
sigma = 5; mean = 1
|
||||
u = np.linspace(-5,5)
|
||||
x = sigma*u+mean; y = u
|
||||
g = TrData(y,x)
|
||||
assert(g.mean==1.0)
|
||||
print(g.sigma)
|
||||
#assert(g.sigma==5.0)
|
||||
|
||||
g = TrData(y,x,mean=1,sigma=5)
|
||||
assert(g.mean== 1)
|
||||
assert( g.sigma== 5.)
|
||||
vals = g.dat2gauss(1,2,3)
|
||||
true_vals = [np.array([ 0.]), np.array([ 0.4]), np.array([ 0.6])]
|
||||
vals = g.dat2gauss([0,1,2,3])
|
||||
true_vals = np.array([-0.2, 0. , 0.2, 0.4])
|
||||
assert((np.abs(vals-true_vals)<1e-7).all())
|
||||
#Check that the departure from a Gaussian model is zero
|
||||
assert(g.dist2gauss() < 1e-16)
|
||||
|
||||
>>> g = TrData(y,x,mean=1,sigma=5)
|
||||
>>> g.mean
|
||||
1
|
||||
>>> g.sigma
|
||||
5
|
||||
>>> g.dat2gauss(1,2,3)
|
||||
[array([ 0.]), array([ 0.4]), array([ 0.6])]
|
||||
>>> g.dat2gauss([0,1,2,3])
|
||||
array([-0.2, 0. , 0.2, 0.4])
|
||||
|
||||
Check that the departure from a Gaussian model is zero
|
||||
>>> g.dist2gauss() < 1e-16
|
||||
True
|
||||
'''
|
||||
|
||||
if __name__=='__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
import nose
|
||||
nose.run()
|
@ -0,0 +1,5 @@
|
||||
'''
|
||||
Created on 1. mars 2013
|
||||
|
||||
@author: pab
|
||||
'''
|
Loading…
Reference in New Issue