Skip to content

Commit 36ca67b

Browse files
committed
don't repeat NULL in dimnames obj
1 parent 18b8bf8 commit 36ca67b

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

R/bind.r

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ bind = function(arrayList, along=length(dim(arrayList[[1]]))+1) {
88
arrayList = vectors_to_row_or_col(arrayList, along=along)
99
re = do.call(function(...) abind::abind(..., along=along), arrayList)
1010

11-
# is.null(...) required because R is stupid
1211
if (dim(re)[along] == length(arrayList) && !is.null(names(arrayList)))
1312
dimnames(re)[[along]] = names(arrayList)
1413

14+
# replace list of NULLs to one NULL to be consistent with base R
15+
if (all(sapply(dimnames(re), is.null)))
16+
dimnames(re) = NULL
17+
1518
re
1619
}

tests/testthat/test-bind.r

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
context("bind")
22

33
test_that("vector", {
4-
ref = cbind(1:2, 3:4)
4+
ref = rbind(1:2, 3:4)
55
expect_equal(ref, bind(list(1:2, 3:4), along=1))
66
expect_equal(ref, t(bind(list(1:2, 3:4), along=2)))
77
})
@@ -13,9 +13,7 @@ test_that("keep names", {
1313
expect_equal(names(x), rownames(m))
1414

1515
colnames(m) = LETTERS[1:2]
16-
expect_equal(bind(list(m,m), along=1),
17-
rbind(m, m))
16+
expect_equal(bind(list(m,m), along=1), rbind(m, m))
1817

19-
expect_equal(bind(list(m,m), along=2),
20-
cbind(m, m))
18+
expect_equal(bind(list(m,m), along=2), cbind(m, m))
2119
})

tests/testthat/test-mask.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ test_that("mask", {
1313
2L), .Dimnames = list(c("a", "b", "c"), c("e1", "e2")))
1414

1515
expect_equal(Zref, Z)
16-
expect_equal(Zref, mask(Z, along=2))
17-
expect_equal(Zref, t(mask(Z, along=1)))
16+
expect_equal(Zref, mask(F, along=2))
17+
expect_equal(Zref, t(mask(F, along=1)))
1818
})

0 commit comments

Comments
 (0)