Skip to content

Commit

Permalink
tests for to/from networkx representation
Browse files Browse the repository at this point in the history
  • Loading branch information
richardjgowers committed Nov 20, 2023
1 parent 49a683c commit c3662d9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cinnabar/tests/test_femap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c3662d9

Please sign in to comment.