Skip to content

Commit

Permalink
Do not provide default method for S3 generic wlr()
Browse files Browse the repository at this point in the history
  • Loading branch information
jdblischak committed Aug 20, 2024
1 parent b3e480d commit 875d1f6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(wlr,counting_process)
S3method(wlr,default)
S3method(wlr,tte_data)
export(counting_process)
export(create_cut)
Expand Down
11 changes: 3 additions & 8 deletions R/wlr.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,16 @@ wlr <- function(data, weight, return_variance = FALSE) {
UseMethod("wlr", data)
}

#' @rdname wlr
#' @export
wlr.counting_process <- function(data, weight, return_variance = FALSE) {
wlr.default(data, weight, return_variance = FALSE)
}

#' @rdname wlr
#' @export
wlr.tte_data <- function(data, weight, return_variance = FALSE) {
x <- data |> counting_process(arm = "experimental")
wlr.default(x, weight, return_variance = FALSE)
wlr.counting_process(x, weight, return_variance = FALSE)
}

#' @rdname wlr
#' @export
wlr.default <- function(data, weight, return_variance = FALSE) {
wlr.counting_process <- function(data, weight, return_variance = FALSE) {
x <- data

# calculate the sample size and randomization ratio
Expand Down
6 changes: 3 additions & 3 deletions man/wlr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/testthat/test-unvalidated-wlr.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ test_that("wlr() accepts tte_data and counting_process objects as input", {

expect_equal(results_tte_data, results_counting_process)
})

test_that("wlr() rejects input object without proper class", {
x <- mtcars
expect_error(wlr(x), "no applicable method")
})

0 comments on commit 875d1f6

Please sign in to comment.