Skip to content

Commit 8026f79

Browse files
author
AndrewC19
committed
Added template classes for metamorphic relations and properties
1 parent 24316fe commit 8026f79

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from dataclasses import dataclass
2+
from abc import abstractmethod
3+
4+
5+
@dataclass(order=True, frozen=True)
6+
class MetamorphicRelation:
7+
"""Class representing a metamorphic relation."""
8+
9+
@abstractmethod
10+
def generate_follow_up(self, source_input_configuration):
11+
"""Generate a follow-up input configuration from a given source input
12+
configuration."""
13+
...
14+
15+
@abstractmethod
16+
def test_oracle(self):
17+
"""A test oracle i.e. a method that checks correctness of a test."""
18+
...
19+
20+
@abstractmethod
21+
def execute_test(self):
22+
"""Execute a test for this metamorphic relation."""
23+
...
24+
25+
26+
@dataclass(order=True, frozen=True)
27+
class ShouldCause(MetamorphicRelation):
28+
"""Class representing a should cause metamorphic relation."""
29+
30+
def generate_follow_up(self, source_input_configuration):
31+
pass
32+
33+
def test_oracle(self):
34+
pass
35+
36+
def execute_test(self):
37+
pass
38+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""A library of dataclasses for properties implied by a causal DAG."""
2+
from dataclasses import dataclass
3+
from typing import Iterable
4+
5+
from causal_specification import Node
6+
7+
8+
@dataclass(order=True, frozen=True)
9+
class ConditionalIndependenceRelation:
10+
treatment: Node
11+
outcome: Node
12+
adjustment_set: Iterable[Node]
13+
14+
def __str__(self):
15+
return f"{self.treatment} _||_ {self.outcome} | {self.adjustment_set}"
16+
17+
18+
@dataclass(order=True, frozen=True)
19+
class CausalRelation:
20+
treatment: Node
21+
outcome: Node
22+
adjustment_set: Iterable[Node] = None
23+
24+
def __str__(self):
25+
formatted_string = f"{self.treatment} --> {self.outcome}"
26+
if self.adjustment_set:
27+
formatted_string += f" | {self.adjustment_set}"
28+
return formatted_string

0 commit comments

Comments
 (0)