Repository navigation
Tests for get_allele_freqs, compute_reference_prop and cpt_population - #39
Merged
Merged
Conversation
…tion Each file has at least one case worked out by hand (a small table for get_allele_freqs and compute_reference_prop, the product of marginals for cpt_population), so a wrong result fails instead of being compared with itself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First part of the uncovered exports task, the three you suggested starting with.
I ran
covr::package_coverage(type = "tests")on main first to confirm the grep. 12 of the 13 are at 0%.get_allele_freqsis the exception: it's at 100% because other tests reach it, so it was covered indirectly like you thought. I still added a test for it since nothing checked its output.Each file has a case worked out by hand:
get_allele_freqs: a 4-allele table typed in, plus a check that every bundled database keeps all its markers and allele namescompute_reference_prop: 5 people with known combinations (2/5, 1/5, ...), plus a direct count againstsim_reference_pop()cpt_population: the full 4 x 5 table written as the product of marginals, plus margins and the normalising warningsTo make sure the tests can actually fail I broke each function on purpose and reran:
Something that looks wrong, R/cpt_population.R:109 and 128-133. When the age range goes past [1, 80] it warns "clamping to valid range", but it never clamps:
So you get negative probabilities. With
MPa = 78, MPr = 6it uses P(T1) = 12/80 even though only ages 72..80 exist. The app'sbuild_cpt_pop()does clamp (max(1, MPa - MPr)), so the two disagree. I didn't add a test for this because I'm not sure which fix you want (clamp like the app, or error), and the function is soft-deprecated anyway.The other 10 functions come in later PRs.