From 5da3701f5e8b4a837b0c18b22e7ed08a6b78ef42 Mon Sep 17 00:00:00 2001 From: Per A Brodtkorb Date: Wed, 7 Sep 2016 11:28:41 +0200 Subject: [PATCH] Fixed a bug in TransformEstimator --- wafo/interpolate.py | 4 ++-- wafo/transform/estimation.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wafo/interpolate.py b/wafo/interpolate.py index 70819e1..4e52682 100644 --- a/wafo/interpolate.py +++ b/wafo/interpolate.py @@ -546,7 +546,7 @@ class SmoothSpline(PPform): self.linear_extrapolate(output=False) def _compute_coefs(self, xx, yy, p=None, var=1): - x, y = np.atleast_1d(xx, yy) + x, y, var = np.atleast_1d(xx, yy, var) x = x.ravel() dx = np.diff(x) must_sort = (dx < 0).any() @@ -573,7 +573,7 @@ class SmoothSpline(PPform): dydx = np.diff(y) / dx - if (n == 2): # % straight line + if (n == 2): # straight line coefs = np.vstack([dydx.ravel(), y[0, :]]) else: diff --git a/wafo/transform/estimation.py b/wafo/transform/estimation.py index be80b9f..b365e71 100644 --- a/wafo/transform/estimation.py +++ b/wafo/transform/estimation.py @@ -7,7 +7,7 @@ from __future__ import absolute_import from .core import TrData from .models import TrHermite, TrOchi, TrLinear from ..stats import edf, skew, kurtosis -from ..interpolate import SmoothSpline +from ..interpolate import SmoothSpline, interp1d from scipy.special import ndtri as invnorm from scipy.integrate import cumtrapz import warnings @@ -109,6 +109,7 @@ class TransformEstimator(object): if (dy <= 0).any(): dy[dy > 0] = eps gvar = -(np.hstack((dy, 0)) + np.hstack((0, dy))) / 2 + eps + gvar = interp1d(tr.args, gvar)(tr_raw.args) pp_tr = SmoothSpline(tr_raw.args, tr_raw.data, p=1, lin_extrap=self.linextrap, var=ix * gvar)