Fixed doctests

master
pbrod 9 years ago
parent a472350386
commit 3f187c6a17

@ -243,9 +243,6 @@ def dctn(x, type=2, shape=None, axes=None, # @ReservedAssignment
>>> import matplotlib.pyplot as plt >>> import matplotlib.pyplot as plt
>>> name = os.path.join(path, 'autumn.gif') >>> name = os.path.join(path, 'autumn.gif')
>>> rgb = Image.open(name) >>> rgb = Image.open(name)
>>> np.shape(rgb2)
>>> np.shape(rgb)
>>> J = dctn(rgb) >>> J = dctn(rgb)
>>> (np.abs(rgb-idctn(J))<1e-7).all() >>> (np.abs(rgb-idctn(J))<1e-7).all()
True True

@ -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[0] < 1e-3, terr[0] < 1e-7
True, True True, True
Compute expectation E( X1^{+}*X2^{+} ) with random Compute expectation E( X1^{+}*X2^{+} ) with random

@ -473,10 +473,10 @@ def plotspec(specdata, linetype='b-', flag=1):
# elseif (plotflag==6) || (plotflag==7), # elseif (plotflag==6) || (plotflag==7),
# theta = S.theta-phi; # theta = S.theta-phi;
# [c, h] = contour(freq,theta,S.S); %,Nlevel); % calculate levels # [c, h] = contour(freq,theta,S.S); %,Nlevel); % calculate levels
# fixthetalabels(thmin,thmax,'y',2) % fix yticklabel and ylabel for theta # fixthetalabels(thmin,thmax,'y',2)
# if plotflag==7, # if plotflag==7,
# hold on # hold on
# [c,h] = contourf(freq,theta,S.S); %,Nlevel); % calculate levels # [c,h] = contourf(freq,theta,S.S); %,Nlevel);
# %hold on # %hold on
# end # end
# #
@ -487,7 +487,7 @@ def plotspec(specdata, linetype='b-', flag=1):
# % label the contour levels # % label the contour levels
# if txtFlag==1 # if txtFlag==1
# textstart_x = 0.06; textstart_y=0.94; # textstart_x = 0.06; textstart_y=0.94;
# cltext1(z_level,textstart_x,textstart_y) % a local variant of cltext # cltext1(z_level,textstart_x,textstart_y) #local: cltext
# else # else
# cltext(z_level) # cltext(z_level)
# end # end
@ -1555,7 +1555,7 @@ class SpecData1D(PlotData):
# err = repmat(nan,size(ftmp)) # err = repmat(nan,size(ftmp))
# else # else
ftmp, err, terr, options = self._cov2mmtpdf(R, dt, u, defnr, Nstart, ftmp, err, terr, options = self._cov2mmtpdf(R, dt, u, defnr, Nstart,
hg, options) hg, options)
# end # end
note = '' note = ''
@ -1594,82 +1594,81 @@ class SpecData1D(PlotData):
title = 'Density of (%sdm, %sMm, M = %2.5g, m = %2.5g)_{v=%2.5g}' % ( title = 'Density of (%sdm, %sMm, M = %2.5g, m = %2.5g)_{v=%2.5g}' % (
tmp, tmp, h[1], -h[1], utc) tmp, tmp, h[1], -h[1], utc)
f = PlotData() f = PlotData(data=data, args=args, title=title, labx=labx. laby=laby)
# f.options = options f.options = options
# if defnr>1 or defnr==-2: if defnr>1 or defnr==-2:
# f.u = utc # save level u f.u = utc # save level u
#
# if Nx>2 % amplitude distributions wanted if Nx>2: # amplitude distributions wanted
# f.x{2} = h f.x{2} = h
# f.labx{2} = 'min [m]' f.labx{2} = 'min [m]'
#
#
# if defnr>2 || defnr==1 if defnr>2 || defnr==1
# der0 = der1[:,None] * der[None,:] der0 = der1[:,None] * der[None,:]
# ftmp = np.reshape(ftmp,Nx,Nx,Nt) * der0[:,:, None] / A ftmp = np.reshape(ftmp,Nx,Nx,Nt) * der0[:,:, None] / A
# err = np.reshape(err,Nx,Nx,Nt) * der0[:,:, None] / A err = np.reshape(err,Nx,Nx,Nt) * der0[:,:, None] / A
#
# f.x{3} = t(:)*A f.x{3} = t(:)*A
# labz = 'wave length [m]' if in_space else 'period [sec]' labz = 'wave length [m]' if in_space else 'period [sec]'
#
# else else:
# der0 = der[:,None] * der[None,:] der0 = der[:,None] * der[None,:]
# ftmp = np.reshape(ftmp,Nx,Nx) * der0 ftmp = np.reshape(ftmp,Nx,Nx) * der0
# err = np.reshape(err,Nx,Nx) * der0 err = np.reshape(err,Nx,Nx) * der0
#
# if (defnr==-1): if (defnr==-1):
# ftmp0 = fliplr(mctp2rfc(fliplr(ftmp))) ftmp0 = fliplr(mctp2rfc(fliplr(ftmp)))
# err = abs(ftmp0-fliplr(mctp2rfc(fliplr(ftmp+err)))) err = abs(ftmp0-fliplr(mctp2rfc(fliplr(ftmp+err))))
# ftmp = ftmp0 ftmp = ftmp0
# elif (defnr==-2): elif (defnr==-2):
# ftmp0=fliplr(mctp2tc(fliplr(ftmp),utc,paramu))*sqrt(L4*L0)/L2 ftmp0=fliplr(mctp2tc(fliplr(ftmp),utc,paramu))*sqrt(L4*L0)/L2
# err =abs(ftmp0-fliplr(mctp2tc(fliplr(ftmp+err),utc,paramu))*sqrt(L4*L0)/L2) err =abs(ftmp0-fliplr(mctp2tc(fliplr(ftmp+err),utc,paramu))*sqrt(L4*L0)/L2)
# index1=find(f.x{1}>0) index1=find(f.x{1}>0)
# index2=find(f.x{2}<0) index2=find(f.x{2}<0)
# ftmp=flipud(ftmp0(index2,index1)) ftmp=flipud(ftmp0(index2,index1))
# err =flipud(err(index2,index1)) err =flipud(err(index2,index1))
# f.x{1} = f.x{1}(index1) f.x{1} = f.x{1}(index1)
# f.x{2} = abs(flipud(f.x{2}(index2))) f.x{2} = abs(flipud(f.x{2}(index2)))
# end # end
# end #end
# f.f = ftmp f.f = ftmp
# f.err = err f.err = err
# else % Only time or wave length distributions wanted else: # Only time or wave length distributions wanted
# f.f = ftmp/A f.f = ftmp/A
# f.err = err/A f.err = err/A
# f.x{1}=A*t' f.x{1}=A*t'
# if strcmpi(def(1),'t') if strcmpi(def(1),'t')
# f.labx{1} = 'period [sec]' f.labx{1} = 'period [sec]'
# else else:
# f.labx{1} = 'wave length [m]' f.labx{1} = 'wave length [m]'
# end # end
# if defnr>3, if defnr>3,
# f.f = reshape(f.f,[Nt, Nt]) f.f = reshape(f.f,[Nt, Nt])
# f.err = reshape(f.err,[Nt, Nt]) f.err = reshape(f.err,[Nt, Nt])
# f.x{2}= A*t' f.x{2}= A*t'
# if strcmpi(def(1),'t') if strcmpi(def(1),'t')
# f.labx{2} = 'period [sec]' f.labx{2} = 'period [sec]'
# else else:
# f.labx{2} = 'wave length [m]' f.labx{2} = 'wave length [m]'
# end # end
# end #end
# end #end
#
#
# try try
# [f.cl,f.pl]=qlevels(f.f,[10 30 50 70 90 95 99 99.9],f.x{1},f.x{2}) [f.cl,f.pl]=qlevels(f.f,[10 30 50 70 90 95 99 99.9],f.x{1},f.x{2})
# catch except:
# warning('WAFO:SPEC2MMTPDF','Singularity likely in pdf') warnings.warn('Singularity likely in pdf')
# end
# %pdfplot(f)
# # Test of spec2mmtpdf
# %Test of spec2mmtpdf # cd f:\matlab\matlab\wafo\source\sp2thpdfalan
# % cd f:\matlab\matlab\wafo\source\sp2thpdfalan # addpath f:\matlab\matlab\wafo ,initwafo, addpath f:\matlab\matlab\graphutil
# % addpath f:\matlab\matlab\wafo ,initwafo, addpath f:\matlab\matlab\graphutil # Hm0=7;Tp=11; S = jonswap(4*pi/Tp,[Hm0 Tp])
# % Hm0=7;Tp=11; S = jonswap(4*pi/Tp,[Hm0 Tp]) # ft = spec2mmtpdf(S,0,'vMmTMm',[0.3,.4,11],[0 .00005 2])
# % ft = spec2mmtpdf(S,0,'vMmTMm',[0.3,.4,11],[0 .00005 2])
return f # % main return f
def _cov2mmtpdf(self, R, dt, u, def_nr, Nstart, hg, options): def _cov2mmtpdf(self, R, dt, u, def_nr, Nstart, hg, options):
''' '''

Loading…
Cancel
Save