Skip to content

Commit

Permalink
Operation test tuple params (#2110)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc committed Mar 6, 2024
2 parents 102a0f5 + 5705cb5 commit a0c5041
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/release_notes/next/dev-2109-operation-test-tuple
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#2109: Allow tuple params in operation test cases
11 changes: 11 additions & 0 deletions scripts/operations_tests/operations_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ def __bool__(self):
return self.status == "pass"


def process_params(param):
"""
Handle parameter values that cannot be encoded natively in json
"""
if isinstance(param, list):
if param[0] == "tuple":
return tuple(param[1:])
return param


def compare_mode():
for operation, test_case_info in TEST_CASES.items():
print(f"Running tests for {operation}:")
Expand All @@ -77,6 +87,7 @@ def compare_mode():
if args.match and args.match not in test_name:
continue
params = test_case_info["params"] | case["params"]
params = {k: process_params(v) for k, v in params.items()}
op_class = FILTERS[operation]
op_func = op_class.filter_func
test_case = TestCase(operation, test_name, sub_test_name, test_number, params, op_func)
Expand Down
10 changes: 10 additions & 0 deletions scripts/operations_tests/test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,16 @@
"params": {
"rebin_param": 0.5
}
},
{
"test_name": "rebin_to_dimensions_100x90",
"params": {
"rebin_param": [
"tuple",
100,
90
]
}
}
]
},
Expand Down

0 comments on commit a0c5041

Please sign in to comment.