Skip to content

Commit

Permalink
fix fanc_cellid_from_segid for when rootids=NULL
Browse files Browse the repository at this point in the history
* more tests
* doc tweaks
  • Loading branch information
jefferis committed Aug 1, 2024
1 parent 865d986 commit 7fc88ec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ Encoding: UTF-8
Language: en-GB
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
VignetteBuilder: knitr
10 changes: 5 additions & 5 deletions R/ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ fanc_ids <- function(x, integer64=NA) {
#' with additional columns.
#' @param cellid_table Optional name of cell id table (the default value of
#' \code{NULL} should find the correct table).
#' @return Either a vector of ids or a data.frame depending on \code{rval}. For
#' cell ids the vector will be an integer for root ids (segment ids), a
#' @return Either a vector of ids or a data.frame depending on \code{rval}. A
#' cellid vector will be integer; for root ids (segment ids), a
#' character vector or an \code{bit64::integer64} vector depending on the
#' \code{integer64} argument.
#' @inheritParams fanc_ids
Expand Down Expand Up @@ -222,9 +222,9 @@ fanc_cellid_from_segid <- function(rootids=NULL, timestamp=NULL, version=NULL, c
res=fanc_cave_query(table = cellid_table, timestamp=timestamp,
version=version, filter_in_dict=idlist, live=live)
if(is.null(rootids)) {
if(rval=='ids') {
fanc_ids(res[['id']], integer64 = F)
} else res
if(rval=='ids')
res <- as.integer(fanc_ids(res[['id']], integer64 = T))
return(res)
}
ids64=fanc_ids(rootids, integer64=T)
if(!all(found <- ids64 %in% res$pt_root_id)) {
Expand Down
4 changes: 2 additions & 2 deletions man/fanc_cellid_from_segid.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-ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ test_that("fanc_ids works", {
test_that("fanc_cellid_from_segid", {
rid=fanc_latestid("648518346486614449")
expect_equal(fanc_cellid_from_segid(rid),12967L)
expect_s3_class(df <- fanc_cellid_from_segid(rid, rval = 'dat'), 'data.frame')
expect_equal(df$id, 12967L)

expect_type(allids <- fanc_cellid_from_segid(), 'integer')
expect_true(length(allids)>20000)

# skip this test because we can't be sure it will work
# expect_equal(
Expand Down

0 comments on commit 7fc88ec

Please sign in to comment.