Skip to content

Commit ca16a3a

Browse files
committed
avoid divide by zero message
1 parent a93270f commit ca16a3a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

hyperactive/optimizers/local/stochastic_hill_climbing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ def _accept(self, _p_):
2424
score_diff_norm = (_p_.score_new - _p_.score_current) / (
2525
_p_.score_new + _p_.score_current
2626
)
27-
return 0.001 / abs(score_diff_norm)
27+
if score_diff_norm == 0:
28+
return 100
29+
else:
30+
return 0.001 / abs(score_diff_norm)
2831

2932
def _iterate(self, i, _cand_, _p_, X, y):
3033
_p_.pos_new = _p_.move_climb(_cand_, _p_.pos_current)

0 commit comments

Comments
 (0)