Skip to content

Commit

Permalink
R7 with no custom length shouldn't fail (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfalbel authored Nov 8, 2023
1 parent fe44f6b commit babc1fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/R7.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
)
}
5 changes: 5 additions & 0 deletions tests/testthat/test-device.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

0 comments on commit babc1fe

Please sign in to comment.