Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This change is not directly related to the issue - not aware of how specific you are on this, I don't see it as an issue if all tests passed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

True. But we are pragmatic.😉

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build: typecheck test
python -m build

lint:
ruff check .
ruff check $(LIB)

test:
pytest --disable-warnings
Expand Down
5 changes: 4 additions & 1 deletion modelskill/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ def match(
spatial_method=spatial_method,
)

assert isinstance(obs, Collection)
if isinstance(obs, Collection):
assert all(isinstance(o, get_args(ObsInputType)) for o in obs)
else:
raise TypeError(f"Obs is not the correct type: it is {type(obs)}. Check the order of the arguments (obs, mod).")

if len(obs) > 1 and isinstance(mod, Collection) and len(mod) > 1:
if not all(isinstance(m, (DfsuModelResult, GridModelResult)) for m in mod):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,13 @@ def test_compare_model_vs_dummy_for_track(mr1, o3):

# better than dummy 🙂
assert cmp2.score()["SW_1"] == pytest.approx(0.3524703)

def test_match_obs_model_pos_args_wrong_order_helpful_error_message():

# match is pretty helpful in converting strings or dataset
# so we need to use a ModelResult to trigger the error
mr = ms.PointModelResult(data=pd.Series([0.0,0.0], index=pd.date_range("1970", periods=2, freq='d')), name="Zero")
obs = ms.PointObservation(data=pd.Series([1.0, 2.0, 3.0], index=pd.date_range("1970", periods=3, freq='h')), name="MyStation")

with pytest.raises(TypeError, match="order"):
ms.match(mr, obs)