updated doctests

master
pbrod 9 years ago
parent 3bff71dfdd
commit 29dd646091

@ -112,7 +112,7 @@ class Rind(object):
>>> val, err, terr = rind(Sc,m,Blo,Bup,indI, xc, nt=0) >>> val, err, terr = rind(Sc,m,Blo,Bup,indI, xc, nt=0)
>>> np.allclose(val, 0.05494076, rtol=1e-2) >>> np.allclose(val, 0.05494076, rtol=1e-2)
True True
>>> err < 1e-3, terr< 1e-7 >>> err < 1e-3, terr< 1e-7
True, True True, True
Compute expectation E( X1^{+}*X2^{+} ) with random Compute expectation E( X1^{+}*X2^{+} ) with random

@ -1592,16 +1592,24 @@ class TimeSeries(PlotData):
>>> import wafo.objects as wo >>> import wafo.objects as wo
>>> x = wd.sea() >>> x = wd.sea()
>>> ts = wo.mat2timeseries(x) >>> ts = wo.mat2timeseries(x)
>>> true_SH = [
... [[ 0.01186982, 0.04852534], [ 0.69, 0.86]],
... [[ 0.02918363, 0.06385979], [ 0.69, 0.86]],
... [[ 0.27797411, 0.33585743], [ 0.69, 0.86]],
... [[ 0.60835634, 0.60930197], [ 0.42, 0.78]],
... [[ 0.60835634, 0.60930197], [ 0.42, 0.78]],
... [[ 0.10140867, 0.06141156], [ 0.42, 0.78]],
... [[ 0.01821413, 0.01236672], [ 0.42, 0.78]]]
>>> for i in range(-3,4): >>> for i in range(-3,4):
... S, H = ts.wave_height_steepness(method=i) ... S, H = ts.wave_height_steepness(method=i)
... print(S[:2],H[:2]) ... np.allclose((S[:2],H[:2]), true_SH[i+3])
[ 0.01186982 0.04852534]), [ 0.69, 0.86] True
[ 0.02918363, 0.06385979]) [ 0.69, 0.86] True
[ 0.27797411, 0.33585743]) [ 0.69, 0.86] True
[ 0.60835634, 0.60930197]) [ 0.42, 0.78] True
[ 0.60835634, 0.60930197]) [ 0.42, 0.78] True
[ 0.10140867, 0.06141156]) [ 0.42, 0.78] True
[ 0.01821413, 0.01236672]) [ 0.42, 0.78] True
import pylab as plt import pylab as plt
h = plt.plot(S,H,'.') h = plt.plot(S,H,'.')

@ -583,7 +583,8 @@ class TestPiecewise(TestCase):
x = np.linspace(-2, 2, 5) x = np.linspace(-2, 2, 5)
X, Y = np.meshgrid(x, x) X, Y = np.meshgrid(x, x)
vals = piecewise([X * Y < -0.5, X * Y > 0.5], vals = piecewise([X * Y < -0.5, X * Y > 0.5],
[lambda x, y: -x * y, lambda x, y: x * y, np.nan], (X, Y)) [lambda x, y: -x * y, lambda x, y: x * y, np.nan],
(X, Y))
nan = np.nan nan = np.nan
assert_array_equal(vals, [[4., 2., nan, 2., 4.], assert_array_equal(vals, [[4., 2., nan, 2., 4.],
[2., 1., nan, 1., 2.], [2., 1., nan, 1., 2.],

@ -397,8 +397,8 @@ class TransformEstimator(object):
141 141
>>> int(g0emp.dist2gauss()*100)>17000 >>> int(g0emp.dist2gauss()*100)>17000
True True
>>> int(g0.dist2gauss()*100) >>> int(g0.dist2gauss()*100) > 90
93 True
>>> int(g1.dist2gauss()*100) >>> int(g1.dist2gauss()*100)
66 66
>>> int(g2.dist2gauss()*100) >>> int(g2.dist2gauss()*100)

Loading…
Cancel
Save