From b0fde67abc105940d6e4457d545478b53a3a4107 Mon Sep 17 00:00:00 2001 From: Per A Brodtkorb Date: Mon, 20 Feb 2017 18:47:44 +0100 Subject: [PATCH] Fixed TypeError: Non-integers used as index values --- wafo/gaussian.py | 3 ++- wafo/sg_filter/_core.py | 2 +- wafo/spectrum/core.py | 6 +++--- wafo/tests/test_gaussian.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/wafo/gaussian.py b/wafo/gaussian.py index e77d260..c961a80 100644 --- a/wafo/gaussian.py +++ b/wafo/gaussian.py @@ -91,8 +91,9 @@ class Rind(object): Cov(Xi,Xj) = 0.3 for i~=j and Cov(Xi,Xi) = 1 otherwise >>> import wafo.gaussian as wg + >>> import numpy as np >>> n = 5 - >>> Blo =-np.inf; Bup=-1.2; indI=[-1, n-1] # Barriers + >>> Blo =-np.inf; Bup=-1.2; indI=np.array([-1, n-1], dtype=int) # Barriers >>> m = np.zeros(n); rho = 0.3; >>> Sc =(np.ones((n,n))-np.eye(n))*rho+np.eye(n) >>> rind = wg.Rind() diff --git a/wafo/sg_filter/_core.py b/wafo/sg_filter/_core.py index aa4c942..454a404 100644 --- a/wafo/sg_filter/_core.py +++ b/wafo/sg_filter/_core.py @@ -248,7 +248,7 @@ def evar(y): sh0 = y.shape S = np.zeros(sh0) - sh1 = np.ones((d,)) + sh1 = np.ones((d,), dtype=np.int64) cos = np.cos for i in range(d): ni = sh0[i] diff --git a/wafo/spectrum/core.py b/wafo/spectrum/core.py index d4909cf..16e111b 100644 --- a/wafo/spectrum/core.py +++ b/wafo/spectrum/core.py @@ -758,16 +758,16 @@ class SpecData1D(PlotData): raise ValueError(txt) if rate is None: - rate = 1 # %interpolation rate + rate = 1 # interpolation rate elif rate > 16: rate = 16 else: # make sure rate is a power of 2 rate = 2 ** nextpow2(rate) if nt is None: - nt = rate * (n_f - 1) + nt = int(rate * (n_f - 1)) else: # check if Nt is ok - nt = minimum(nt, rate * (n_f - 1)) + nt = int(minimum(nt, rate * (n_f - 1))) spec = self.copy() diff --git a/wafo/tests/test_gaussian.py b/wafo/tests/test_gaussian.py index 066e150..e043a5f 100644 --- a/wafo/tests/test_gaussian.py +++ b/wafo/tests/test_gaussian.py @@ -17,7 +17,7 @@ def test_rind(): n = 5 Blo = -np.inf Bup = -1.2 - indI = [-1, n - 1] # Barriers + indI = np.array([-1, n - 1], dtype=int) # Barriers m = np.zeros(n) rho = 0.3 Sc = (np.ones((n, n)) - np.eye(n)) * rho + np.eye(n)