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

add creat_arm by lose sum(accr_para) == 1 to is_wholenumber(sum(accr_para) - 1) #345

Conversation

LittleBeannie
Copy link
Collaborator

@LittleBeannie LittleBeannie commented Feb 22, 2024

Fixes #344

@LittleBeannie LittleBeannie self-assigned this Feb 22, 2024
@LittleBeannie LittleBeannie added the bug Something isn't working label Feb 22, 2024
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.

I appreciate the idea but the best way is to contribute a patch to the upstream dependency and let the maintainer make a CRAN release.

Copying an entire function (implementation) with one thing changed instead of coding against the interface is problematic. This is because if the upstream dependency changes their internal implementations, those changes can easily break you package, as your modified copy is not updated.

The approach here will likely become technical debt and add extra burden to refactor.

@nanxstats
Copy link
Collaborator

nanxstats commented Feb 23, 2024

Your code also loosened the original condition. The new logic only checked if the number is almost any integer:

if (length(accr_interval) > 2 && !is_wholenumber(sum(accr_param) - 1))

but not checking if the number is almost 1L specifically. It should be something like this:

is_almost_k <- function(x, k, tol = .Machine$double.eps^0.5) abs(x - k) < tol

if (length(accr_interval) > 2 && !is_almost_k(sum(accr_param), k = 1L))

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.

Following today's discussion, let's merge this so we have a working version for the short term, and create an issue #346 on reverting it back once npsurvSS is patched in the future.

@nanxstats nanxstats merged commit 2fadd4f into main Feb 23, 2024
8 checks passed
@nanxstats nanxstats deleted the 344-bug-of-gs_design_wlr-when-the-input-enroll_rates-rate-sum-is-not-1 branch February 23, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug of gs_design_wlr when the input enroll_rate's rate sum is not 1
2 participants