Skip to content

Commit c29d0ff

Browse files
authored
Update FCI.py for fixing isNoncollider
Editing isNoncollider() for FCI Algo; Fixing Bug: If sep_set does not contain certain node combination, this will led to a KeyError. With this fix, None will automatically set by the get func. Also get_node_map() will only called once to check sep_set Signed-off-by: Sven Pieper <[email protected]>
1 parent d98225b commit c29d0ff

File tree

1 file changed

+2
-1
lines changed
  • causallearn/search/ConstraintBased

1 file changed

+2
-1
lines changed

causallearn/search/ConstraintBased/FCI.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ def rulesR1R2cycle(graph: Graph, bk: BackgroundKnowledge | None, changeFlag: boo
320320

321321
def isNoncollider(graph: Graph, sep_sets: Dict[Tuple[int, int], Set[int]], node_i: Node, node_j: Node,
322322
node_k: Node) -> bool:
323-
sep_set = sep_sets[(graph.get_node_map()[node_i], graph.get_node_map()[node_k])]
323+
node_map = graph.get_node_map()
324+
sep_set = sep_sets.get((node_map[node_i], node_map[node_k]))
324325
return sep_set is not None and sep_set.__contains__(graph.get_node_map()[node_j])
325326

326327

0 commit comments

Comments
 (0)