Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bonicim committed Aug 30, 2023
1 parent 9ba04f2 commit dc51613
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions hypernetx/classes/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,12 +1253,14 @@ def dual(self, name=None, switch_names=True):
cprops = [col for col in df.columns if not col in [edge, node, wt]]

df[[edge, node]] = df[[node, edge]]
if switch_names == True and not (self._edge_col == 'edges' and self._node_col == 'nodes'):
# if switch_names == False or (self._edge_col == 'edges' and self._node_col == 'nodes'):
if switch_names == True and not (
self._edge_col == "edges" and self._node_col == "nodes"
):
# if switch_names == False or (self._edge_col == 'edges' and self._node_col == 'nodes'):
df = df.rename(columns={edge: self._node_col, node: self._edge_col})
node = self._edge_col
edge = self._node_col

return Hypergraph(
df,
edge_col=edge,
Expand Down
5 changes: 4 additions & 1 deletion hypernetx/classes/tests/test_hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ def test_dual_again(sbs_edgedict):
H = Hypergraph(sbs_edgedict, edge_col="Types", node_col="Values")
assert list(H.dataframe.columns[0:2]) == ["Types", "Values"]
assert list(H.dual().dataframe.columns[0:2]) == ["Values", "Types"]
assert list(H.dual(switch_names=False).dataframe.columns[0:2]) == ["Types","Values"]
assert list(H.dual(switch_names=False).dataframe.columns[0:2]) == [
"Types",
"Values",
]


@pytest.mark.filterwarnings("ignore:No 3-path between ME and FN")
Expand Down

0 comments on commit dc51613

Please sign in to comment.