Skip to content

Commit

Permalink
re-enable plotVelocityStream() with a warning; only test on non-macOS (
Browse files Browse the repository at this point in the history
…#89)

* re-enable plotVelocityStream() with a warning; only test on non-macOS

* conditional run of examples in man page
  • Loading branch information
kevinrue authored Sep 13, 2024
1 parent 14de4ca commit 4ec5297
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", comment = c(ORCID = "0000-0003-3899-3872")),
person("Aaron", "Lun", role="aut", email="[email protected]", comment = c(ORCID = '0000-0002-3564-4813')),
person("Charlotte", "Soneson", role="aut", email="[email protected]", comment = c(ORCID = '0000-0003-3833-2169')),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 11 additions & 5 deletions R/plotVelocityStream.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
#'
#' em <- embedVelocity(reducedDim(out, 1), out)[,1:2]
#'
#' \dontrun{
#' # https://github.com/kevinrue/velociraptor/issues/90
#'
#' if (!basilisk.utils::isMacOSX()){
#' plotVelocityStream(out, em)
#' plotVelocityStream(out, em, color.streamlines = TRUE)
#' }
Expand All @@ -92,10 +94,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.")
Expand Down
4 changes: 3 additions & 1 deletion man/plotVelocityStream.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 26 additions & 33 deletions tests/testthat/test-plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# })

0 comments on commit 4ec5297

Please sign in to comment.