Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Bug in sign_plot leads to all insignificant plot when using DataFrame #79

Closed
feiden opened this issue Dec 17, 2024 · 4 comments
Closed
Assignees
Labels

Comments

@feiden
Copy link

feiden commented Dec 17, 2024

Describe the bug
A call by reference in the sign_plot method leads to a bad plot if using a DataFrame.

To Reproduce
Minimal example:

import statsmodels.api as sa
import scikit_posthocs as sp
df = sa.datasets.get_rdataset('iris').data
post_hoc = sp.posthoc_ttest(df, val_col='Sepal.Width', group_col='Species', p_adjust='holm')
fig = sp.sign_plot(post_hoc, flat=False)[0].get_figure()

Solution
Change xc = df.values to xc = df.values.copy() in line 195 in plotting.py

Last Words
Thank you for this nice open source code :)

@maximtrp
Copy link
Owner

Hi! Thank you for reporting, but there is no bug. Please look at line 194. DataFrames are being copied now, so no need for any other changes.

@feiden
Copy link
Author

feiden commented Dec 18, 2024

Hi Maxim, yes the dataframe is being copied as df, but xc is not copied from df. Later df (lines 224-227) is being changed based on the values of xc, but when changing df, xc changes too, leading to an error. You should be able to see that in the code example I provided, no? Maybe this error only occurs with certain versions, idk?

@feiden
Copy link
Author

feiden commented Dec 18, 2024

Maybe I should note, that it does not throw an error, but rather the values get incorrect

@maximtrp
Copy link
Owner

maximtrp commented Dec 18, 2024

Sorry, did not inspect it carefully. Released the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants