mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-05 01:32:40 +02:00
caught warnings in misc_tests
This commit is contained in:
parent
a344155827
commit
0883c2e556
1 changed files with 7 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import scipy as sp
|
import scipy as sp
|
||||||
import GPy
|
import GPy
|
||||||
|
import warnings
|
||||||
|
|
||||||
class MiscTests(np.testing.TestCase):
|
class MiscTests(np.testing.TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
@ -11,8 +12,12 @@ class MiscTests(np.testing.TestCase):
|
||||||
self._lim_val_exp = np.log(self._lim_val)
|
self._lim_val_exp = np.log(self._lim_val)
|
||||||
|
|
||||||
def test_safe_exp_upper(self):
|
def test_safe_exp_upper(self):
|
||||||
assert np.exp(self._lim_val_exp + 1) == np.inf
|
with warnings.catch_warnings(record=True) as w:
|
||||||
assert GPy.util.misc.safe_exp(self._lim_val_exp + 1) < np.inf
|
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):
|
def test_safe_exp_lower(self):
|
||||||
assert GPy.util.misc.safe_exp(1e-10) < np.inf
|
assert GPy.util.misc.safe_exp(1e-10) < np.inf
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue