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

- added snapshot test for df_to_array() #276

Merged
merged 40 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c70e6ef
renaming
d-morrison Sep 24, 2024
72ef142
rename file
d-morrison Sep 24, 2024
c6ef21f
in progress
d-morrison Sep 25, 2024
c3103b2
generalizing
d-morrison Sep 25, 2024
a9008fc
updated news
d-morrison Sep 25, 2024
7f6b817
Merge pull request #273 from UCD-SERG/263-generalize-attribute-extrac…
d-morrison Sep 25, 2024
1503b42
document
d-morrison Sep 25, 2024
1e83040
in progress
d-morrison Sep 25, 2024
39493aa
add `antigen_isos" attribute to `curve-params` class
d-morrison Sep 25, 2024
3053f66
Merge pull request #275 from UCD-SERG/263-generalize-attribute-extrac…
d-morrison Sep 25, 2024
9702eb7
Merge branch '264-test-simcs' of https://github.com/UCD-SERG/serocalc…
d-morrison Sep 25, 2024
a93547e
in progress
d-morrison Sep 25, 2024
1d086ef
- added snapshot test for `df_to_array()`
d-morrison Sep 25, 2024
024d192
Increment version number to 1.2.0.9003
d-morrison Sep 25, 2024
3a549f8
Merge pull request #277 from UCD-SERG/test-df_to_array
d-morrison Sep 25, 2024
caeeea3
Merged origin/264-test-simcs into 264-test-simcs
d-morrison Sep 25, 2024
0c9336f
fixing lint
d-morrison Sep 25, 2024
da75e82
simplify to remove lint
d-morrison Sep 25, 2024
d605437
adding news
d-morrison Sep 25, 2024
7a60546
lint
d-morrison Sep 25, 2024
bd5b1f9
lint
d-morrison Sep 25, 2024
56fdbec
fix lint
d-morrison Sep 25, 2024
9dae175
Merge pull request #279 from UCD-SERG/263-generalize-attribute-extrac…
d-morrison Sep 25, 2024
dc1ca40
fix dplyr syntax warning
d-morrison Sep 25, 2024
727f037
regenerate docs
d-morrison Sep 25, 2024
dfbb24c
fix
d-morrison Sep 25, 2024
0b247fe
exclude deprecated function name from name linter
d-morrison Sep 25, 2024
a86c1ac
line lengths
d-morrison Sep 25, 2024
f0b4943
more linting
d-morrison Sep 25, 2024
d82381a
update documentation
d-morrison Sep 25, 2024
2211e0a
Merge branch '264-test-simcs' into test-df_to_array
d-morrison Sep 25, 2024
5ea6b74
Revert "Merge branch '264-test-simcs' into test-df_to_array"
d-morrison Sep 25, 2024
a7803a3
Merged origin/main into test-df_to_array
d-morrison Sep 26, 2024
7a2b8a4
Increment version number to 1.2.0.9004
d-morrison Sep 26, 2024
bfcdc62
Merge branch 'main' into test-df_to_array
d-morrison Sep 26, 2024
e1a00e9
increment version
d-morrison Sep 26, 2024
80f91f2
Merge branch 'main' into test-df_to_array
chrisorwa Sep 29, 2024
9915ad7
Merge branch 'main' into test-df_to_array
d-morrison Sep 30, 2024
b5ca13c
Merge branch 'main' into test-df_to_array
d-morrison Sep 30, 2024
834ce1d
Increment version number to 1.2.0.9009
d-morrison Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: serocalculator
Type: Package
Title: Estimating Infection Rates from Serological Data
Version: 1.2.0.9003
Version: 1.2.0.9004
Authors@R: c(
person(given = "Peter", family = "Teunis", email = "[email protected]", role = c("aut", "cph"), comment = "Author of the method and original code."),
person(given = "Kristina", family = "Lai", email = "[email protected]", role = c("aut", "cre")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# serocalculator (development version)

* created unit test for `df_to_array()`
* fixed `dplyr::select()` deprecation warning in `df_to_array()`

# serocalculator 1.2.0
* Added `test-summary.pop_data` test

Expand Down
22 changes: 14 additions & 8 deletions R/df_to_array.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @keywords internal
#'
df.to.array <- function(
df.to.array <- function( # nolint: object_name_linter
Copy link
Member Author

@d-morrison d-morrison Sep 26, 2024

Choose a reason for hiding this comment

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

we skip linting this particular variable name because it is the deprecated version of the renamed function, and thus cannot be renamed here.

df,
dim_var_names,
value_var_name = "value") {
Expand All @@ -18,10 +18,14 @@ df.to.array <- function(

#' Convert a data.frame (or tibble) into a multidimensional array
#'
#' @param df a [data.frame()] (or [tibble::tibble()]) in long format (each row contains one value for the intended array)
#' @param dim_var_names a [character()] vector of variable names in `df`. All of these variables should be factors, or a warning will be produced.
#' @param value_var_name a [character()] variable containing a variable name from `df` which contains the values for the intended array.
#' @return an [array()] with dimensions defined by the variables in `df` listed in `dim_var_names`
#' @param df a [data.frame()] (or [tibble::tibble()]) in long format
#' (each row contains one value for the intended array)
#' @param dim_var_names a [character()] vector of variable names in `df`.
#' All of these variables should be factors, or a warning will be produced.
#' @param value_var_name a [character()] variable containing a variable name
#' from `df` which contains the values for the intended array.
#' @return an [array()] with dimensions defined by the variables in `df`
#' listed in `dim_var_names`
#'
#' @examples
#' library(dplyr)
Expand All @@ -33,7 +37,9 @@ df.to.array <- function(
#' cols = c("Sepal.Length", "Sepal.Width", "Petal.Width", "Petal.Length")
#' ) %>%
#' mutate(parameter = factor(parameter, levels = unique(parameter)))
#' arr <- df %>% serocalculator:::df.to.array(dim_var_names = c("parameter", "Species"))
#' arr <- df %>%
#' serocalculator:::df_to_array(
#' dim_var_names = c("parameter", "Species"))
#' ftable(arr[,,1:5])
#' @noRd
df_to_array <- function(
Expand All @@ -49,7 +55,7 @@ df_to_array <- function(

all_factors <-
df %>%
select(dim_var_names) %>%
select(all_of(dim_var_names)) %>%
sapply(FUN = is.factor) %>%
all()

Expand Down Expand Up @@ -77,6 +83,6 @@ df_to_array <- function(
)

df %>%
mutate(.by = all_of(dim_var_names), obs = 1:n()) %>%
mutate(.by = all_of(dim_var_names), obs = row_number()) %>%
xtabs(formula = formula(xtabs_formula))
}
111 changes: 111 additions & 0 deletions tests/testthat/_snaps/df_to_array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# df_to_array() produces consistent results

WAoAAAACAAQEAQACAwAAAAMOAAACWEAUZmZmZmZmQAwAAAAAAAA/yZmZmZmZmj/2ZmZmZmZm
QBwAAAAAAABACZmZmZmZmj/2ZmZmZmZmQBLMzMzMzM1AGTMzMzMzM0AKZmZmZmZmQAQAAAAA
AABAGAAAAAAAAEATmZmZmZmaQAgAAAAAAAA/yZmZmZmZmj/2ZmZmZmZmQBmZmZmZmZpACZmZ
mZmZmj/4AAAAAAAAQBIAAAAAAABAFzMzMzMzM0AFmZmZmZmaP/5mZmZmZmZAFGZmZmZmZkAS
zMzMzMzNQAmZmZmZmZo/yZmZmZmZmj/0zMzMzMzNQBuZmZmZmZpACMzMzMzMzT/4AAAAAAAA
QBOZmZmZmZpAHGZmZmZmZkAIAAAAAAAAQADMzMzMzM1AF5mZmZmZmkASZmZmZmZmQAjMzMzM
zM0/yZmZmZmZmj/4AAAAAAAAQBYAAAAAAABAAmZmZmZmZj/0zMzMzMzNQBAAAAAAAABAGTMz
MzMzM0AHMzMzMzMzP/zMzMzMzM1AFmZmZmZmZkAUAAAAAAAAQAzMzMzMzM0/yZmZmZmZmj/2
ZmZmZmZmQBoAAAAAAABABmZmZmZmZj/4AAAAAAAAQBJmZmZmZmZAGgAAAAAAAEAIAAAAAAAA
QAGZmZmZmZpAFzMzMzMzM0AVmZmZmZmaQA8zMzMzMzM/2ZmZmZmZmj/7MzMzMzMzQBbMzMzM
zM1ABmZmZmZmZj/0zMzMzMzNQBIAAAAAAABAHmZmZmZmZkAIAAAAAAAAQADMzMzMzM1AGmZm
ZmZmZkASZmZmZmZmQAszMzMzMzM/0zMzMzMzMz/2ZmZmZmZmQBkzMzMzMzNACmZmZmZmZj/5
mZmZmZmaQBLMzMzMzM1AE5mZ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AAAACMjUABAAJAAAA
AjI2AAQACQAAAAIyNwAEAAkAAAACMjgABAAJAAAAAjI5AAQACQAAAAIzMAAEAAkAAAACMzEA
BAAJAAAAAjMyAAQACQAAAAIzMwAEAAkAAAACMzQABAAJAAAAAjM1AAQACQAAAAIzNgAEAAkA
AAACMzcABAAJAAAAAjM4AAQACQAAAAIzOQAEAAkAAAACNDAABAAJAAAAAjQxAAQACQAAAAI0
MgAEAAkAAAACNDMABAAJAAAAAjQ0AAQACQAAAAI0NQAEAAkAAAACNDYABAAJAAAAAjQ3AAQA
CQAAAAI0OAAEAAkAAAACNDkABAAJAAAAAjUwAAAEAgAAAAEABAAJAAAABW5hbWVzAAAAEAAA
AAMABAAJAAAACXBhcmFtZXRlcgAEAAkAAAAHU3BlY2llcwAEAAkAAAADb2JzAAAA/gAABAIA
AAABAAQACQAAAAVjbGFzcwAAABAAAAACAAQACQAAAAV4dGFicwAEAAkAAAAFdGFibGUAAAQC
AAAAAQAEAAkAAAAEY2FsbAAAAAYAAAABAAQACQAAAAV4dGFicwAABAIAAAABAAQACQAAAAdm
b3JtdWxhAAAABgAAB/8AAAACAAAAAQAEAAkAAAANeHRhYnNfZm9ybXVsYQAAAP4AAAQCAAAA
AQAEAAkAAAAEZGF0YQAAAAEABAAJAAAAAS4AAAD+AAAA/g==

18 changes: 18 additions & 0 deletions tests/testthat/test-df_to_array.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
test_that("df_to_array() produces consistent results", {
library(dplyr)
library(tidyr)
df <- iris %>%
tidyr::pivot_longer(
names_to = "parameter",
cols = c(
"Sepal.Length",
"Sepal.Width",
"Petal.Width",
"Petal.Length"
)
) %>%
mutate(parameter = factor(parameter, levels = unique(parameter)))
arr <- df %>%
serocalculator:::df_to_array(dim_var_names = c("parameter", "Species"))
arr %>% expect_snapshot_value(style = "serialize")
})
Loading