diff --git a/R/R7.R b/R/R7.R index cec9070f4e..f84151afdb 100644 --- a/R/R7.R +++ b/R/R7.R @@ -132,7 +132,7 @@ length.R7 <- function(x) { tryCatch( x$length(), error = function(err) { - cli::cli_abort("{.val length} is not support for objects with class {.cls {class(x)}}") + 1 # when no custom length method is implemented, we return 1. } ) } \ No newline at end of file diff --git a/tests/testthat/test-device.R b/tests/testthat/test-device.R index c523af7e5c..5333f927b8 100644 --- a/tests/testthat/test-device.R +++ b/tests/testthat/test-device.R @@ -83,3 +83,8 @@ test_that("printer works", { print(torch_device("cpu")) }) }) + +test_that("can query device length", { + device <- torch_device("cpu") + expect_equal(length(device), 1) +})