Skip to content

Commit

Permalink
Merge pull request #215 from UCD-SERG/create-test-for-as_curve_params
Browse files Browse the repository at this point in the history
add as_curve_params test
  • Loading branch information
d-morrison authored Jul 30, 2024
2 parents 9e03e77 + a2e8c01 commit b2567be
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/as_curve_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#' as_curve_params()
#'
#' print(curve_data)

as_curve_params <- function(data, antigen_isos = NULL) {
curve_data <-
data %>%
Expand All @@ -23,7 +22,10 @@ as_curve_params <- function(data, antigen_isos = NULL) {

# check if object is curve (with columns)
if (!all(is.element(curve_cols, curve_data %>% names()))) {
cli::cli_abort("Please provide curve data")
cli::cli_abort(
class = "not curve_params",
message = c("Please provide curve data.") # TO DO: 'or check variable names' (message)
)
}

# assign curve class
Expand Down
124 changes: 124 additions & 0 deletions tests/testthat/_snaps/as_curve_params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# `as_curve_params()` produces expected results

Code
test_data
Output
# A tibble: 100 x 7
antigen_iso iter y0 y1 t1 alpha r
<fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
1 HlyE_IgA 1 2.48 63.5 9.52 0.000581 1.75
2 HlyE_IgG 1 3.04 164. 6.55 0.00457 1.17
3 LPS_IgA 1 0.748 103. 4.98 0.00308 1.58
4 LPS_IgG 1 0.941 320. 6.14 0.00166 1.41
5 Vi_IgG 1 8.46 4348. 3.07 0.0000340 1.06
6 HlyE_IgA 2 3.86 288. 1.27 0.000459 2.66
7 HlyE_IgG 2 1.82 154. 10.8 0.000921 1.30
8 LPS_IgA 2 1.76 852. 2.49 0.000126 2.91
9 LPS_IgG 2 0.434 20.6 4.29 0.00122 1.37
10 Vi_IgG 2 18.8 345. 3.48 0.000142 1.02
# i 90 more rows

---

WAoAAAACAAQEAQACAwAAAAMTAAAABwAAAw0AAABkAAAAAQAAAAIAAAADAAAABAAAAAUAA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Si
/j/+QH3pPRWGQBNKuwuhMck/8/QqDh+ZuD/9ZfKAQRPaP/YoWFMfEglAAqaXA6A5Qz/4dJZx
IGCwP/ZccM0T1sY/9VnuhCymUEABvqpnN0tEQAWUjQ2bcdM/+E24fmQLxj/winainbFvQAcH
QhFvIeZAB6WqVyowCkABzoJsYoXSP/lox/vSuBo/84fVm8S5ID/2C0Vv2A9xP/yabpid0npA
AkiF5Du5qT/373K2lK7oP/By7+5oG4xAC2bhEJpDoz/zdkYlYLLPQABjLSzXpMg/9kV4DGLW
bz//mn9BoV6WAAAEAgAAAv8AAAAQAAAABAAEAAkAAAAMY3VydmVfcGFyYW1zAAQACQAAAAZ0
YmxfZGYABAAJAAAAA3RibAAEAAkAAAAKZGF0YS5mcmFtZQAABAIAAAABAAQACQAAAAlyb3cu
bmFtZXMAAAANAAAAAoAAAAD///+cAAAEAgAAAAEABAAJAAAABW5hbWVzAAAAEAAAAAcABAAJ
AAAAC2FudGlnZW5faXNvAAQACQAAAARpdGVyAAQACQAAAAJ5MAAEAAkAAAACeTEABAAJAAAA
AnQxAAQACQAAAAVhbHBoYQAEAAkAAAABcgAABAIAAAABAAQACQAAAAxhbnRpZ2VuX2lzb3MA
AAMNAAAABQAAAAEAAAACAAAAAwAAAAQAAAAFAAAEAgAAAf8AAAAQAAAABQAEAAkAAAAISGx5
RV9JZ0EABAAJAAAACEhseUVfSWdHAAQACQAAAAdMUFNfSWdBAAQACQAAAAdMUFNfSWdHAAQA
CQAAAAZWaV9JZ0cAAAQCAAAC/wAAABAAAAABAAQACQAAAAZmYWN0b3IAAAD+AAAA/g==

27 changes: 27 additions & 0 deletions tests/testthat/test-as_curve_params.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
test_that("`as_curve_params()` produces an error when non-curve data is provided", {
library(magrittr)
expect_error(
object = curve_data <-
"https://osf.io/download//n6cp3/" %>% # pop data
readr::read_rds() %>%
as_curve_params(),
class = "not curve_params"
)
})

test_that("`as_curve_params()` produces expected results", {
library(dplyr)
test_data <- "https://osf.io/download/rtw5k/" %>% # curve data
readr::read_rds() %>%
slice_head(n = 100) %>%
as_curve_params()

expect_snapshot(test_data)

expect_snapshot_value(
x = test_data,
style = "serialize"
)


})

0 comments on commit b2567be

Please sign in to comment.