Closed LTLA closed 3 years ago
Fixed in DelayedArray 0.17.4 (see commit f1279e072d94793add8ba65f281def5a967a4406).
With this change cbind()
/rbind()
can now combine different types of DelayedArray derivatives without trying to coerce them to the type of the first object:
library(HDF5Array)
M1 <- as(matrix(1:12, nrow=4), "HDF5Array")
M2 <- DelayedArray(as(matrix(sample(c(0,1), 20, replace=TRUE), nrow=4), "dgCMatrix"))
showtree(cbind(M1, M2))
# 4x8 double: DelayedMatrix object
# └─ 4x8 double: Abind (along=2)
# ├─ 4x3 integer: [seed] HDF5ArraySeed object
# └─ 4x5 double, sparse: [seed] dgCMatrix object
Try this with your mumosa (no idea what that is but it sounds refreshing) and let me know if that fixes the problem.
Thanks, looks good on my end.
The following behavior is more or less expected:
But if we throw in another DA subclass,
rbind()
converts the later arguments to that class:It is easy to see how this could be problematic if the conversion cost is high. The problem lies in
DelayedArray:::stash_DelayedAbind
, which runsS4Vectors:::prepare_objects_to_bind
, which in turn runscoerce2
. It seems like it would be possible to not do this coercion if we see that all entities are DAs.FWIW, my actual use case is that of my new
ConstantMatrix
class. If you were to install mumosa, you could do:The last is a coercion error, which seems unnecessary to me; I'm happy with the
Abind
wrapper from the firstrbind
call.