1010
1111from causal_testing .testing .base_test_case import BaseTestCase
1212
13- from .scenario import Scenario
14- from .variable import Output
13+ from .variable import Variable
1514
1615Node = Union [str , int ] # Node type hint: A node is a string or an int
1716
@@ -489,16 +488,7 @@ def get_backdoor_graph(self, treatments: list[str]) -> CausalDAG:
489488 backdoor_graph .add_edges_from (filter (lambda x : x not in outgoing_edges , self .edges ))
490489 return backdoor_graph
491490
492- @staticmethod
493- def remove_hidden_adjustment_sets (minimal_adjustment_sets : list [str ], scenario : Scenario ):
494- """Remove variables labelled as hidden from adjustment set(s)
495-
496- :param minimal_adjustment_sets: list of minimal adjustment set(s) to have hidden variables removed from
497- :param scenario: The modelling scenario which informs the variables that are hidden
498- """
499- return [adj for adj in minimal_adjustment_sets if all (not scenario .variables .get (x ).hidden for x in adj )]
500-
501- def identification (self , base_test_case : BaseTestCase , scenario : Scenario = None ):
491+ def identification (self , base_test_case : BaseTestCase , avoid_variables : set [Variable ] = None ):
502492 """Identify and return the minimum adjustment set
503493
504494 :param base_test_case: A base test case instance containing the outcome_variable and the
@@ -523,8 +513,10 @@ def identification(self, base_test_case: BaseTestCase, scenario: Scenario = None
523513 else :
524514 raise ValueError ("Causal effect should be 'total' or 'direct'" )
525515
526- if scenario is not None :
527- minimal_adjustment_sets = self .remove_hidden_adjustment_sets (minimal_adjustment_sets , scenario )
516+ if avoid_variables is not None :
517+ minimal_adjustment_sets = [
518+ adj for adj in minimal_adjustment_sets if not {x .name for x in avoid_variables }.intersection (adj )
519+ ]
528520
529521 minimal_adjustment_set = min (minimal_adjustment_sets , key = len , default = set ())
530522 return set (minimal_adjustment_set )
0 commit comments