Made doctests more robust.

master
Per A Brodtkorb 6 years ago
parent 61c1d8e650
commit 75591fcd3e

@ -187,8 +187,9 @@ class PlotData(object):
>>> y = np.sin(x)
>>> ci = PlotData(np.vstack((y*.9, y*1.1)).T, x)
>>> d = PlotData(y, x, children=[ci])
>>> d.integrate(0, np.pi/2, return_ci=True)
array([ 0.99940055, 0.89946049, 1.0993406 ])
>>> np.allclose(d.integrate(0, np.pi/2, return_ci=True),
... [ 0.99940055, 0.89946049, 1.0993406 ])
True
>>> np.allclose(d.integrate(0, 5, return_ci=True),
... d.integrate(return_ci=True))
True
@ -209,7 +210,7 @@ class PlotData(object):
return res
def _plot_children(self, axis, plotflag, kwds):
axis.hold('on')
# axis.hold('on')
tmp = []
child_args = kwds.pop('plot_args_children',
tuple(self.plot_args_children))
@ -413,7 +414,7 @@ def plot1d(axis, args, data, dataCI, plotflag, *varargin, **kwds):
plotfun = getattr(axis, fun)
h.extend(plotfun(args, data, *varargin, **kwds))
if np.any(dataCI) and plottype < 3:
axis.hold(True)
# axis.hold(True)
h.extend(plotfun(args, dataCI, 'r--'))
elif plottype == 4:
h = axis.errorbar(args, data,

@ -95,10 +95,10 @@ def dct(x, type=2, n=None, axis=-1, norm='ortho'): # @ReservedAssignment
--------
>>> import numpy as np
>>> x = np.arange(5)
>>> np.abs(x-idct(dct(x)))<1e-14
array([ True, True, True, True, True], dtype=bool)
>>> np.abs(x-dct(idct(x)))<1e-14
array([ True, True, True, True, True], dtype=bool)
>>> np.allclose(x, idct(dct(x)))
True
>>> np.allclose(x, dct(idct(x)))
True
References
----------

@ -705,8 +705,8 @@ def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
... [0.0019456719705212067, 1.0059406844578488e-05, 0])
True
>>> np.abs(val-Et)< err0+terr0
array([ True], dtype=bool)
>>> np.allclose(np.abs(val-Et) < err0+terr0, True)
True
>>> 'val = %2.5f' % val
'val = 0.00195'

@ -453,8 +453,8 @@ def la_roots(n, alpha=0, method='newton'):
-------
>>> import numpy as np
>>> [x,w] = h_roots(10)
>>> np.sum(x*w)
1.3352627380516791e-17
>>> np.allclose(np.sum(x*w) < 1e-16, True)
True
See also
--------

@ -273,18 +273,18 @@ def lazyselect(condlist, choicelist, arrays, default=0):
Examples
--------
>>> x = np.arange(6)
>>> np.select([x <3, x > 3], [x**2, x**3], default=0)
array([ 0, 1, 4, 0, 64, 125])
>>> lazyselect([x < 3, x > 3], [lambda x: x**2, lambda x: x**3], (x,))
array([ 0., 1., 4., 0., 64., 125.])
>>> np.allclose(np.select([x <3, x > 3], [x**2, x**3], default=0),
... [ 0, 1, 4, 0, 64, 125])
True
>>> np.allclose(lazyselect([x < 3, x > 3], [lambda x: x**2, lambda x: x**3], (x,)),
... [ 0., 1., 4., 0., 64., 125.])
True
>>> a = -np.ones_like(x)
>>> lazyselect([x < 3, x > 3],
... [lambda x, a: x**2, lambda x, a: a * x**3],
... (x, a))
array([ 0., 1., 4., 0., -64., -125.])
>>> np.allclose(lazyselect([x < 3, x > 3],
... [lambda x, a: x**2, lambda x, a: a * x**3],
... (x, a)),
... [ 0., 1., 4., 0., -64., -125.])
True
"""
arrays = np.broadcast_arrays(*arrays)
tcode = np.mintypecode([a.dtype.char for a in arrays])
@ -1185,6 +1185,8 @@ def findrfc(tp, h=0.0, method='clib'):
ind, ix = clib.findrfc(y, h)
ix = int(ix)
else:
if isinstance(method, str):
method = 2
ind = numba_misc.findrfc(y, h, method)
ix = len(ind)
@ -1909,8 +1911,8 @@ def betaloge(z, w):
Example
-------
>>> import wafo.misc as wm
>>> np.abs(wm.betaloge(3,2)+2.48490665)<1e-7
array([ True], dtype=bool)
>>> np.allclose(wm.betaloge(3,2), -2.48490665)
True
See also
--------

@ -1248,8 +1248,8 @@ class SpecData1D(PlotData):
if paramt is None:
# (2.5 * mean distance between extremes)
distanceBetweenExtremes = 5 * pi * sqrt(m[1] / m[2])
paramt = [0, distanceBetweenExtremes, 43]
distance_between_extremes = 5 * pi * sqrt(m[1] / m[2])
paramt = [0, distance_between_extremes, 43]
if paramu is None:
paramu = [-5 * sqrt(m[0]), 5 * sqrt(m[0]), 41]

Loading…
Cancel
Save