tidied link_fn tests

This commit is contained in:
James Hensman 2015-08-17 16:32:27 +01:00
parent 4656962337
commit c79c74a2d6

View file

@ -7,7 +7,6 @@ _lim_val_exp = np.log(_lim_val)
_lim_val_square = np.sqrt(_lim_val) _lim_val_square = np.sqrt(_lim_val)
_lim_val_cube = cbrt(_lim_val) _lim_val_cube = cbrt(_lim_val)
from GPy.likelihoods.link_functions import Identity, Probit, Cloglog, Log, Log_ex_1, Reciprocal, Heaviside from GPy.likelihoods.link_functions import Identity, Probit, Cloglog, Log, Log_ex_1, Reciprocal, Heaviside
#np.seterr(over='raise')
class LinkFunctionTests(np.testing.TestCase): class LinkFunctionTests(np.testing.TestCase):
def setUp(self): def setUp(self):
@ -80,8 +79,7 @@ class LinkFunctionTests(np.testing.TestCase):
assert np.isinf(np.exp(np.log(self.f_upper_lim))) assert np.isinf(np.exp(np.log(self.f_upper_lim)))
#Check the clipping works #Check the clipping works
np.testing.assert_almost_equal(link.transf(self.f_lower_lim), 0, decimal=5) np.testing.assert_almost_equal(link.transf(self.f_lower_lim), 0, decimal=5)
#Need to look at most significant figures here rather than the decimals self.assertTrue(np.isfinite(link.transf(self.f_upper_lim)))
np.testing.assert_approx_equal(link.transf(self.f_upper_lim), _lim_val, significant=5)
self.check_overflow(link, lim_of_inf) self.check_overflow(link, lim_of_inf)
#Check that it would otherwise fail #Check that it would otherwise fail