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.
31 lines
821 B
Python
31 lines
821 B
Python
15 years ago
|
from wafo.transform import TrData
|
||
12 years ago
|
import numpy as np
|
||
15 years ago
|
def test_trdata():
|
||
|
'''
|
||
|
Construct a linear transformation model
|
||
12 years ago
|
'''
|
||
|
|
||
|
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)
|
||
15 years ago
|
|
||
|
|
||
|
|
||
|
if __name__=='__main__':
|
||
12 years ago
|
import nose
|
||
|
nose.run()
|