Skip to content

Commit 977aa67

Browse files
committed
Removed unused depends_on_outputs
1 parent 845d064 commit 977aa67

2 files changed

Lines changed: 0 additions & 68 deletions

File tree

causal_testing/specification/causal_dag.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -489,22 +489,6 @@ def get_backdoor_graph(self, treatments: list[str]) -> CausalDAG:
489489
backdoor_graph.add_edges_from(filter(lambda x: x not in outgoing_edges, self.edges))
490490
return backdoor_graph
491491

492-
def depends_on_outputs(self, node: Node, scenario: Scenario) -> bool:
493-
"""Check whether a given node in a given scenario is or depends on a
494-
model output in the given scenario. That is, whether or not the model
495-
needs to be run to determine its value.
496-
497-
NOTE: The graph must be acyclic for this to terminate.
498-
499-
:param node: The node in the DAG representing the variable of interest.
500-
:param scenario: The modelling scenario.
501-
502-
:return: Whether the given variable is or depends on an output.
503-
"""
504-
if isinstance(scenario.variables[node], Output):
505-
return True
506-
return any((self.depends_on_outputs(n, scenario) for n in self.predecessors(node)))
507-
508492
@staticmethod
509493
def remove_hidden_adjustment_sets(minimal_adjustment_sets: list[str], scenario: Scenario):
510494
"""Remove variables labelled as hidden from adjustment set(s)

tests/specification_tests/test_causal_dag.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -362,58 +362,6 @@ def tearDown(self) -> None:
362362
shutil.rmtree(self.temp_dir_path)
363363

364364

365-
class TestDependsOnOutputs(unittest.TestCase):
366-
"""
367-
Test the depends_on_outputs method.
368-
"""
369-
370-
def setUp(self) -> None:
371-
from scipy.stats import uniform
372-
from causal_testing.specification.variable import Input, Output, Meta
373-
from causal_testing.specification.scenario import Scenario
374-
375-
self.temp_dir_path = tempfile.mkdtemp()
376-
self.dag_dot_path = os.path.join(self.temp_dir_path, "dag.dot")
377-
dag_dot = """digraph G { A -> B; B -> C; D -> A; D -> C}"""
378-
f = open(self.dag_dot_path, "w")
379-
f.write(dag_dot)
380-
f.close()
381-
382-
D = Input("D", float, uniform(0, 1))
383-
A = Meta("A", float, uniform(0, 1))
384-
B = Output("B", float, uniform(0, 1))
385-
C = Meta("C", float, uniform(0, 1))
386-
387-
self.scenario = Scenario({A, B, C, D})
388-
389-
def test_depends_on_outputs_output(self):
390-
causal_dag = CausalDAG(self.dag_dot_path)
391-
print("nodes:", causal_dag.nodes())
392-
print("graph:", causal_dag)
393-
self.assertTrue(causal_dag.depends_on_outputs("B", self.scenario))
394-
395-
def test_depends_on_outputs_output_meta(self):
396-
causal_dag = CausalDAG(self.dag_dot_path)
397-
print("nodes:", causal_dag.nodes())
398-
print("graph:", causal_dag)
399-
self.assertTrue(causal_dag.depends_on_outputs("C", self.scenario))
400-
401-
def test_depends_on_outputs_input_meta(self):
402-
causal_dag = CausalDAG(self.dag_dot_path)
403-
print("nodes:", causal_dag.nodes())
404-
print("graph:", causal_dag)
405-
self.assertFalse(causal_dag.depends_on_outputs("A", self.scenario))
406-
407-
def test_depends_on_outputs_input(self):
408-
causal_dag = CausalDAG(self.dag_dot_path)
409-
print("nodes:", causal_dag.nodes())
410-
print("graph:", causal_dag)
411-
self.assertFalse(causal_dag.depends_on_outputs("D", self.scenario))
412-
413-
def tearDown(self) -> None:
414-
shutil.rmtree(self.temp_dir_path)
415-
416-
417365
class TestUndirectedGraphAlgorithms(unittest.TestCase):
418366
"""
419367
Test the graph algorithms designed for the undirected graph variants of a Causal DAG.

0 commit comments

Comments
 (0)