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

Added unit test to test labelling with floats on the x_axis #84

Merged
merged 1 commit into from
Jan 27, 2023
Merged

Added unit test to test labelling with floats on the x_axis #84

merged 1 commit into from
Jan 27, 2023

Conversation

JasonMendoza2008
Copy link
Contributor

@JasonMendoza2008 JasonMendoza2008 commented Oct 17, 2022

To enhance tests for float values on the x_axis (they are currently supported). Also added PyCharm IDE files to the .gitignore file to avoid accidental commit of these files. Refers to this issue: #65

Not sure if the test is properly coded (EDIT: second commit should make the whole thing closer to what was already in place). In case the commit is not clear, here is the code (user-oriented) to create the figure and make sure the result is the one expected that I used as inspiration to make the unit test (I checked it did not run and now runs with your latest commits):

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
from statannotations.Annotator import Annotator

y_axis = [16.99, 10.34, 21.01, 23.68, 24.59, 25.29, 8.77, 26.88, 15.04, 14.78, 10.27, 35.26, 15.42, 18.43, 14.83, 21.58,
          10.33, 16.29, 16.97, 20.65, 17.92, 20.29, 15.77, 39.42, 19.82, 17.81, 13.37, 12.69, 21.7, 19.65, 9.55, 18.35,
          15.06, 20.69, 17.78, 24.06, 16.31, 16.93, 18.69, 31.27, 16.04, 17.46, 13.94, 9.68, 30.4, 18.29, 22.23, 32.4,
          28.55, 18.04]
x_axis = [1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03,
          1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03,
          1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02, 1.03, 1.01, 1.02]
df = pd.DataFrame(data={"y_axis": y_axis, "x_axis": x_axis})
x = "x_axis"
y = "y_axis"
order = [1.01, 1.02, 1.03]

ax = sns.boxplot(data=df, x=x, y=y, order=order)

pairs = [(1.01, 1.02), (1.02, 1.03)]

annotator = Annotator(ax, pairs, data=df, x=x, y=y, order=order)
annotator.configure(test='Mann-Whitney', text_format='star', loc='outside')
annotator.apply_and_annotate()
plt.savefig('test.png', dpi=300, bbox_inches='tight')

@trevismd trevismd changed the base branch from master to dev October 17, 2022 15:58
@codecov
Copy link

codecov bot commented Oct 17, 2022

Codecov Report

Merging #84 (ace2592) into dev (c123a61) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head ace2592 differs from pull request most recent head 45cfdc5. Consider uploading reports for the commit 45cfdc5 to get more accurate results

@@            Coverage Diff             @@
##              dev      #84      +/-   ##
==========================================
+ Coverage   97.04%   97.06%   +0.01%     
==========================================
  Files          29       29              
  Lines        1898     1907       +9     
==========================================
+ Hits         1842     1851       +9     
  Misses         56       56              
Impacted Files Coverage Δ
tests/test_annotator.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Owner

@trevismd trevismd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JasonMendoza2008 , thanks for the quick reply and PR, I appreciate it!
I left a few comments in case you're willing and have the time to go a little further with it.
As before, please let me know if I can be of assistance.

tests/test_annotator.py Outdated Show resolved Hide resolved
tests/test_annotator.py Outdated Show resolved Hide resolved
tests/test_annotator.py Outdated Show resolved Hide resolved
tests/test_annotator.py Outdated Show resolved Hide resolved
Copy link
Owner

@trevismd trevismd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @JasonMendoza2008 !
Thanks for the update. Nice job! We are about ready here, except for two minor things about unnecessary diff.
If possible, would you also please squash your commits into a single one? (You'll then have to force push the branch on github)

tests/test_annotator.py Outdated Show resolved Hide resolved
tests/test_annotator.py Outdated Show resolved Hide resolved
Unit tests to test labelling with floats on the x_axis
@JasonMendoza2008
Copy link
Contributor Author

Hello @trevismd
I have squashed all commits and restored the blank line. For some reason I had to use the terminal and not PyCharm to squash the commits and to force push because they were greyed out in my IDE. Do you have any idea why that's the case? It's the first time that that's happening to me.

@JasonMendoza2008
Copy link
Contributor Author

@trevismd anything I should do? Tests failed on Python 3.6 but it seems to be github related.

@trevismd trevismd merged commit e551b58 into trevismd:dev Jan 27, 2023
@trevismd
Copy link
Owner

Thank you for your contribution and patience, @JasonMendoza2008 !
The problem is due to the availability of Python 3.6 in Ubuntu 22.04. I've already pushed a commit for it to the dev branch so this should work fine. (Finally, I'm afraid I can't come up with any idea about your squashing issue)

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

Successfully merging this pull request may close these issues.

None yet

2 participants