Skip to content

Commit 9bb6473

Browse files
Check for unexpected correlation_kwargs in CLI
1 parent e0fbc2e commit 9bb6473

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

janus_core/cli/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,22 @@ def parse_correlation_kwargs(kwargs: CorrelationKwargs) -> list[dict]:
343343
"""
344344
parsed_kwargs = []
345345
for name, cli_kwargs in kwargs.value.items():
346+
arguments = {
347+
"blocks",
348+
"points",
349+
"averaging",
350+
"update_frequency",
351+
"a_kwargs",
352+
"b_kwargs",
353+
"a",
354+
"b",
355+
}
356+
if not (set(cli_kwargs.keys()) <= arguments):
357+
raise ValueError(
358+
"correlation_kwargs got unexpected argument(s)"
359+
f"{set(cli_kwargs.keys()).difference(arguments)}"
360+
)
361+
346362
if "a" not in cli_kwargs and "b" not in cli_kwargs:
347363
raise ValueError("At least one observable must be supplied as 'a' or 'b'")
348364

tests/test_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,16 @@ def test_invalid_slicelikes(slc):
266266
@pytest.mark.parametrize(
267267
"kwargs, message",
268268
[
269-
({"vaf": {"a": "Velocity"}}, "Correlation keyword argument points"),
269+
({"vaf": {"a": "Velocity"}}, "Correlation keyword argument 'points'"),
270270
({"vaf": {"points": 10}}, "At least one observable"),
271271
(
272272
{"vaf": {"points": 10, "a": "Velocity", "a_kwargs": ".", "b_kwargs": "."}},
273273
"cannot 'ditto' each other",
274274
),
275+
(
276+
{"vaf": {"points": 10, "a": "Velocity", "a_kwarg": {}}},
277+
"correlation_kwargs got unexpected argument",
278+
),
275279
],
276280
)
277281
def test_parse_correlation_kwargs_errors(kwargs, message):

0 commit comments

Comments
 (0)