Closed PeteHaitch closed 5 years ago
Another small inconsistency: the [<-
method for base::array supports NULL
indices but the method for matter does not:
suppressPackageStartupMessages(library(matter))
array <- array(1:8, dim = c(2, 2, 2))
matter <- matter_arr(array, dim = dim(array))
# base: Returns empty array of appropriate dimension
array[NULL, NULL, NULL]
#> <0 x 0 x 0 array of integer>
#>
# matter: errors
matter[NULL, NULL, NULL]
#> Error in matter[NULL, NULL, NULL]: incorrect number of dimensions
# base: Returns empty array of appropriate dimension
array[NULL, NULL, 1]
#> <0 x 0 matrix>
# matter: errors
matter[NULL, NULL, 1]
#> Error in matter[NULL, NULL, 1]: incorrect number of dimensions
# base: Returns empty array of appropriate dimension
array[NULL, , NULL]
#> <0 x 2 x 0 array of integer>
#> [,1] [,2]
# matter: errors
matter[NULL, , NULL]
#> Error in FUN(if (length(d.call) < 2L) newX[, 1] else array(newX[, 1L], : subscript out of bounds
Sorry, another corner case: the [<-
method for base::array supports integer(0)
indices but the method for matter does not:
suppressPackageStartupMessages(library(matter))
array <- array(1:8, dim = c(2, 2, 2))
matter <- matter_arr(array)
# base: Returns an array of appropriate dimension
array[integer(0), integer(0), integer(0)]
#> <0 x 0 x 0 array of integer>
#>
# matter: errors
matter[integer(0), integer(0), integer()]
#> Error in FUN(if (length(d.call) < 2L) newX[, 1] else array(newX[, 1L], : subscript out of bounds
# base: Returns an array (I don't quite understand the dimensions)
array[integer(0), 1, integer(0)]
#> <0 x 0 matrix>
# matter: errors
matter[1, 1, integer(0)]
#> Error in FUN(if (length(d.call) < 2L) newX[, 1] else array(newX[, 1L], : subscript out of bounds
These should behave more as expected in version >= 1.9.8, with the exception that subsetting a matter_arr
always produces an array
and never a matrix
.
Hi Kylie,
The
[<-
replacement method seems to work the same for base::matrix and _mattermat objects, but not so for base::array and _matterarr objects. An example is shown below. Is this fixable? I hit this when using programatically constructed indices passed to the[<-
method for the _matterarr class via ado.call()
.