Skip to content

Commit

Permalink
Improve docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
grst committed Dec 7, 2024
1 parent f48b1b0 commit 0297391
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/formulaic_contrasts/_contrasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,24 @@ def cond(self, **kwargs):
"""
Get a contrast vector representing a specific condition.
The `kwargs` are key/value pairs where the key refers to a variable used in the
design and the value represents a category of that variable. Variables not specified
will be filled with their default/baseline value.
The vectors generated by `.cond` can be combined using standard arithmetic operations
to obtain the desired contrast, e.g.
>>> contrast = model.cond(treatment="drugA") - model.cond(treatment="placebo")
Parameters
----------
**kwargs
column/value pairs.
Returns
-------
A contrast vector that aligns to the columns of the design matrix.
A vector with one element per column in the design matrix,
where the kwargs arguments are coded as in the design matrix.
"""
cond_dict = kwargs
if not set(cond_dict.keys()).issubset(self.variables):
Expand All @@ -60,6 +70,9 @@ def contrast(self, column, baseline, group_to_compare):
"""
Build a simple contrast for pairwise comparisons.
For more complex contrasts, please use construct a contrast vector using
:func:`~formulaic_contrasts.FormulaicContrasts.cond`.
Parameters
----------
column
Expand Down

0 comments on commit 0297391

Please sign in to comment.