Skip to content

Assumption

Signature/Parameters

class Assumption

Structured representation of a causal inference assumption.

Source code in causalinf/assumptions.py
@dataclass(frozen=True)
class Assumption:
    """Structured representation of a causal inference assumption."""

    key: str
    name: str
    assumption_type: str
    usage: List[str]
    definition: str
    method: str
    scope: str = ""
    role: str = ""
    violation: str = ""
    aliases: List[str] = field(default_factory=list)
    notes: str = ""
    required: Optional[str] = None
    testable: Optional[str] = None

    def __post_init__(self):
        normalized_type = self.assumption_type.strip().lower()
        if normalized_type not in ASSUMPTION_TYPES:
            raise ValueError(
                "assumption_type must be one of: " + ", ".join(ASSUMPTION_TYPES)
            )
        object.__setattr__(self, "assumption_type", normalized_type)
        object.__setattr__(self, "usage", [u.strip().lower() for u in self.usage])

    def to_dict(self):
        """Return the legacy dictionary representation used by older callers."""
        data = asdict(self)
        data.pop("key")
        return data