Skip to content

Commit d0eac49

Browse files
authored
Don't specialize IndexStyle for AbstractBlockArray (#249)
* Don't specialize IndexStyle for AbstractBlockArray * test fallback axes
1 parent e6f3d00 commit d0eac49

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/abstractblockarray.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ Base.similar(a::AbstractBlockArray{T}, dims::Tuple) where {T} = s
4040
# If all we know is size, just return an Array which conforms to BlockArray interface
4141
Base.similar(::Type{<:AbstractBlockArray{T,N}}, dims::Dims) where {T,N} = similar(Array{T,N}, dims)
4242

43-
Base.IndexStyle(::Type{<:AbstractBlockArray}) = IndexCartesian()
44-
4543
# need to overload axes to return BlockAxis
4644
@inline size(block_array::AbstractBlockArray) = map(length, axes(block_array))
47-
@inline axes(block_array::AbstractBlockArray) = throw(error("axes for ", typeof(block_array), " is not implemented"))
45+
@noinline axes(block_array::AbstractBlockArray) = throw(ArgumentError("axes for $(typeof(block_array)) is not implemented"))
4846

4947

5048
"""

test/test_blockarrayinterface.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ using BlockArrays, LinearAlgebra, FillArrays, Base64, Test
33
# avoid fast-paths for view
44
bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b)
55

6+
@testset "missing fallback block axes" begin
7+
@test_throws ArgumentError invoke(axes, Tuple{AbstractBlockArray}, PseudoBlockArray{ComplexF64}(undef, (1:4), (2:5)))
8+
end
9+
610
@testset "Array block interface" begin
711
@test 1[Block()] == 1
812

0 commit comments

Comments
 (0)