Skip to content

Commit

Permalink
support for 64 bit ids in manc_annotate_body
Browse files Browse the repository at this point in the history
* extends to other fields
  • Loading branch information
jefferis committed Jan 25, 2024
1 parent ec10184 commit cea3eac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/annotate.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@ clioannotationdf2list <- function(x, write_empty_fields=FALSE) {
}

# turns it into a list of lists
i64class=class(x$bodyid)
i64cols=sapply(x, inherits, 'integer64')
x=purrr::transpose(x)
fix_bodyid <- function(x) {class(x[['bodyid']]) <-i64class; x}
x=purrr::map(x, fix_bodyid)
fix_bodyid <- function(x, cols='bodyid') {for(col in cols) class(x[[col]]) <-'integer64'; x}
x=purrr::map(x, fix_bodyid, cols=which(i64cols))
purge_empty <- function(x) purrr::keep(x, .p=function(x) length(x)>0 && !any(is.na(x)) && any(nzchar(x)))
if(!write_empty_fields)
x=purrr::map(x, purge_empty)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-clio.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ test_that("manc_point_annotations/clioannotationdf2list works", {
entry_nerve = c("None", "None", "None", "None"),
exit_nerve = c("CvC",
"CvC", "CvC", "CvC"),
group = c(NA, 10223, 10223, 10245),
group = manc_ids(c(NA, 10223, 10223, 10245), integer64 = T, unique = F),
user = c(
"[email protected]",
"[email protected]",
Expand All @@ -124,7 +124,7 @@ test_that("manc_point_annotations/clioannotationdf2list works", {
)

expect_known_hash(cliolist <- clioannotationdf2list(ansforuploadsample),
"b57d0a3fdf")
"9783889b09")
# a row with only bodyid should be dropped
ansforuploadsample[5,'bodyid']=1
expect_equal(clioannotationdf2list(ansforuploadsample), cliolist)
Expand Down

0 comments on commit cea3eac

Please sign in to comment.