Skip to content

Commit 582b528

Browse files
committed
remove g.has_node(q["id"])
- #55 (comment)
1 parent e01f7b7 commit 582b528

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

chebai/preprocessing/datasets/chebi.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,9 @@ def _extract_class_hierarchy(self, data_path: str) -> nx.DiGraph:
260260
g.add_node(n["id"], **n)
261261

262262
# Only take the edges which connects the existing nodes, to avoid internal creation of obsolete nodes
263+
# https://github.com/ChEB-AI/python-chebai/pull/55#issuecomment-2386654142
263264
g.add_edges_from(
264-
[
265-
(p, q["id"])
266-
for q in elements
267-
for p in q["parents"]
268-
if g.has_node(p) and g.has_node(q["id"])
269-
]
265+
[(p, q["id"]) for q in elements for p in q["parents"] if g.has_node(p)]
270266
)
271267

272268
print("Compute transitive closure")

0 commit comments

Comments
 (0)