Skip to content

Add test and reduce namespace requirements for sim_gs_n() with updated bounds #331

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

Merged
merged 4 commits into from
May 29, 2025

Conversation

jdblischak
Copy link
Collaborator

@jdblischak jdblischak commented May 27, 2025

This is a follow-up to PR #324 which enabled updating the bounds in a simulation performed by sim_gs_n().

  1. First I added a test. I used the deprecated expect_equivalent() because we are still using {testthat} edition 2 (the replacement is only available with edition 3) UPDATE: I also migrated to {testthat} edition 3
  2. I replaced dplyr::filter() with base::tapply() and dplyr::group_by()+dplyr::summarize() with base::tapply(). Note that tapply(summarize = TRUE) returns a 1-D array, but this appears to be sufficient for our use case UDPATE: And since the test I added doesn't cover all possible code paths, I decided to be cautious and explicitly convert it to a numeric vector with as.numeric()

@jdblischak jdblischak requested a review from LittleBeannie May 27, 2025 17:34
@jdblischak jdblischak self-assigned this May 27, 2025
Copy link
Collaborator

@nanxstats nanxstats left a comment

Choose a reason for hiding this comment

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

Let's maybe avoid using deprecated testthat APIs when possible? You know we have been using local_edition(3) to switch this at the test level all the time.

usethis::use_testthat(edition = 3)

I didn't enable test parallelization because some of our functions
run in parallel in the test files.
@jdblischak jdblischak requested a review from nanxstats May 28, 2025 16:56
@jdblischak
Copy link
Collaborator Author

Note that the example I used to create the test does not cover all the code paths. I updated obs_event, but only one of its potential downstream manipulations was tested. From the coverage report of this PR:

image

tapply() returns a 1-D array, which is likely fine, but better to
be explicit than to rely on R's automatic conversions to do what
we expect.
Copy link
Collaborator

@nanxstats nanxstats left a comment

Choose a reason for hiding this comment

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

The other code paths look familiar... The gsDesign web interface generates similar code if you switch the "interim and final analysis alpha spending strategy" options in the Update tab.

Copy link
Collaborator

@LittleBeannie LittleBeannie left a comment

Choose a reason for hiding this comment

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

Thanks, @jdblischak!

@LittleBeannie LittleBeannie merged commit 99f1aed into Merck:main May 29, 2025
9 checks passed
@jdblischak jdblischak deleted the update-bounds-no-dplyr branch May 29, 2025 17:06
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