Skip to content

Commit

Permalink
hotfix: plot_rm_corr crash with specific column names (#351)
Browse files Browse the repository at this point in the history
* hotfix: plot_rm_corr crash with specific column names

* missed a formula
  • Loading branch information
remrama authored Mar 9, 2023
1 parent 8c92b6d commit c22843f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pingouin/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,8 @@ def anovan(data=None, dv=None, between=None, ss_type=2, effsize="np2"):
# C marks the data as categorical
# Q allows to quote variable that do not meet Python variable name rule
# e.g. if variable is "weight.in.kg" or "2A"
assert dv not in ["C", "Q"], "`dv` must not be 'C' or 'Q'."
assert all(fac not in ["C", "Q"] for fac in between), "`between` must not contain 'C' or 'Q'."
formula = "Q('%s') ~ " % dv
for fac in between:
formula += "C(Q('%s'), Sum) * " % fac
Expand Down Expand Up @@ -1709,6 +1711,9 @@ def ancova(data=None, dv=None, between=None, covar=None, effsize="np2"):

# Fit ANCOVA model
# formula = dv ~ 1 + between + covar1 + covar2 + ...
assert dv not in ["C", "Q"], "`dv` must not be 'C' or 'Q'."
assert between not in ["C", "Q"], "`between` must not be 'C' or 'Q'."
assert all(c not in ["C", "Q"] for c in covar), "`covar` must not contain 'C' or 'Q'."
formula = "Q('%s') ~ C(Q('%s'))" % (dv, between)
for c in covar:
formula += " + Q('%s')" % (c)
Expand Down
3 changes: 3 additions & 0 deletions pingouin/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,9 @@ def plot_rm_corr(
# C marks the data as categorical
# Q allows to quote variable that do not meet Python variable name rule
# e.g. if variable is "weight.in.kg" or "2A"
assert x not in ["C", "Q"], "`x` must not be 'C' or 'Q'."
assert y not in ["C", "Q"], "`y` must not be 'C' or 'Q'."
assert subject not in ["C", "Q"], "`subject` must not be 'C' or 'Q'."
formula = "Q('%s') ~ C(Q('%s')) + Q('%s')" % (y, subject, x)
model = ols(formula, data=data).fit()

Expand Down

0 comments on commit c22843f

Please sign in to comment.