Skip to content

Commit 2ca8968

Browse files
committed
Update test_all_objects.py
1 parent ef64b58 commit 2ca8968

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/hyperactive/tests/test_all_objects.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,24 @@ def test_score_function(self, object_class):
192192
assert isinstance(e_score, float), f"Score is not a float: {e_score}"
193193
assert isinstance(e_metadata, dict), f"Metadata is not a dict: {e_metadata}"
194194

195-
if inst.get_tag("property:randomness") == "deterministic":
195+
det_tag = inst.get_tag("property:randomness", "random")
196+
197+
if det_tag == "deterministic":
196198
msg = f"Score and eval calls do not match: |{e_score}| != |{score}|"
197199
assert abs(e_score) == abs(score), msg
198200

199201
call_sc = inst(**obj)
200202
assert isinstance(call_sc, float), f"Score is not a float: {call_sc}"
201-
if inst.get_tag("property:randomness") == "deterministic":
203+
if det_tag == "deterministic":
202204
msg = f"Score does not match: {res} != {call_sc}"
203205
assert e_score == call_sc, msg
204206

207+
sign_tag = inst.get_tag("property:higher_or_lower_is_better", "lower")
208+
if sign_tag == "higher" and det_tag == "deterministic":
209+
assert e_score == res
210+
elif sign_tag == "lower" and det_tag == "deterministic":
211+
assert e_score == -res
212+
205213

206214
class OptimizerFixtureGenerator(BaseFixtureGenerator):
207215
"""Fixture generator for optimizers.

0 commit comments

Comments
 (0)