Skip to content

Commit

Permalink
Merge pull request #34 from causy-dev/refactor/rename-pipeline-steps
Browse files Browse the repository at this point in the history
refactor: rename pipeline steps
  • Loading branch information
this-is-sofia authored May 16, 2024
2 parents e3a183f + 294798b commit 3884b28
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion causy/causal_effect_estimation/multivariate_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion causy/common_pipeline_steps/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion causy/common_pipeline_steps/placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
14 changes: 10 additions & 4 deletions causy/independence_tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]]:
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions causy/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion causy/orientation_rules/fci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand Down
10 changes: 5 additions & 5 deletions causy/orientation_rules/pc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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]:
"""
Expand Down

0 comments on commit 3884b28

Please sign in to comment.