From c3662d9d82c9b85d41f5af41940ff4151e6884c4 Mon Sep 17 00:00:00 2001 From: richard gowers Date: Wed, 15 Nov 2023 17:57:55 +0000 Subject: [PATCH] tests for to/from networkx representation --- cinnabar/tests/test_femap.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cinnabar/tests/test_femap.py b/cinnabar/tests/test_femap.py index f6642dc..9d21641 100644 --- a/cinnabar/tests/test_femap.py +++ b/cinnabar/tests/test_femap.py @@ -208,3 +208,20 @@ def test_to_dataframe(example_map): assert abs_df2.shape == (72, 5) assert abs_df2.loc[abs_df2.computational].shape == (36, 5) assert abs_df2.loc[~abs_df2.computational].shape == (36, 5) + + +def test_to_networkx(example_map): + g = example_map.to_networkx() + + assert g + assert isinstance(g, nx.MultiDiGraph) + # should have (exptl + comp edges) * 2 + assert len(g.edges) == 2 * (36 + 58) + + +def test_from_networkx(example_map): + g = example_map.to_networkx() + + m2 = cinnabar.FEMap.from_networkx(g) + + assert example_map == m2