Skip to content

Commit 6b7c47e

Browse files
committed
add 'warnings' to exception and fix bug
1 parent ca623bc commit 6b7c47e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/hyperactive/opt/_common.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Common functions used by multiple optimizers."""
22

3+
import warnings
4+
35
__all__ = ["_score_params"]
46

57

@@ -14,7 +16,11 @@ def _score_params(params, meta):
1416
error_score = meta["error_score"]
1517

1618
try:
17-
return float(experiment(**params))
18-
except Exception: # noqa: B904
19-
# Catch all exceptions and assign error_score
20-
return error_score
19+
return float(experiment(params))
20+
except Exception as e:
21+
warnings.warn(
22+
f"Experiment raised {type(e).__name__}: {e}. "
23+
f"Assigning error_score={error_score}.",
24+
stacklevel=2,
25+
)
26+
return float(error_score)

0 commit comments

Comments
 (0)