File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,22 @@ test_that("0-length", {
189189 expect_equal(list (), materialize(lazy_tensor(), rbind = FALSE ))
190190})
191191
192+ test_that(" materialize.data.frame with empty data.frame" , {
193+ lt = as_lazy_tensor(torch_randn(5 , 3 ))
194+ df = data.frame (x = I(lt [integer(0 )]))
195+
196+ res_rbind = materialize(df , rbind = TRUE )
197+ expect_list(res_rbind )
198+ expect_equal(names(res_rbind ), " x" )
199+ expect_class(res_rbind $ x , " torch_tensor" )
200+ expect_equal(res_rbind $ x $ shape , 0L )
201+
202+ res_list = materialize(df , rbind = FALSE )
203+ expect_list(res_list )
204+ expect_equal(names(res_list ), " x" )
205+ expect_list(res_list $ x , len = 0 )
206+ })
207+
192208test_that(" materialize with shape (NA, NA) and .getbatch implementation" , {
193209 # this can e.g. happen when we do padding in the dataset
194210 ds = dataset(
Original file line number Diff line number Diff line change 1+ test_that(" auto_device handles NULL and 'auto'" , {
2+ # NULL should be returned as-is
3+ expect_null(auto_device(NULL ))
4+ # explicit device should be returned as-is
5+ expect_equal(auto_device(" cpu" ), " cpu" )
6+ # "auto" should return either "cuda" or "cpu"
7+ expect_true(auto_device(" auto" ) %in% c(" cuda" , " cpu" ))
8+ })
9+
110test_that(" make_check_vector works" , {
211 check_vector1 = make_check_vector(1 )
312 expect_true(check_vector1(1 ))
You can’t perform that action at this time.
0 commit comments