Fixed doctests

master
pbrod 9 years ago
parent 2e1ace8a5f
commit 46d18708e4

@ -602,8 +602,8 @@ def parse_kwargs(options, **kwargs):
Example Example
>>> opt = dict(arg1=2, arg2=3) >>> opt = dict(arg1=2, arg2=3)
>>> opt = parse_kwargs(opt,arg2=100) >>> opt = parse_kwargs(opt,arg2=100)
>>> print(opt) >>> opt == {'arg1': 2, 'arg2': 100}
{'arg1': 2, 'arg2': 100} True
>>> opt2 = dict(arg2=101) >>> opt2 = dict(arg2=101)
>>> opt = parse_kwargs(opt,**opt2) >>> opt = parse_kwargs(opt,**opt2)
@ -1005,9 +1005,9 @@ def findrfc_astm(tp):
# the sig_rfc was constructed too big in rainflow.rf3, so # the sig_rfc was constructed too big in rainflow.rf3, so
# reduce the sig_rfc array as done originally by a matlab mex c function # reduce the sig_rfc array as done originally by a matlab mex c function
n = len(sig_rfc) n = len(sig_rfc)
sig_rfc = sig_rfc.__getslice__(0, n - cnr[0]) # sig_rfc = sig_rfc.__getslice__(0, n - cnr[0])
# sig_rfc holds the actual rainflow counted cycles, not the indices # sig_rfc holds the actual rainflow counted cycles, not the indices
return sig_rfc return sig_rfc[:n - cnr[0]]
def findrfc(tp, h=0.0, method='clib'): def findrfc(tp, h=0.0, method='clib'):

@ -1505,16 +1505,24 @@ class TimeSeries(PlotData):
>>> x = wd.sea() >>> x = wd.sea()
>>> ts = wo.mat2timeseries(x) >>> ts = wo.mat2timeseries(x)
>>> wp = ts.wave_parameters() >>> wp = ts.wave_parameters()
>>> true_wp = {'Ac':[ 0.25950546, 0.34950546],
... 'At': [ 0.16049454, 0.43049454],
... 'Hu': [ 0.69, 0.86],
... 'Hd': [ 0.42, 0.78],
... 'Tu': [ 6.10295202, 3.36978685],
... 'Td': [ 3.84377468, 6.35707656],
... 'Tcf': [ 0.42656819, 0.57361617],
... 'Tcb': [ 0.93355982, 1.04063638]}
>>> for name in ['Ac', 'At', 'Hu', 'Hd', 'Tu', 'Td', 'Tcf', 'Tcb']: >>> for name in ['Ac', 'At', 'Hu', 'Hd', 'Tu', 'Td', 'Tcf', 'Tcb']:
... print('%s' % name, wp[name][:2]) ... np.allclose(wp[name][:2], true_wp[name])
('Ac', array([ 0.25950546, 0.34950546])) True
('At', array([ 0.16049454, 0.43049454])) True
('Hu', array([ 0.69, 0.86])) True
('Hd', array([ 0.42, 0.78])) True
('Tu', array([ 6.10295202, 3.36978685])) True
('Td', array([ 3.84377468, 6.35707656])) True
('Tcf', array([ 0.42656819, 0.57361617])) True
('Tcb', array([ 0.93355982, 1.04063638])) True
import pylab as plt import pylab as plt
h = plt.plot(wp['Td'],wp['Hd'],'.') h = plt.plot(wp['Td'],wp['Hd'],'.')

Loading…
Cancel
Save