Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
wincowgerDEV committed May 20, 2024
1 parent 77571d4 commit 52292d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/manage_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ merge_map.list <- function(x, origins = NULL, ...) {

if(is.null(origins)){
origin = lapply(map, function(x) unique(x$metadata$description))
pix_size = lapply(map, function(x) unique(x$metadata$`pixel size`))
pixel_size = vapply(pix_size, function(x) as.numeric(gsub("(\\{)|(\\})|(,.*)", "",x))*10^6, FUN.VALUE = numeric(1))
originx = vapply(origin, function(x) gsub(",.*", "", gsub(".*X=", "", x)) |> as.numeric(), FUN.VALUE = numeric(1))
originy = vapply(origin, function(x) gsub(".*Y=", "", x) |> as.numeric(), FUN.VALUE = numeric(1))
xoffset = as.integer((originx-min(originx))/(as.numeric(gsub("(\\{)|(\\})|(,.*)", "",x$metdata["pixel size"]))*10^5))
yoffset = as.integer((originy-min(originy))/(as.numeric(gsub("(\\{)|(\\})|(,.*)", "",x$metdata["pixel size"]))*10^5))
xoffset = as.integer((originx-min(originx))/pixel_size)
yoffset = as.integer((originy-min(originy))/pixel_size)
}

else{
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-manage_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ test_that("merge_map()", {
expect_true(check_OpenSpecy(merged))
two_alt <- list(read_extdata("CA_tiny_map.zip"), read_extdata("CA_tiny_map.zip"))
merged2 <- merge_map(two_alt, origins = origins)
auto_size <- merge_map(two_alt)
expect_true(check_OpenSpecy(merged2))
expect_identical(merged$spectra, merged2$spectra)
expect_true(ncol(merged2$spectra) == ncol(tiny_map$spectra) * 2)
expect_true(ncol(auto_size$spectra) == ncol(tiny_map$spectra))
})

0 comments on commit 52292d5

Please sign in to comment.