Skip to content

Commit

Permalink
Fixed pytest with new fidelity parameter checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gopaljigaur committed Nov 7, 2024
1 parent 67aaa64 commit 4abb9de
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/test_yaml_search_space/correct_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param_float1:
is_fidelity: off

param_int1:
lower: -3
lower: 3
upper: 30
log: false
is_fidelity: on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ param_float1:

param_int1:
type: integer
lower: -3
lower: 3
upper: 30
is_fidelity: True

Expand Down
22 changes: 22 additions & 0 deletions tests/test_yaml_search_space/incorrect_fidelity_bounds_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
param_float1:
lower: 0.00001
upper: 0.1
log: TRUE
is_fidelity: off

param_int1:
lower: -3 # negative fidelity range
upper: 30
log: false
is_fidelity: on

param_int2:
type: int
lower: 1E2
upper: 3e4
log: ON
is_fidelity: FALSE

param_float2:
lower: 3.3e-5
upper: 1.5E-1
10 changes: 9 additions & 1 deletion tests/test_yaml_search_space/test_search_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_correct_yaml_file(path):
assert isinstance(pipeline_space, dict)
float1 = Float(0.00001, 0.1, log=True, is_fidelity=False)
assert float1.__eq__(pipeline_space["param_float1"]) is True
int1 = Integer(-3, 30, log=False, is_fidelity=True)
int1 = Integer(3, 30, log=False, is_fidelity=True)
assert int1.__eq__(pipeline_space["param_int1"]) is True
int2 = Integer(100, 30000, log=True, is_fidelity=False)
assert int2.__eq__(pipeline_space["param_int2"]) is True
Expand Down Expand Up @@ -143,3 +143,11 @@ def test_categorical_default_value_not_in_choices():
with pytest.raises(SearchSpaceFromYamlFileError) as excinfo:
pipeline_space_from_yaml(BASE_PATH + "default_value_not_in_choices_config.yaml")
assert excinfo.value.exception_type == "ValueError"

@pytest.mark.neps_api
def test_incorrect_fidelity_parameter_bounds():
"""Test if a ValueError is raised when the bounds of a fidelity parameter are
not correctly specified."""
with pytest.raises(SearchSpaceFromYamlFileError) as excinfo:
pipeline_space_from_yaml(BASE_PATH + "incorrect_fidelity_bounds_config.yaml")
assert excinfo.value.exception_type == "ValueError"

0 comments on commit 4abb9de

Please sign in to comment.