Skip to content

Commit

Permalink
New version of terra undid the flip thing
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdamoses committed Dec 14, 2024
1 parent 6e4508d commit febca98
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SpatialFeatureExperiment
Type: Package
Title: Integrating SpatialExperiment with Simple Features in sf
Version: 1.9.4
Version: 1.9.5
Authors@R:
c(person("Lambda", "Moses", email = "[email protected]",
role = c("aut", "cre"),
Expand Down
2 changes: 1 addition & 1 deletion R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
terra::RGB(im_new) <- seq_len(3)
} else if (inherits(img, "RemoteSpatialImage") || inherits(img, "StoredSpatialImage")) {
suppressWarnings(im_new <- rast(imgSource(img)))
if (packageVersion('terra') >= as.package_version("1.7.83"))
if (packageVersion('terra') == as.package_version("1.7.83"))
im_new <- terra::flip(im_new)
} else {
warning("Don't know how to convert image ", i, " to SpatRaster, ",
Expand Down
6 changes: 3 additions & 3 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ read10xVisiumSFE <- function(samples = "",
data <- match.arg(data)
unit <- match.arg(unit)
flip <- match.arg(flip)
if (packageVersion('terra') >= as.package_version("1.7.83"))
if (packageVersion('terra') == as.package_version("1.7.83"))
flip <- "none"
if (is_present(load)) {
deprecate_warn("1.8.0", "read10xVisiumSFE(load)")
Expand Down Expand Up @@ -326,7 +326,7 @@ readVisiumHD <- function(data_dir, bin_size = c(2L, 8L, 16L),
data <- match.arg(data)
unit <- match.arg(unit)
flip <- match.arg(flip)
if (packageVersion('terra') >= as.package_version("1.7.83"))
if (packageVersion('terra') == as.package_version("1.7.83"))
flip <- "none"
images <- match.arg(images, several.ok = TRUE)
bin_size <- match.arg(as.character(bin_size), choices = c("2", "8", "16"),
Expand Down Expand Up @@ -747,7 +747,7 @@ readVizgen <- function(data_dir,
check_installed("sfarrow")
data_dir <- normalizePath(data_dir, mustWork = TRUE)
flip <- match.arg(flip)
if (packageVersion('terra') >= as.package_version("1.7.83"))
if (packageVersion('terra') == as.package_version("1.7.83"))
flip <- "none"
image <- match.arg(image, several.ok = TRUE)
if ((any(z < 0) || any(z > 6)) && z != "all") {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-image.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ test_that("mirrorImg, SpatRasterImage method", {
img_m2 <- mirrorImg(img, maxcell = 100)
expect_equal(dim(img_m2), c(13,8,3))
# check content
if (packageVersion('terra') >= as.package_version("1.7.83"))
if (packageVersion('terra') == as.package_version("1.7.83"))
expect_equal(imgRaster(img_m2)[4,3,2][[1]], 190)

# Use filename
Expand Down Expand Up @@ -243,7 +243,7 @@ test_that("scaleImg, SpatRasterImage method, EBI behind the scene", {

test_that("affineImg, SpatRasterImage method, EBI behind the scene", {
suppressWarnings(spi <- SpatRasterImage(rast(img_path)))
if (packageVersion('terra') >= as.package_version("1.7.83"))
if (packageVersion('terra') == as.package_version("1.7.83"))
spi <- mirrorImg(spi, "vertical")
# Should rotate clockwise somewhat, squished to be flatter, shear to the right
M <- matrix(c(0.6, -0.2, 0.2, 0.3), nrow = 2)
Expand Down

0 comments on commit febca98

Please sign in to comment.