@@ -41,29 +41,26 @@ function eachstoredblock(a::AbstractArray)
4141 return storedvalues (blocks (a))
4242end
4343
44- # TODO : Generalize this, this catches simple cases
45- # where the more general definition isn't specific enough.
46- blocktype (a:: Array ) = typeof (a)
47- # TODO : Maybe unwrap SubArrays?
4844function blocktype (a:: AbstractArray )
49- # TODO : Unfortunately, this doesn't always give
50- # a concrete type, even when it could be concrete, i.e.
51- #=
52- ```julia
53- julia> eltype(blocks(BlockArray(randn(2, 2), [1, 1], [1, 1])))
54- Matrix{Float64} (alias for Array{Float64, 2})
55-
56- julia> eltype(blocks(BlockedArray(randn(2, 2), [1, 1], [1, 1])))
57- AbstractMatrix{Float64} (alias for AbstractArray{Float64, 2})
58-
59- julia> eltype(blocks(randn(2, 2)))
60- AbstractMatrix{Float64} (alias for AbstractArray{Float64, 2})
61- ```
62- =#
6345 if isempty (blocks (a))
46+ # TODO : Unfortunately, this doesn't always give
47+ # a concrete type, even when it could be concrete, i.e.
48+ #=
49+ ```julia
50+ julia> eltype(blocks(BlockArray(randn(2, 2), [1, 1], [1, 1])))
51+ Matrix{Float64} (alias for Array{Float64, 2})
52+
53+ julia> eltype(blocks(BlockedArray(randn(2, 2), [1, 1], [1, 1])))
54+ AbstractMatrix{Float64} (alias for AbstractArray{Float64, 2})
55+
56+ julia> eltype(blocks(randn(2, 2)))
57+ AbstractMatrix{Float64} (alias for AbstractArray{Float64, 2})
58+ ```
59+ =#
60+ # That is an issue in BlockArrays.jl that we should address.
6461 return eltype (blocks (a))
6562 end
66- return eltype ( first ( blocks (a) ))
63+ return mapreduce (typeof, promote_type, blocks (a))
6764end
6865
6966abstract type AbstractBlockSparseArrayInterface <: AbstractSparseArrayInterface end
0 commit comments