From 69f380d2270d47aea3ccda8bec995aa9095a303d Mon Sep 17 00:00:00 2001 From: olivroy Date: Sat, 17 Aug 2024 15:59:55 -0400 Subject: [PATCH] Update tests based on https://github.com/r-tmap/tmap/commit/4e7f35d084881497455e3e2dec7a24a93751fb45 --- NEWS.md | 2 ++ tests/testthat/test-terra-stars.R | 8 ++++---- tests/testthat/test-v3.R | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4b9d9410..bcf2ca6b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ * In view mode, `hover` is now independent from `id` (#851). +* `tm_vars()` is a new function for multivariate scale (#819) + # tmap 3.3-4 - (!) last version of tmap 3.x. Next CRAN version will be tmap 4.x (release planned at the end of 2023) - fixed bug (some stars appeared upside down in plot mode) diff --git a/tests/testthat/test-terra-stars.R b/tests/testthat/test-terra-stars.R index 80f076a9..de6b76a6 100644 --- a/tests/testthat/test-terra-stars.R +++ b/tests/testthat/test-terra-stars.R @@ -17,7 +17,7 @@ test_that("terra works", { # FIXME this is not expected. tm_shape(landsat) + - tm_rgb(tm_mv("landsat_4", "landsat_3", "landsat_2"), col.scale = tm_scale_rgb(maxValue = 31961)) + tm_rgb(tm_vars(c("landsat_4", "landsat_3", "landsat_2"), multivariate = TRUE), col.scale = tm_scale_rgb(maxColorValue = 31961)) # Defaults of stars and terra are identical. tm_shape(landsat) + tm_raster(col.free = FALSE) tm_shape(landsat) + @@ -65,7 +65,7 @@ test_that("multi rast works.", { }) tm_shape(multi_rast) + - tm_rgb(tm_mv("landsat_4", "landsat_3", "landsat_2"), col.scale = tm_scale_rgb(maxValue = 31961)) + tm_rgb(tm_vars(c("landsat_4", "landsat_3", "landsat_2"), multivariate = TRUE), col.scale = tm_scale_rgb(maxColorValue = 31961)) }) @@ -76,11 +76,11 @@ test_that("Both approaches work for stars.", { # direct approach landsat_stars = stars::read_stars(system.file("raster/landsat.tif", package = "spDataLarge")) expect_no_condition(tm_shape(landsat_stars) + - tm_rgb(tm_mv_dim("band", c(4,3,2)), col.scale = tm_scale_rgb(maxValue = 31961)) + tm_rgb(tm_vars("band", dimvalues = c(4,3,2)), col.scale = tm_scale_rgb(maxColorValue = 31961)) ) # indirect approach landsat_stars2 = split(landsat_stars, "band") tm_shape(landsat_stars2) + - tm_rgb(tm_mv("X4", "X3", "X2"), col.scale = tm_scale_rgb(maxValue = 31961)) + tm_rgb(tm_vars(c("X4", "X3", "X2"), multivariate = TRUE), col.scale = tm_scale_rgb(maxColorValue = 31961)) }) diff --git a/tests/testthat/test-v3.R b/tests/testthat/test-v3.R index c2ed84b4..7a1ec0bd 100644 --- a/tests/testthat/test-v3.R +++ b/tests/testthat/test-v3.R @@ -45,7 +45,7 @@ test_that("v3 syntax works", { skip_if_not_installed("cartogram") # Cartogram - NLD_prov_pop <- cartogram::cartogram(NLD_prov, "population") + NLD_prov_pop <- cartogram::cartogram_cont(NLD_prov, "population") tm_shape(NLD_prov_pop) + tm_polygons("origin_non_west", title = "Non-western origin (%)") })