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
|
from wafo.transform.models import TrHermite, TrOchi, TrLinear
|
||||||
|
import numpy as np
|
||||||
def test_trhermite():
|
def test_trhermite():
|
||||||
'''
|
|
||||||
>>> std = 7./4
|
|
||||||
>>> g = TrHermite(sigma=std, ysigma=std)
|
|
||||||
>>> g.dist2gauss()
|
|
||||||
3.9858776379926808
|
|
||||||
|
|
||||||
>>> g.mean
|
std = 7./4
|
||||||
0.0
|
g = TrHermite(sigma=std, ysigma=std)
|
||||||
>>> g.sigma
|
assert(np.abs(g.dist2gauss()- 0.88230868748851554)<1e-7)
|
||||||
1.75
|
|
||||||
>>> g.dat2gauss([0,1,2,3])
|
assert( g.mean == 0.0)
|
||||||
array([ 0.04654321, 1.03176393, 1.98871279, 2.91930895])
|
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():
|
def test_trochi():
|
||||||
'''
|
|
||||||
>>> std = 7./4
|
std = 7./4
|
||||||
>>> g = TrOchi(sigma=std, ysigma=std)
|
g = TrOchi(sigma=std, ysigma=std)
|
||||||
>>> g.dist2gauss()
|
assert(g.dist2gauss()== 1.4106988010566603)
|
||||||
5.9322684525265501
|
assert(g.mean== 0.0)
|
||||||
>>> g.mean
|
assert(g.sigma==1.75)
|
||||||
0.0
|
vals = g.dat2gauss([0,1,2,3])
|
||||||
>>> g.sigma
|
true_vals = np.array([ 6.21927960e-04, 9.90237621e-01, 1.96075606e+00,
|
||||||
1.75
|
|
||||||
>>> g.dat2gauss([0,1,2,3])
|
|
||||||
array([ 6.21927960e-04, 9.90237621e-01, 1.96075606e+00,
|
|
||||||
2.91254576e+00])
|
2.91254576e+00])
|
||||||
'''
|
assert((np.abs(vals-true_vals)<1e-7).all())
|
||||||
|
|
||||||
def test_trlinear():
|
def test_trlinear():
|
||||||
'''
|
|
||||||
>>> std = 7./4
|
std = 7./4
|
||||||
>>> g = TrLinear(sigma=std, ysigma=std)
|
g = TrLinear(sigma=std, ysigma=std)
|
||||||
>>> g.dist2gauss()
|
assert(g.dist2gauss() == 0.0)
|
||||||
0.0
|
assert(g.mean == 0.0)
|
||||||
>>> g.mean
|
assert(g.sigma== 1.75)
|
||||||
0.0
|
vals = g.dat2gauss([0,1,2,3])
|
||||||
>>> g.sigma
|
true_vals = np.array([ 0., 1., 2., 3.])
|
||||||
1.75
|
assert((np.abs(vals-true_vals)<1e-7).all())
|
||||||
>>> g.dat2gauss([0,1,2,3])
|
|
||||||
array([ 0., 1., 2., 3.])
|
|
||||||
'''
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
import doctest
|
import nose
|
||||||
doctest.testmod()
|
nose.run()
|
@ -1,32 +1,31 @@
|
|||||||
from wafo.transform import TrData
|
from wafo.transform import TrData
|
||||||
|
import numpy as np
|
||||||
def test_trdata():
|
def test_trdata():
|
||||||
'''
|
'''
|
||||||
Construct a linear transformation model
|
Construct a linear transformation model
|
||||||
>>> import numpy as np
|
'''
|
||||||
>>> sigma = 5; mean = 1
|
|
||||||
>>> u = np.linspace(-5,5); x = sigma*u+mean; y = u
|
sigma = 5; mean = 1
|
||||||
>>> g = TrData(y,x)
|
u = np.linspace(-5,5)
|
||||||
>>> g.mean
|
x = sigma*u+mean; y = u
|
||||||
array([ 1.])
|
g = TrData(y,x)
|
||||||
>>> g.sigma
|
assert(g.mean==1.0)
|
||||||
array([ 5.])
|
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__':
|
if __name__=='__main__':
|
||||||
import doctest
|
import nose
|
||||||
doctest.testmod()
|
nose.run()
|
@ -0,0 +1,5 @@
|
|||||||
|
'''
|
||||||
|
Created on 1. mars 2013
|
||||||
|
|
||||||
|
@author: pab
|
||||||
|
'''
|
Loading…
Reference in New Issue