diff --git a/wafo/demo_sg.py b/wafo/demo_sg.py index ac9a843..178a5b5 100644 --- a/wafo/demo_sg.py +++ b/wafo/demo_sg.py @@ -1,7 +1,7 @@ import matplotlib.pyplot as plt from pylab import subplot, plot, title, figure from numpy import random, arange, sin -from sg_filter import SavitzkyGolay, smoothn # calc_coeff, smooth +from .sg_filter import SavitzkyGolay, smoothn # calc_coeff, smooth def example_reconstruct_noisy_chirp(): diff --git a/wafo/demos.py b/wafo/demos.py index 14ad6dd..2d73dd1 100644 --- a/wafo/demos.py +++ b/wafo/demos.py @@ -17,24 +17,27 @@ def magic(n): Examples -------- - >>> magic(3) - array([[8, 1, 6], - [3, 5, 7], - [4, 9, 2]]) - - >>> magic(4) - array([[16, 2, 3, 13], - [ 5, 11, 10, 8], - [ 9, 7, 6, 12], - [ 4, 14, 15, 1]]) - - >>> magic(6) - array([[35, 1, 6, 26, 19, 24], - [ 3, 32, 7, 21, 23, 25], - [31, 9, 2, 22, 27, 20], - [ 8, 28, 33, 17, 10, 15], - [30, 5, 34, 12, 14, 16], - [ 4, 36, 29, 13, 18, 11]]) + >>> np.allclose(magic(3), + ... [[8, 1, 6], + ... [3, 5, 7], + ... [4, 9, 2]]) + True + + >>> np.allclose(magic(4), + ... [[16, 2, 3, 13], + ... [ 5, 11, 10, 8], + ... [ 9, 7, 6, 12], + ... [ 4, 14, 15, 1]]) + True + + >>> np.allclose(magic(6), + ... [[35, 1, 6, 26, 19, 24], + ... [ 3, 32, 7, 21, 23, 25], + ... [31, 9, 2, 22, 27, 20], + ... [ 8, 28, 33, 17, 10, 15], + ... [30, 5, 34, 12, 14, 16], + ... [ 4, 36, 29, 13, 18, 11]]) + True ''' if (n < 3): raise ValueError('n must be greater than 2.') diff --git a/wafo/interpolate.py b/wafo/interpolate.py index 7250451..c8395fb 100644 --- a/wafo/interpolate.py +++ b/wafo/interpolate.py @@ -7,7 +7,7 @@ import scipy.sparse as sparse from numpy import ones, zeros, prod, sin, diff, pi, inf, vstack, linspace from scipy.interpolate import PiecewisePolynomial, interp1d -from . import polynomial as pl +from wafo import polynomial as pl __all__ = [ @@ -1015,7 +1015,8 @@ class StinemanInterp2(PiecewisePolynomial): def __init__(self, x, y, yp=None, method='parabola', monotone=False): if yp is None: yp = slopes(x, y, method, monotone=monotone) - super(StinemanInterp2, self).__init__(x, zip(y, yp)) + yyp = [z for z in zip(y, yp)] + super(StinemanInterp2, self).__init__(x, yyp) class CubicHermiteSpline(PiecewisePolynomial): @@ -1028,7 +1029,8 @@ class CubicHermiteSpline(PiecewisePolynomial): def __init__(self, x, y, yp=None, method='Catmull-Rom'): if yp is None: yp = slopes(x, y, method, monotone=False) - super(CubicHermiteSpline, self).__init__(x, zip(y, yp), orders=3) + yyp = [z for z in zip(y, yp)] + super(CubicHermiteSpline, self).__init__(x, yyp, orders=3) class Pchip(PiecewisePolynomial): @@ -1127,7 +1129,8 @@ class Pchip(PiecewisePolynomial): def __init__(self, x, y, yp=None, method='secant'): if yp is None: yp = slopes(x, y, method=method, monotone=True) - super(Pchip, self).__init__(x, zip(y, yp), orders=3) + yyp = [z for z in zip(y, yp)] + super(Pchip, self).__init__(x, yyp, orders=3) def interp3(x, y, z, v, xi, yi, zi, method='cubic'): diff --git a/wafo/kdetools.py b/wafo/kdetools.py index 6a750eb..34f6900 100644 --- a/wafo/kdetools.py +++ b/wafo/kdetools.py @@ -2819,7 +2819,7 @@ def _compute_qth_weighted_percentile(a, q, axis, out, method, weights, if axis is None: sorted_ = a.ravel() else: - taxes = range(a.ndim) + taxes = [i for i in range(a.ndim)] taxes[-1], taxes[axis] = taxes[axis], taxes[-1] sorted_ = np.transpose(a, taxes).reshape(-1, shape0[axis]) diff --git a/wafo/misc.py b/wafo/misc.py index ce34e4e..4aa96a6 100644 --- a/wafo/misc.py +++ b/wafo/misc.py @@ -584,8 +584,8 @@ def sub_dict_select(somedict, somekeys): >>> kwds = dict(arg2=100,arg3=1000) >>> sub_dict = sub_dict_select(kwds,opt.keys()) >>> opt.update(sub_dict) - >>> opt - {'arg1': 2, 'arg2': 100} + >>> opt == {'arg1': 2, 'arg2': 100} + True See also -------- diff --git a/wafo/objects.py b/wafo/objects.py index ab212f6..2fba80c 100644 --- a/wafo/objects.py +++ b/wafo/objects.py @@ -1595,13 +1595,13 @@ class TimeSeries(PlotData): >>> for i in range(-3,4): ... S, H = ts.wave_height_steepness(method=i) ... print(S[:2],H[:2]) - (array([ 0.01186982, 0.04852534]), array([ 0.69, 0.86])) - (array([ 0.02918363, 0.06385979]), array([ 0.69, 0.86])) - (array([ 0.27797411, 0.33585743]), array([ 0.69, 0.86])) - (array([ 0.60835634, 0.60930197]), array([ 0.42, 0.78])) - (array([ 0.60835634, 0.60930197]), array([ 0.42, 0.78])) - (array([ 0.10140867, 0.06141156]), array([ 0.42, 0.78])) - (array([ 0.01821413, 0.01236672]), array([ 0.42, 0.78])) + [ 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] import pylab as plt h = plt.plot(S,H,'.') diff --git a/wafo/sg_filter.py b/wafo/sg_filter.py index 8c4105d..ad05428 100644 --- a/wafo/sg_filter.py +++ b/wafo/sg_filter.py @@ -6,8 +6,8 @@ from numpy import (pi, abs, size, convolve, linalg, concatenate, sqrt) from scipy.sparse import spdiags from scipy.sparse.linalg import spsolve, expm from scipy.signal import medfilt -from wafo.dctpack import dctn, idctn -from wafo.plotbackend import plotbackend as plt +from .dctpack import dctn, idctn +from .plotbackend import plotbackend as plt import scipy.optimize as optimize from scipy.signal import _savitzky_golay from scipy.ndimage import convolve1d