Skip to content

Commit

Permalink
Merge pull request #6 from scverse/variables
Browse files Browse the repository at this point in the history
Simplify .variables
  • Loading branch information
grst authored Dec 1, 2024
2 parents 9d62570 + 51b0a24 commit 8d2215f
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/formulaic_contrasts/_contrasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ def __init__(self, data: pd.DataFrame, design: str):
@property
def variables(self):
"""Get the names of the variables used in the model definition."""
try:
return self.design_matrix.model_spec.variables_by_source["data"]
except AttributeError:
raise ValueError(
"Retrieving variables is only possible if the model was initialized using a formula."
) from None
return self.design_matrix.model_spec.variables_by_source["data"]

def cond(self, **kwargs):
"""
Expand All @@ -47,10 +42,6 @@ def cond(self, **kwargs):
-------
A contrast vector that aligns to the columns of the design matrix.
"""
if self.factor_storage is None:
raise RuntimeError(
"Building contrasts with `cond` only works if you specified the model using a formulaic formula. Please manually provide a contrast vector."
)
cond_dict = kwargs
if not set(cond_dict.keys()).issubset(self.variables):
raise ValueError(
Expand Down

0 comments on commit 8d2215f

Please sign in to comment.