Skip to content
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

Fix default UPDATE_KEYS with threshold in CALCULATE_KEYS #21

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion semeio/jobs/correlated_observations_scaling/job_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def _realize_list(input_string):
def _expand_input(input_value):
expanded_values = deepcopy(input_value)
if "CALCULATE_KEYS" in expanded_values and "UPDATE_KEYS" not in expanded_values:
expanded_values.update({"UPDATE_KEYS": expanded_values["CALCULATE_KEYS"]})
expanded_values.update(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not have been caught in the test_expand_input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yes it should, is now.

{"UPDATE_KEYS": {"keys": expanded_values["CALCULATE_KEYS"]["keys"]}}
)
return expanded_values


Expand Down
23 changes: 10 additions & 13 deletions tests/jobs/correlated_observations_scaling/unit/test_scaling_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,27 @@ def test_min_value(test_input, expected_result):
assert job_config._min_value(test_input).__bool__() == expected_result


def test_expand_input():
def test_expand_input_no_modification():

expected_result = {
"UPDATE_KEYS": {"keys": [{"key": "key_4"}, {"key": "key_5"}, {"key": "key_6"}]},
"CALCULATE_KEYS": {
"keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}]
"keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}],
"threshold": 1.0,
},
}

valid_config = deepcopy(expected_result)

assert job_config._expand_input(deepcopy(expected_result)) == expected_result

copy_of_valid_config = deepcopy(valid_config)
copy_of_valid_config.pop("UPDATE_KEYS")

expected_result = {
"UPDATE_KEYS": {"keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}]},
"CALCULATE_KEYS": {
"keys": [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}]
},
}
def test_expand_input_modification():
keys = [{"key": "key_1"}, {"key": "key_2"}, {"key": "key_3"}]
test_input = {"CALCULATE_KEYS": {"keys": keys, "threshold": 1.0}}

expected_results = deepcopy(test_input)
expected_results["UPDATE_KEYS"] = {"keys": keys}

assert job_config._expand_input(copy_of_valid_config) == expected_result
assert job_config._expand_input(test_input) == expected_results


def test_config_setup():
Expand Down