From 9e6a79d24d9cc21e8365e7217d159f0121a13d2f Mon Sep 17 00:00:00 2001 From: Per A Brodtkorb Date: Fri, 23 Dec 2016 09:32:48 +0100 Subject: [PATCH] Moved test_kdetools.py to wafo.kdetools.tests --- wafo/kdetools/kdetools.py | 19 +------------------ wafo/kdetools/tests/__init__.py | 0 wafo/kdetools/tests/conftest.py | 12 ++++++++++++ wafo/{ => kdetools}/tests/test_kdetools.py | 0 4 files changed, 13 insertions(+), 18 deletions(-) create mode 100644 wafo/kdetools/tests/__init__.py create mode 100644 wafo/kdetools/tests/conftest.py rename wafo/{ => kdetools}/tests/test_kdetools.py (100%) diff --git a/wafo/kdetools/kdetools.py b/wafo/kdetools/kdetools.py index a943dba..80d6454 100644 --- a/wafo/kdetools/kdetools.py +++ b/wafo/kdetools/kdetools.py @@ -1144,24 +1144,11 @@ class BKRegression(object): plot_kwds=dict(alpha=0.2, color=color)), prb_e] - # empirical oversmooths the data -# p_s = prb_s.eval_points(self.x) -# dp_s = np.diff(prb_s.data) -# k = (dp_s[:-1]*dp_s[1:]<0).sum() # numpeaks -# p_e = self.y -# n_s = interpolate.interp1d(x_s, c_s)(self.x) -# plo, pup = self.prb_ci(n_s, p_s, alpha) -# sigmai = (pup-plo) -# aicc = (((p_e-p_s)/sigmai)**2).sum()+ 2*k*(k+1)/np.maximum(n-k+1,1) - p_e = prb_e.eval_points(x_s) p_s = prb_s.data dp_s = np.sign(np.diff(p_s)) k = (dp_s[:-1] != dp_s[1:]).sum() # numpeaks - # sigmai = (pup-plo)+_EPS - # aicc = (((p_e-p_s)/sigmai)**2).sum()+ 2*k*(k+1)/np.maximum(n_e-k+1,1) - # + np.abs((p_e-pup).clip(min=0)-(p_e-plo).clip(max=0)).sum() sigmai = _logit(pup) - _logit(plo) + _EPS aicc = ((((_logit(p_e) - _logit(p_s)) / sigmai) ** 2).sum() + 2 * k * (k + 1) / np.maximum(n_e - k + 1, 1) + @@ -1169,10 +1156,6 @@ class BKRegression(object): (p_e - plo).clip(max=0)).sum()) prb_s.aicc = aicc - # prb_s.labels.title = '' - # prb_s.labels.title='perr=%1.3f,aicc=%1.3f, n=%d, hs=%1.3f' % - # (prb_s.prediction_error_avg,aicc,n,hs) - return prb_s def prb_search_best(self, prb_e=None, hsvec=None, hsfun='hste', @@ -1192,7 +1175,7 @@ class BKRegression(object): prb_e = self.prb_empirical( hs_e=self.hs_e, alpha=alpha, color=color) if hsvec is None: - hsmax = self._get_max_smoothing(hsfun)[0] # @UnusedVariable + hsmax = self._get_max_smoothing(hsfun)[0] hsmax = max(hsmax, self.hs_e) hsvec = np.linspace(hsmax * 0.2, hsmax, 55) diff --git a/wafo/kdetools/tests/__init__.py b/wafo/kdetools/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wafo/kdetools/tests/conftest.py b/wafo/kdetools/tests/conftest.py new file mode 100644 index 0000000..5c8859b --- /dev/null +++ b/wafo/kdetools/tests/conftest.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + Dummy conftest.py for wafo. + + If you don't know what this is for, just leave it empty. + Read more about conftest.py under: + https://pytest.org/latest/plugins.html +""" +from __future__ import print_function, absolute_import, division + +import pytest # @UnusedImport diff --git a/wafo/tests/test_kdetools.py b/wafo/kdetools/tests/test_kdetools.py similarity index 100% rename from wafo/tests/test_kdetools.py rename to wafo/kdetools/tests/test_kdetools.py