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

Creating a file for the code shared by all _frequencies functions #690

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

jonbrenas
Copy link
Collaborator

Addresses #664 .

I moved the functions to enable the computation of frequencies and the plotting functions (which required to define a new AnophelesFrequency class). I still want to move the tests of the plotting functions to their own file instead of test_snp_frq.py.

@jonbrenas
Copy link
Collaborator Author

The tests for the plotting functions are still only on SNP frequencies. Is that good enough?

@jonbrenas
Copy link
Collaborator Author

@alimanfoo, I might have found a solution that works for what I wanted to do (namely, import shared testing functions for plotting frequencies into the various test_*_frq.pys) by telling pytest to ignore them when it reaches their file (it means that the tests now return the number of "passed", "skipped", "failed" tests (as well as warnings). I checked that when the tests are actually run when called in the relevant file, they would show a failure if they failed (i.e., they are not skipped when explicitly called).

@jonbrenas jonbrenas marked this pull request as ready for review January 2, 2025 14:04
Copy link
Member

@alimanfoo alimanfoo left a comment

Choose a reason for hiding this comment

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

Hi @jonbrenas, thanks so much. A few comments...

malariagen_data/anoph/frq_funcs.py Outdated Show resolved Hide resolved
malariagen_data/anoph/frq_funcs.py Outdated Show resolved Hide resolved
malariagen_data/anoph/hap_frq.py Show resolved Hide resolved
Comment on lines 1018 to 1020
transcript_ids = [
t.split(";")[0].split("=")[1] for t in df_transcripts.loc[:, "attributes"]
]
Copy link
Member

Choose a reason for hiding this comment

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

This relies on the ID appearing first within the attributes. Is there a safer and more obvious way to get the IDs? E.g., via gff3_parse_attributes() in util module?

tests/anoph/test_frq.py Outdated Show resolved Hide resolved
@alimanfoo
Copy link
Member

@alimanfoo, I might have found a solution that works for what I wanted to do (namely, import shared testing functions for plotting frequencies into the various test_*_frq.pys) by telling pytest to ignore them when it reaches their file (it means that the tests now return the number of "passed", "skipped", "failed" tests (as well as warnings). I checked that when the tests are actually run when called in the relevant file, they would show a failure if they failed (i.e., they are not skipped when explicitly called).

Thanks @jonbrenas. As suggested in the code review above, it might be even better to name these utility functions like "check_..." instead of "test_..." then no need for skipping.

If the importing of functions between test modules seems to work then I guess we're OK! I still don't understand the mechanics of how pytest imports test modules. But if you've confirmed it works then no objection.

@jonbrenas
Copy link
Collaborator Author

Thanks @alimanfoo. This all makes a lot of sense.

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 97.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 94.96%. Comparing base (cc1ce67) to head (8c0a432).
Report is 123 commits behind head on master.

Files with missing lines Patch % Lines
malariagen_data/anoph/frq_base.py 96.79% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #690      +/-   ##
==========================================
+ Coverage   94.57%   94.96%   +0.39%     
==========================================
  Files          40       45       +5     
  Lines        4187     4612     +425     
==========================================
+ Hits         3960     4380     +420     
- Misses        227      232       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leehart leehart requested review from alimanfoo and removed request for alimanfoo January 24, 2025 11:06
@leehart leehart self-requested a review January 24, 2025 11:58
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.

2 participants