Skip to content

Commit

Permalink
Merge pull request #292 from DHI/check-kwargs-valid
Browse files Browse the repository at this point in the history
Check kwargs valid
  • Loading branch information
jsmariegaard authored Dec 3, 2023
2 parents c2bad56 + 55b0b3b commit 5e1a758
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modelskill/comparison/_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ def skill(
# TODO remove in v1.1
model, start, end, area = _get_deprecated_args(kwargs)
observation, variable = _get_deprecated_obs_var_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

cmp = self.sel(
model=model,
Expand Down Expand Up @@ -530,6 +531,7 @@ def spatial_skill(

model, start, end, area = _get_deprecated_args(kwargs)
observation, variable = _get_deprecated_obs_var_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

metrics = _parse_metric(metrics, self.metrics, return_list=True)

Expand Down Expand Up @@ -677,6 +679,7 @@ def mean_skill(
# TODO remove in v1.1
model, start, end, area = _get_deprecated_args(kwargs)
observation, variable = _get_deprecated_obs_var_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

# filter data
cmp = self.sel(
Expand Down Expand Up @@ -769,6 +772,7 @@ def mean_skill_points(
# TODO remove in v1.1
model, start, end, area = _get_deprecated_args(kwargs)
observation, variable = _get_deprecated_obs_var_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

# filter data
cmp = self.sel(
Expand Down Expand Up @@ -905,6 +909,7 @@ def score(

model, start, end, area = _get_deprecated_args(kwargs)
observation, variable = _get_deprecated_obs_var_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

if model is None:
models = self.mod_names
Expand Down Expand Up @@ -960,6 +965,7 @@ def taylor(

model, start, end, area = _get_deprecated_args(kwargs)
observation, variable = _get_deprecated_obs_var_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

cmp = self.sel(
model=model,
Expand Down
3 changes: 3 additions & 0 deletions modelskill/comparison/_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ def skill(

# TODO remove in v1.1
model, start, end, area = _get_deprecated_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

cmp = self.sel(
model=model,
Expand Down Expand Up @@ -1026,6 +1027,7 @@ def score(

# TODO remove in v1.1
model, start, end, area = _get_deprecated_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

s = self.skill(
metrics=[metric],
Expand Down Expand Up @@ -1108,6 +1110,7 @@ def spatial_skill(

# TODO remove in v1.1
model, start, end, area = _get_deprecated_args(kwargs)
assert kwargs == {}, f"Unknown keyword arguments: {kwargs}"

cmp = self.sel(
model=model,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_aggregated_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def test_skill(cc1):
assert "bias" in repr(s)


def test_skill_bad_args(cc1):
with pytest.raises(AssertionError):
cc1.skill(nonexisting_arg=1)


def test_skill_multi_model(cc2):
s = cc2.skill(metrics=["rmse", "bias"])

Expand Down

0 comments on commit 5e1a758

Please sign in to comment.