-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimenter bug #176
Experimenter bug #176
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
"""Tests for the main experimenter.""" | ||
from __future__ import annotations | ||
|
||
from unittest import mock | ||
|
||
import numpy as np | ||
|
||
from swmmanywhere import parameters | ||
|
@@ -41,4 +43,38 @@ def test_generate_samples(): | |
seed = 1, | ||
groups = True) | ||
assert len(samples) == 36 | ||
|
||
|
||
def test_process_parameters(): | ||
"""Test process_parameters.""" | ||
config = {'parameters_to_sample' : ['min_v','max_v'], | ||
'sample_magnitude' : 3, | ||
} | ||
|
||
# Test standard | ||
with mock.patch('swmmanywhere.paper.experimenter.swmmanywhere.swmmanywhere', | ||
return_value=('fake_path',{'fake_metric' : 1})) as mock_sa: | ||
result = experimenter.process_parameters(0,1,config) | ||
|
||
assert len(result[0]) == 48 | ||
assert_close(result[0][0]['min_v'], 0.310930) | ||
|
||
# Test experimenter takes precedence over overrides | ||
config['parameter_overrides'] = {'hydraulic_design': {'min_v': 1.0}} | ||
with mock.patch('swmmanywhere.paper.experimenter.swmmanywhere.swmmanywhere', | ||
return_value=('fake_path',{'fake_metric' : 1})) as mock_sa: | ||
result = experimenter.process_parameters(0,1,config) | ||
|
||
assert len(result[0]) == 48 | ||
assert_close(result[0][0]['min_v'], 0.310930) | ||
|
||
# Test non experimenter overrides still work | ||
config['parameter_overrides'] = {'hydraulic_design': {'max_fr': 0.5}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a non-experimenter override? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The experimenter passes parameters to main function via If I am running the |
||
with mock.patch('swmmanywhere.paper.experimenter.swmmanywhere.swmmanywhere', | ||
return_value=('fake_path',{'fake_metric' : 1})) as mock_sa: | ||
result = experimenter.process_parameters(0,1,config) | ||
|
||
for call in mock_sa.mock_calls: | ||
assert call.args[0]['parameter_overrides']['hydraulic_design']['max_fr'] == 0.5 | ||
|
||
assert len(result[0]) == 48 | ||
assert_close(result[0][0]['min_v'], 0.310930) | ||
Comment on lines
+79
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, no change in the assert statements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The setting of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this testing that the experimenter overrides do anything at all? The results you are asserting are identical to the previous case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that the experimenter parameter selection (passed via
parameter_overrides
) takes precedence over aconfig
defined parameter override. It should be the same as before even though we have provided an override.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this and subsequent comments - I have tried to address by improving the docstring of
process_parameters