From 2a15e18efe54ac299bbe4abc3da2fcfb09f499bf Mon Sep 17 00:00:00 2001 From: Kevin Rue-Albrecht Date: Thu, 12 Sep 2024 15:06:33 +0100 Subject: [PATCH] re-enable plotVelocityStream() with a warning; only test on non-macOS --- DESCRIPTION | 4 +-- NEWS.md | 4 +++ R/plotVelocityStream.R | 12 ++++--- tests/testthat/test-plotting.R | 59 +++++++++++++++------------------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c5fa68b..e3bfaa4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: velociraptor Title: Toolkit for Single-Cell Velocity -Version: 1.15.10 -Date: 2024-09-11 +Version: 1.15.11 +Date: 2024-09-12 Authors@R: c(person("Kevin", "Rue-Albrecht", role = c("aut", "cre"), email = "kevinrue67@gmail.com", comment = c(ORCID = "0000-0003-3899-3872")), person("Aaron", "Lun", role="aut", email="infinite.monkeys.with.keyboards@gmail.com", comment = c(ORCID = '0000-0002-3564-4813')), person("Charlotte", "Soneson", role="aut", email="charlottesoneson@gmail.com", comment = c(ORCID = '0000-0003-3833-2169')), diff --git a/NEWS.md b/NEWS.md index 2901a2a..5cb0603 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# velociraptor 1.15.11 + +* Re-enable `plotVelocityStream()` with a warning. + # velociraptor 1.15.10 * Temporarily disable `plotVelocityStream()` due to unexplained issue related to diff --git a/R/plotVelocityStream.R b/R/plotVelocityStream.R index 70958c6..cb434c9 100644 --- a/R/plotVelocityStream.R +++ b/R/plotVelocityStream.R @@ -92,10 +92,14 @@ plotVelocityStream <- function( "#22A884", "#43BF71", "#7AD151", "#BBDF27", "#FDE725"), arrow.angle = 8, arrow.length = 0.8) { - stop( - "This function is temporarily unavailable while we investigate an issue ", - "related to metR::geom_streamline()" - ) + if (basilisk.utils::isMacOSX()){ # both Intel and Arm + warning( + "This function has been observed to run indefinitely on macOS. ", + "The issue is related to the metR::geom_streamline() layer but unsolved yet. ", + "Use with caution and consider terminating R if rendering the plot freezes your session.", + immediate. = TRUE + ) + } if (!identical(ncol(sce), nrow(embedded))) { stop("'sce' and 'embedded' do not have consistent dimensions.") diff --git a/tests/testthat/test-plotting.R b/tests/testthat/test-plotting.R index 2511678..80614ff 100644 --- a/tests/testthat/test-plotting.R +++ b/tests/testthat/test-plotting.R @@ -66,37 +66,30 @@ test_that("plotVelocity runs", { unlink(tf) }) -test_that("plotVelocityStream throws an error", { - - expect_error( - plotVelocityStream(out2, em2), - "temporarily" - ) - +test_that("plotVelocityStream runs", { + # metR::geom_streamline() layer causes timeouts on macOS + if (!basilisk.utils::isMacOSX()) { + skip_if_not_installed("ggplot2") + skip_if_not_installed("metR") + + expect_error(plotVelocityStream("error", em2)) + expect_error(plotVelocityStream(out2, "error")) + expect_error(plotVelocityStream(out2, em2[1:10, ])) + expect_error(plotVelocityStream(out2, em2, use.dimred = "error")) + expect_error(plotVelocityStream(out2, em2, use.dimred = FALSE)) + expect_error(plotVelocityStream(out2, em2, color_by = "error")) + expect_error(plotVelocityStream(out2, em2, grid.resolution = "error")) + expect_error(plotVelocityStream(out2, em2, scale = "error")) + expect_error(plotVelocityStream(out2, em2, color.streamlines = "error")) + + tf <- tempfile(fileext = ".png") + png(tf) + expect_warning(print(plotVelocityStream(out2, em2, color_by = "#44444422"))) + print(plotVelocityStream(out2, em2)) + print(plotVelocityStream(out3, em2, color_by = "type")) + print(plotVelocityStream(out2, em2, color.streamlines = TRUE)) + dev.off() + expect_true(file.exists(tf)) + unlink(tf) + } }) - -# test_that("plotVelocityStream runs", { -# -# skip_if_not_installed("ggplot2") -# skip_if_not_installed("metR") -# -# expect_error(plotVelocityStream("error", em2)) -# expect_error(plotVelocityStream(out2, "error")) -# expect_error(plotVelocityStream(out2, em2[1:10, ])) -# expect_error(plotVelocityStream(out2, em2, use.dimred = "error")) -# expect_error(plotVelocityStream(out2, em2, use.dimred = FALSE)) -# expect_error(plotVelocityStream(out2, em2, color_by = "error")) -# expect_error(plotVelocityStream(out2, em2, grid.resolution = "error")) -# expect_error(plotVelocityStream(out2, em2, scale = "error")) -# expect_error(plotVelocityStream(out2, em2, color.streamlines = "error")) -# -# tf <- tempfile(fileext = ".png") -# png(tf) -# expect_warning(print(plotVelocityStream(out2, em2, color_by = "#44444422"))) -# print(plotVelocityStream(out2, em2)) -# print(plotVelocityStream(out3, em2, color_by = "type")) -# print(plotVelocityStream(out2, em2, color.streamlines = TRUE)) -# dev.off() -# expect_true(file.exists(tf)) -# unlink(tf) -# })