Skip to content

Commit

Permalink
Fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvallat committed Nov 11, 2023
1 parent a3a62ac commit 2d35aea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
3 changes: 2 additions & 1 deletion pingouin/contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ def chi2_independence(data, x, y, correction=True):
>>> import pingouin as pg
>>> data = pg.read_dataset('chi2_independence')
>>> data['sex'].value_counts(ascending=True)
sex
0 96
1 207
Name: sex, dtype: int64
Name: count, dtype: int64
If gender is not a good predictor for heart disease, we should expect the
same 96:207 ratio across the target classes.
Expand Down
34 changes: 16 additions & 18 deletions pingouin/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,17 +680,16 @@ def epsilon(data, dv=None, within=None, subject=None, correction="gg"):
levels:
>>> # Pivot from long-format to wide-format
>>> piv = data.pivot_table(index='Subject', columns=['Time', 'Metric'],
... values='Performance')
>>> piv = data.pivot(index='Subject', columns=['Time', 'Metric'], values='Performance')
>>> piv.head()
Time Post Pre
Metric Action Client Product Action Client Product
Time Pre Post
Metric Product Client Action Product Client Action
Subject
1 34 30 18 17 12 13
2 30 18 6 18 19 12
3 32 31 21 24 19 17
4 40 39 18 25 25 12
5 27 28 18 19 27 19
1 13 12 17 18 30 34
2 12 19 18 6 18 30
3 17 19 24 21 31 32
4 12 25 25 18 39 40
5 19 27 19 18 28 27
>>> round(pg.epsilon(piv), 3)
0.727
Expand Down Expand Up @@ -934,17 +933,16 @@ def sphericity(data, dv=None, within=None, subject=None, method="mauchly", alpha
levels:
>>> # Pivot from long-format to wide-format
>>> piv = data.pivot_table(index='Subject', columns=['Time', 'Metric'],
... values='Performance')
>>> piv = data.pivot(index='Subject', columns=['Time', 'Metric'], values='Performance')
>>> piv.head()
Time Post Pre
Metric Action Client Product Action Client Product
Time Pre Post
Metric Product Client Action Product Client Action
Subject
1 34 30 18 17 12 13
2 30 18 6 18 19 12
3 32 31 21 24 19 17
4 40 39 18 25 25 12
5 27 28 18 19 27 19
1 13 12 17 18 30 34
2 12 19 18 6 18 30
3 17 19 24 21 31 32
4 12 25 25 18 39 40
5 19 27 19 18 28 27
>>> spher, _, chisq, dof, pval = pg.sphericity(piv)
>>> print(spher, round(chisq, 3), dof, round(pval, 3))
Expand Down

0 comments on commit 2d35aea

Please sign in to comment.