From a1635276389c43a431cbc194920f88dedea0425f Mon Sep 17 00:00:00 2001 From: zweihuehner <2huehner@gmail.com> Date: Sun, 15 Mar 2026 13:54:38 +0000 Subject: [PATCH 1/4] make test_create_decode more specific --- tests/test_graph_creation.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_graph_creation.py b/tests/test_graph_creation.py index b45d486..2c2d0a4 100644 --- a/tests/test_graph_creation.py +++ b/tests/test_graph_creation.py @@ -197,8 +197,8 @@ def test_create_lat_lon(kind): @pytest.mark.parametrize("kind", ["graphcast", "keisler", "oskarsson_hierarchical"]) def test_create_decode_mask(kind): """ - Tests that the decode mask for m2g works, resulting in less edges than - no filtering. + Tests that the decode mask for m2g works, resulting in less m2g edges than + without decode mask. """ xy = test_utils.create_fake_irregular_coords(100) fn_name = f"create_{kind}_graph" @@ -214,8 +214,16 @@ def test_create_decode_mask(kind): coords=xy, mesh_node_distance=mesh_node_distance, decode_mask=decode_mask ) - # Check that some filtering has been performed - assert len(filtered_graph.edges) < len(unfiltered_graph.edges) + # Check that m2g edges (mesh-to-grid / decoding edges) are filtered + unfiltered_m2g_edges = [ + e for e in unfiltered_graph.edges(data=True) if e[2].get("component") == "m2g" + ] + filtered_m2g_edges = [ + e for e in filtered_graph.edges(data=True) if e[2].get("component") == "m2g" + ] + print(len(unfiltered_m2g_edges)) + print(len(filtered_m2g_edges)) + assert len(filtered_m2g_edges) < len(unfiltered_m2g_edges) @pytest.mark.parametrize("kind", ["graphcast", "oskarsson_hierarchical"]) From 3169656ce8cea546fda54881c2811666b1204687 Mon Sep 17 00:00:00 2001 From: zweihuehner <2huehner@gmail.com> Date: Sun, 15 Mar 2026 14:15:53 +0000 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cf3ab0..5223180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `__version__` attribute to the package init [\#56](https://github.com/mllam/weather-model-graphs/pull/56) @AdMub +### Changed + +- Make `test_create_decode_mask` more specific and future-proof by checking only m2g (decoding) edges instead of total edges. [\#104](https://github.com/mllam/weather-model-graphs/pull/104) @zweihuehner + ## [v0.3.0](https://github.com/mllam/weather-model-graphs/releases/tag/v0.3.0) From d656c58188c3f65c4f7f2d50639567c16b9bfcfb Mon Sep 17 00:00:00 2001 From: zweihuehner <2huehner@gmail.com> Date: Sun, 15 Mar 2026 14:18:35 +0000 Subject: [PATCH 3/4] remove print statments --- tests/test_graph_creation.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_graph_creation.py b/tests/test_graph_creation.py index 2c2d0a4..f57a8f4 100644 --- a/tests/test_graph_creation.py +++ b/tests/test_graph_creation.py @@ -221,8 +221,6 @@ def test_create_decode_mask(kind): filtered_m2g_edges = [ e for e in filtered_graph.edges(data=True) if e[2].get("component") == "m2g" ] - print(len(unfiltered_m2g_edges)) - print(len(filtered_m2g_edges)) assert len(filtered_m2g_edges) < len(unfiltered_m2g_edges) From 21dc99d206e3473c1d60dd29d5af53d5505ebf11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Faro=20Sch=C3=A4fer?= <58438715+zweihuehner@users.noreply.github.com> Date: Sat, 21 Mar 2026 23:03:20 +0100 Subject: [PATCH 4/4] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/test_graph_creation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_graph_creation.py b/tests/test_graph_creation.py index f57a8f4..9b72759 100644 --- a/tests/test_graph_creation.py +++ b/tests/test_graph_creation.py @@ -197,8 +197,8 @@ def test_create_lat_lon(kind): @pytest.mark.parametrize("kind", ["graphcast", "keisler", "oskarsson_hierarchical"]) def test_create_decode_mask(kind): """ - Tests that the decode mask for m2g works, resulting in less m2g edges than - without decode mask. + Tests that the decode mask for m2g works, resulting in fewer m2g edges than + without a decode mask. """ xy = test_utils.create_fake_irregular_coords(100) fn_name = f"create_{kind}_graph"