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

Squashing unintended test warnings due to model recombination rate #1626

Merged

Conversation

gregorgorjanc
Copy link
Contributor

As triggered by #1598 (comment) I looked into the test warnings due to model specific mutation and recombination rate.

One test warning was not intended, so I fixed that.

I am a bit confused what to do with these ones:

> python3 -m pytest tests/test_models.py
========================================================================= test session starts =========================================================================
platform darwin -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
rootdir: /Users/ggorjanc/Storages/GitBox/popsim/stdpopsim/stdpopsim_fork
configfile: setup.cfg
plugins: xdist-3.6.1
4 workers [275 items]   
............................................................................................................................................................... [ 57%]
....................................................................................................................                                            [100%]
========================================================================== warnings summary ===========================================================================
tests/test_models.py::TestBosTauHolsteinFriesian_1M13::test_simulation_runs
  /Users/ggorjanc/Storages/GitBox/popsim/stdpopsim/stdpopsim_fork/stdpopsim/engines.py:125: UserWarning: The demographic model has recombination rate 1e-08, but this simulation used the contig's recombination rate 0.0. Patterns of linkage may be different than expected for this species. For details see documentation at https://popsim-consortium.github.io/stdpopsim-docs/stable/tutorial.html
    warnings.warn(

tests/test_models.py::TestBosTauAngus_1B16::test_simulation_runs
  /Users/ggorjanc/Storages/GitBox/popsim/stdpopsim/stdpopsim_fork/stdpopsim/engines.py:125: UserWarning: The demographic model has recombination rate 5e-09, but this simulation used the contig's recombination rate 0.0. Patterns of linkage may be different than expected for this species. For details see documentation at https://popsim-consortium.github.io/stdpopsim-docs/stable/tutorial.html
    warnings.warn(

tests/test_models.py::TestBosTauHolsteinFriesian_1B16::test_simulation_runs
  /Users/ggorjanc/Storages/GitBox/popsim/stdpopsim/stdpopsim_fork/stdpopsim/engines.py:125: UserWarning: The demographic model has recombination rate 3.66e-09, but this simulation used the contig's recombination rate 0.0. Patterns of linkage may be different than expected for this species. For details see documentation at https://popsim-consortium.github.io/stdpopsim-docs/stable/tutorial.html
    warnings.warn(

tests/test_models.py::TestBosTauFleckvieh_1B16::test_simulation_runs
  /Users/ggorjanc/Storages/GitBox/popsim/stdpopsim/stdpopsim_fork/stdpopsim/engines.py:125: UserWarning: The demographic model has recombination rate 3.89e-09, but this simulation used the contig's recombination rate 0.0. Patterns of linkage may be different than expected for this species. For details see documentation at https://popsim-consortium.github.io/stdpopsim-docs/stable/tutorial.html
    warnings.warn(

tests/test_models.py::TestBosTauJersey_1B16::test_simulation_runs
  /Users/ggorjanc/Storages/GitBox/popsim/stdpopsim/stdpopsim_fork/stdpopsim/engines.py:125: UserWarning: The demographic model has recombination rate 4.58e-09, but this simulation used the contig's recombination rate 0.0. Patterns of linkage may be different than expected for this species. For details see documentation at https://popsim-consortium.github.io/stdpopsim-docs/stable/tutorial.html
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=================================================================== 275 passed, 5 warnings in 1.06s ===================================================================

As indicated by @nspope these seem to come from mitochondria (that have rec rate of 0), but I am getting lost in the code of how these tests are autogenerated and called. Can anyone suggest what I could do to capture these tests - they are making noise that we probably don't want?

Copy link

codecov bot commented Dec 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.84%. Comparing base (ff79d8d) to head (02e63ee).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1626   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files         130      130           
  Lines        4416     4416           
  Branches      608      608           
=======================================
  Hits         4409     4409           
  Misses          3        3           
  Partials        4        4           

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

@nspope
Copy link
Collaborator

nspope commented Dec 22, 2024

If the warnings are intended, then they can be filtered with pytest, by adding the annotation

@pytest.mark.filterwarnings("ignore::UserWarning")

above the test function (grep for "filterwarnings" in tests/*py to see examples).

Or maybe it's be better to be more specific, in case a UserWarning comes up in the future that is unintended (that we would want the tests to make obvious). So we could match the starting text,

@pytest.mark.filterwarnings("ignore: The demographic model has recombination rate")

@petrelharp
Copy link
Contributor

Thanks for the cleanup!

@petrelharp petrelharp merged commit d6e0406 into popsim-consortium:main Dec 23, 2024
11 checks passed
gregorgorjanc added a commit to gregorgorjanc/stdpopsim that referenced this pull request Dec 23, 2024
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.

3 participants