Summation of ConstantArray of 0 with vector of 0's fails
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the zero-valued case starting with DelayedArray::ConstantArray and the HDF5Array::writeHDF5Array entry point, then compare it with the working combinations shown in the report. Done means the zero ConstantArray plus zero vector can be written successfully, with the existing examples serving as regression checks.
Written by the indexing model from the issue text.
Description
Hi,
I ran into a curious edge case, where summing a ConstantArray with a vector fails if both are zero and then writing it with HDF5Array::writeHDF5Array, but not in any other combination:
mat <- DelayedArray::ConstantArray(c(2, 4), value = 0)
res <- mat + rep(0, 2)
res
#> <2 x 4> sparse DelayedMatrix object of type "double":
#> [,1] [,2] [,3] [,4]
#> [1,] 0 0 0 0
#> [2,] 0 0 0 0
HDF5Array::writeHDF5Array(res)
#> Error in .Arith_SVT1_v2(.Generic, e1, e2): "+" is not supported between a SparseArray object and a numeric vector
#> (result wouldn't be sparse in general)
# All other combination seems to work
mat <- DelayedArray::ConstantArray(c(2, 4), value = 0)
res <- mat + rep(3, 2)
HDF5Array::writeHDF5Array(res)
#> <2 x 4> HDF5Matrix object of type "double":
#> [,1] [,2] [,3] [,4]
#> [1,] 3 3 3 3
#> [2,] 3 3 3 3
mat <- DelayedArray::ConstantArray(c(2, 4), value = 17)
res <- mat + rep(0, 2)
HDF5Array::writeHDF5Array(res)
#> <2 x 4> HDF5Matrix object of type "double":
#> [,1] [,2] [,3] [,4]
#> [1,] 17 17 17 17
#> [2,] 17 17 17 17
mat <- DelayedArray::ConstantArray(c(2, 4), value = 0)
res <- mat + 0
HDF5Array::writeHDF5Array(res)
#> <2 x 4> sparse HDF5Matrix object of type "double":
#> [,1] [,2] [,3] [,4]
#> [1,] 0 0 0 0
#> [2,] 0 0 0 0
Created on 2025-03-05 with reprex v2.1.1
I am not actually 100% this is an DelayedArray issue or if it might rather need to be moved to HDF5Array.
Best,
Constantin
- Dominant language
- R
- Stars
- 29
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Bioconductor/DelayedArray
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Bioconductor/DelayedArray#129 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Bioconductor/DelayedArray#127 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Bioconductor/DelayedArray#125 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Bioconductor/DelayedArray#122 ·
-
`base::cbind()` Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Bioconductor/DelayedArray#116 · 3 comments ·