From 294798bc0df7b3899a953341ee03a6335ec7ec62 Mon Sep 17 00:00:00 2001 From: Sofia Faltenbacher Date: Thu, 16 May 2024 21:48:21 +0200 Subject: [PATCH] refactor: rename pipeline steps --- .../multivariate_regression.py | 2 +- causy/common_pipeline_steps/calculation.py | 2 +- causy/common_pipeline_steps/placeholder.py | 2 +- causy/independence_tests/common.py | 14 ++++++++++---- causy/interfaces.py | 6 ++++-- causy/orientation_rules/fci.py | 2 +- causy/orientation_rules/pc.py | 10 +++++----- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/causy/causal_effect_estimation/multivariate_regression.py b/causy/causal_effect_estimation/multivariate_regression.py index eb4c6da..888f4ca 100644 --- a/causy/causal_effect_estimation/multivariate_regression.py +++ b/causy/causal_effect_estimation/multivariate_regression.py @@ -18,7 +18,7 @@ class ComputeDirectEffectsMultivariateRegression(PipelineStepInterface): chunk_size_parallel_processing: int = 1 parallel: bool = False - def test(self, nodes: Tuple[str], graph: BaseGraphInterface) -> TestResult: + def process(self, nodes: Tuple[str], graph: BaseGraphInterface) -> TestResult: """ Calculate the direct effect of each edge in the graph using multivariate regression. :param nodes: list of nodes diff --git a/causy/common_pipeline_steps/calculation.py b/causy/common_pipeline_steps/calculation.py index 1afbc8d..ff2f98c 100644 --- a/causy/common_pipeline_steps/calculation.py +++ b/causy/common_pipeline_steps/calculation.py @@ -24,7 +24,7 @@ class CalculatePearsonCorrelations( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test(self, nodes: Tuple[str], graph: BaseGraphInterface) -> TestResult: + def process(self, nodes: Tuple[str], graph: BaseGraphInterface) -> TestResult: """ Calculate the correlation between each pair of nodes and store it to the respective edge. :param nodes: list of nodes diff --git a/causy/common_pipeline_steps/placeholder.py b/causy/common_pipeline_steps/placeholder.py index 9e243dc..a915a96 100644 --- a/causy/common_pipeline_steps/placeholder.py +++ b/causy/common_pipeline_steps/placeholder.py @@ -18,7 +18,7 @@ class PlaceholderTest( chunk_size_parallel_processing: int = 10 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> List[TestResult] | TestResult: """ diff --git a/causy/independence_tests/common.py b/causy/independence_tests/common.py index 5a6f2b2..daf9a1f 100644 --- a/causy/independence_tests/common.py +++ b/causy/independence_tests/common.py @@ -30,7 +30,9 @@ class CorrelationCoefficientTest( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test(self, nodes: List[str], graph: BaseGraphInterface) -> Optional[TestResult]: + def process( + self, nodes: List[str], graph: BaseGraphInterface + ) -> Optional[TestResult]: """ Test if u and v are independent and delete edge in graph if they are. :param nodes: list of nodes @@ -65,7 +67,7 @@ class PartialCorrelationTest( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> Optional[List[TestResult]]: """ @@ -142,7 +144,9 @@ class ExtendedPartialCorrelationTestMatrix( chunk_size_parallel_processing: int = 1000 parallel: bool = False - def test(self, nodes: List[str], graph: BaseGraphInterface) -> Optional[TestResult]: + def process( + self, nodes: List[str], graph: BaseGraphInterface + ) -> Optional[TestResult]: """ Test if nodes u,v are independent given Z (set of nodes) based on partial correlation using the inverted covariance matrix (precision matrix). https://en.wikipedia.org/wiki/Partial_correlation#Using_matrix_inversion @@ -244,7 +248,9 @@ class ExtendedPartialCorrelationTestLinearRegression( chunk_size_parallel_processing: int = 1000 parallel: bool = False - def test(self, nodes: List[str], graph: BaseGraphInterface) -> Optional[TestResult]: + def process( + self, nodes: List[str], graph: BaseGraphInterface + ) -> Optional[TestResult]: if not graph.edge_exists(graph.nodes[nodes[0]], graph.nodes[nodes[1]]): return diff --git a/causy/interfaces.py b/causy/interfaces.py index 4493d06..d457420 100644 --- a/causy/interfaces.py +++ b/causy/interfaces.py @@ -262,7 +262,9 @@ def name(self) -> str: return serialize_module_name(self) @abstractmethod - def test(self, nodes: List[str], graph: BaseGraphInterface) -> Optional[TestResult]: + def process( + self, nodes: List[str], graph: BaseGraphInterface + ) -> Optional[TestResult]: """ Test if u and v are independent :param u: u values @@ -274,7 +276,7 @@ def test(self, nodes: List[str], graph: BaseGraphInterface) -> Optional[TestResu def __call__( self, nodes: List[str], graph: BaseGraphInterface ) -> Optional[TestResult]: - return self.test(nodes, graph) + return self.process(nodes, graph) class ExitConditionInterface(ABC, BaseModel): diff --git a/causy/orientation_rules/fci.py b/causy/orientation_rules/fci.py index 1f1a9fc..70c9549 100644 --- a/causy/orientation_rules/fci.py +++ b/causy/orientation_rules/fci.py @@ -21,7 +21,7 @@ class ColliderRuleFCI( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> Optional[List[TestResult] | TestResult]: """ diff --git a/causy/orientation_rules/pc.py b/causy/orientation_rules/pc.py index 8b1f552..496255a 100644 --- a/causy/orientation_rules/pc.py +++ b/causy/orientation_rules/pc.py @@ -27,7 +27,7 @@ class ColliderTest( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> Optional[List[TestResult] | TestResult]: """ @@ -95,7 +95,7 @@ class NonColliderTest( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> Optional[List[TestResult] | TestResult]: """ @@ -161,7 +161,7 @@ class FurtherOrientTripleTest( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> Optional[List[TestResult] | TestResult]: """ @@ -219,7 +219,7 @@ class OrientQuadrupleTest( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> Optional[List[TestResult] | TestResult]: """ @@ -287,7 +287,7 @@ class FurtherOrientQuadrupleTest( chunk_size_parallel_processing: int = 1 parallel: bool = False - def test( + def process( self, nodes: Tuple[str], graph: BaseGraphInterface ) -> Optional[List[TestResult] | TestResult]: """