-
Notifications
You must be signed in to change notification settings - Fork 10
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
temporary suggestion for testing simulate for design class #802
base: main
Are you sure you want to change the base?
Conversation
Hello @danielinteractive please review the suggestion for testing. I tried both, the scenario with fixed seeds (checking the full mySims object, thus inherently checking all subsequent scenarios) and the scenario which just checks for the "meta data" (i.e. lengths, classes etc.). Before continuing to apply that to all other methods in Design-methods I wanted to check in and ask for best-practice guidance. Also, I would suggest, if we agree on the testing strategy, to do all Design-methods testing in one branch / PR then because it will be quite straight forward to implement and review? |
Code Coverage Summary
Diff against main
Results for commit: f19a571 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @robertadamsbayer for the nice work! please see feedback below - I would simplify this further. yes, once agreed, we can put many tests in the same PR. no need to shoot for everything right away though, because then the PR gets again too large and takes too much time. incremental progress here is still best too
tests/testthat/test-helpers_design.R
Outdated
rng_kind = "Mersenne-Twister", | ||
rng_seed = 1234 | ||
) | ||
time <- system.time(mySims <- simulate(design, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to time this simulation run? (not sure, because time
is also not used below and would anyway differ between platforms)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fully agree - was a bit lazy from me taking that over from the examples...
tests/testthat/test-helpers_design.R
Outdated
expect_class(mySims, "Simulations") | ||
|
||
expect_equal(any(sapply(mySims@fit[[1]], is.numeric)), TRUE) # check if all elements in mySims@fit are numeric | ||
|
||
expect_equal(length(mySims@stop_report), 5) # check for length | ||
|
||
expect_logical(mySims@stop_report) # check for stop_report to be logical vector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like this would be sufficient
tests/testthat/test-helpers_design.R
Outdated
), | ||
))[3] | ||
|
||
expected <- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is too detailed / too much maintenance when numbers change etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for guidance! I will adopt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielinteractive Hi Daniel, I put the new "end-to-end" test for simulate in "test-helpers_design.R". When moving it over to "test-Design-methods.R" I realized that there are already tests (using snapshots) for simulate (and different classes) already implemented. Those use fixed rng seeds, therefore "mimicking" quite closely what you suggested not to do. I don´t know what to keep and what to get rid of there?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just leave existing tests. More coverage does not hurt us
Unit Test Performance Difference
Additional test case details
Results for commit abf2c65 ♻️ This comment has been updated with latest results. |
…ithub.com/Roche/crmPack into 798_code_coverage_for_simulate_for_design
Merge branch '798_code_coverage_for_simulate_for_design' of https://github.com/Roche/crmPack into 798_code_coverage_for_simulate_for_design # Conflicts: # tests/testthat/test-Design-methods.R
…602-621 in Deisn-methods, partially - not yet for placebo)
Hi @danielinteractive - in DualDesign there are placebo clauses which are not covered in tests yet (indicated by the missing rows in test coverage). When I create a dual design which contains placebo data and try to pass that to simulate I get the following error: Do we have a working example for DualDesign with placebo or ist that somehow a special case that I am not aware of? |
Thanks @robertadamsbayer , I would check the examples folder, if there is nothing it might be a bug ... and we would need to fix it |
This PR is parked for now, in order to prioritize tests for Simulation methods. |
Pull Request
Fixes #798