From 0883c2e556cca4e1e0c057d66efd36744249adc6 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Thu, 13 Aug 2015 08:54:56 +0100 Subject: [PATCH] caught warnings in misc_tests --- GPy/testing/misc_tests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/GPy/testing/misc_tests.py b/GPy/testing/misc_tests.py index e620fa7e..cbb74ca2 100644 --- a/GPy/testing/misc_tests.py +++ b/GPy/testing/misc_tests.py @@ -1,6 +1,7 @@ import numpy as np import scipy as sp import GPy +import warnings class MiscTests(np.testing.TestCase): """ @@ -11,8 +12,12 @@ class MiscTests(np.testing.TestCase): self._lim_val_exp = np.log(self._lim_val) def test_safe_exp_upper(self): - assert np.exp(self._lim_val_exp + 1) == np.inf - assert GPy.util.misc.safe_exp(self._lim_val_exp + 1) < np.inf + with warnings.catch_warnings(record=True) as w: + assert np.isfinite(np.exp(self._lim_val_exp)) + assert np.isinf(np.exp(self._lim_val_exp + 1)) + assert np.isfinite(GPy.util.misc.safe_exp(self._lim_val_exp + 1)) + + assert len(w)==1 # should have one overflow warning def test_safe_exp_lower(self): assert GPy.util.misc.safe_exp(1e-10) < np.inf