Skip to content

Commit a2aefa3

Browse files
authored
Fix/kerneldist (#130)
* bugfix to catch situation where kernel distance returns NaN * following confirmed bug fix, incremented version number for master update
1 parent 52fc413 commit a2aefa3

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

mogp_emulator/Kernel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ def calc_r(self, x1, x2, params):
147147

148148
r_matrix = cdist(x1, x2, "seuclidean", V = exp_theta)
149149

150+
if np.any(np.isnan(r_matrix)):
151+
raise FloatingPointError("NaN enountered in kernel distance computation")
152+
150153
return r_matrix
151154

152155
def calc_drdtheta(self, x1, x2, params):

mogp_emulator/tests/test_Kernel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def test_calc_r_failures():
8181
with pytest.raises(AssertionError):
8282
k.calc_r(x, y, params)
8383

84+
with pytest.raises(FloatingPointError):
85+
k.calc_r(y, y, np.array([800., 0.]))
86+
8487
def test_calc_drdtheta():
8588
"test calc_drdtheta function"
8689

mogp_emulator/tests/test_fitting.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def test_fit_GP_MAP():
4444
with pytest.raises(RuntimeError):
4545
fit_GP_MAP(gp, n_tries=1)
4646

47+
with pytest.raises(RuntimeError):
48+
fit_GP_MAP(gp, theta0 = np.array([800., 0., 0.]), n_tries=1)
49+
4750
# bad inputs
4851

4952
with pytest.raises(TypeError):
@@ -119,6 +122,9 @@ def test_fit_GP_MAP_MOGP():
119122
with pytest.raises(RuntimeError):
120123
fit_GP_MAP(gp, n_tries=1)
121124

125+
with pytest.raises(RuntimeError):
126+
fit_GP_MAP(gp, theta0 = np.array([800., 0., 0.]), n_tries=1)
127+
122128
# bad inputs
123129

124130
with pytest.raises(TypeError):
@@ -176,6 +182,9 @@ def test_fit_single_GP_MAP():
176182
with pytest.raises(RuntimeError):
177183
_fit_single_GP_MAP(gp, n_tries=1)
178184

185+
with pytest.raises(RuntimeError):
186+
_fit_single_GP_MAP(gp, theta0 = np.array([800., 0., 0.]), n_tries=1)
187+
179188
# bad inputs
180189

181190
with pytest.raises(AssertionError):
@@ -237,6 +246,9 @@ def test_fit_MOGP_MAP_MOGP():
237246
with pytest.raises(RuntimeError):
238247
_fit_MOGP_MAP(gp, n_tries=1)
239248

249+
with pytest.raises(RuntimeError):
250+
_fit_MOGP_MAP(gp, theta0 = np.array([800., 0., 0.]), n_tries=1)
251+
240252
# bad inputs
241253

242254
with pytest.raises(AssertionError):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# version information
44
MAJOR = 0
55
MINOR = 3
6-
MICRO = 0
6+
MICRO = 1
77
PRERELEASE = 0
88
ISRELEASED = True
99
version = "{}.{}.{}".format(MAJOR, MINOR, MICRO)

0 commit comments

Comments
 (0)