From 7b7a51cbdf70d60b06d7644bb7d02dde9961e902 Mon Sep 17 00:00:00 2001 From: Eric Firing Date: Fri, 10 Jan 2020 10:09:12 -1000 Subject: [PATCH] Do not try to calculate diagnostics when conf_int is 'none'. Closes #78. The smoke-test has been extended to catch this. --- tests/test_solve.py | 11 +++++++---- utide/_reconstruct.py | 2 +- utide/_solve.py | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_solve.py b/tests/test_solve.py index 5295515..eaa507f 100644 --- a/tests/test_solve.py +++ b/tests/test_solve.py @@ -9,15 +9,18 @@ from __future__ import (absolute_import, division, print_function) +import pytest + import numpy as np from utide import reconstruct from utide import solve from utide._ut_constants import ut_constants from utide.utilities import Bunch - - -def test_roundtrip(): +# We omit the 'MC' case for now because with this test data, it +# fails with 'numpy.linalg.LinAlgError: SVD did not converge'. +@pytest.mark.parametrize('conf_int', ['linear', 'none']) +def test_roundtrip(conf_int): """Minimal conversion from simple_utide_test.""" ts = 735604 duration = 35 @@ -44,7 +47,7 @@ def test_roundtrip(): 'nodal': False, 'trend': False, 'method': 'ols', - 'conf_int': 'linear', + 'conf_int': conf_int, 'Rayleigh_min': 0.95, } diff --git a/utide/_reconstruct.py b/utide/_reconstruct.py index ebb7723..e72c862 100644 --- a/utide/_reconstruct.py +++ b/utide/_reconstruct.py @@ -92,7 +92,7 @@ def _reconstruct(t, goodmask, coef, verbose, constit, min_SNR, min_PE): # Determine constituents to include. if constit is not None: ind = [i for i, c in enumerate(coef['name']) if c in constit] - elif min_SNR == 0 and min_PE == 0: + elif (min_SNR == 0 and min_PE == 0) or coef['aux']['opt']['nodiagn']: ind = slice(None) else: if twodim: diff --git a/utide/_solve.py b/utide/_solve.py index 9ce79e5..0445c16 100644 --- a/utide/_solve.py +++ b/utide/_solve.py @@ -57,6 +57,7 @@ def _translate_opts(opts): oldopts.linci = False elif opts.conf_int == 'none': oldopts.conf_int = False + oldopts.nodiagn = 1 else: raise ValueError("'conf_int' must be 'linear', 'MC', or 'none'")