Adding a ConstantArray class#87
Conversation
|
Sounds good but does this work? Seems like some unit tests are needed. |
|
... only for matrices, apparently. Oops. Fixed. |
|
Thanks. A few more things:
|
|
Done... I think I got all of the above. |
|
Thanks. Sorry to insist but you don't need to specify the representation in the class definition of ConstantMatrix 'cause you inherit it from ConstantArray (hey, I gave you above the exact |
|
ooops. |
|
Just for fun, here's one way to make a delayed constant matrix without using the new ConstantMatrix stuff: However, it's 10x slower than: and also the memory footprint of the resulting object is 5000x bigger. |
Nothing too fancy here, this class just represents an array with a constant value for all of its cells.
This was originally implemented as part of SingleCellExperiment, which contains a primitive implementation of what I hope will be the
combineRowsimplementation forSummarizedExperimentobjects. The idea is to create all-NAmatrices for assays that are not present in some SE objects, thus allowing them to be efficiently combined (without pretending that they're zero, which they're not).I thought about using an
RleArrayfor this purpose but it breaks pretty quickly with:I guess I could make a list of
Rleobjects, but it's a bit of a chore to have to create the chunks manually. Probably like:By comparison, the proposed class is simple to understand and use (and maintain) by just calling:
Data extraction also seems faster based on some cursory timings, but this isn't a major consideration here.