Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BlockArrays"
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
version = "1.9"
version = "1.9.1"


[deps]
Expand Down
8 changes: 4 additions & 4 deletions src/blockindices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ BlockIndex(indcs::Tuple{Vararg{BlockIndex{1},N}}) where N = BlockIndex(block.(in
bl = block(I)
checkbounds(Bool, A, bl) || return false
# TODO: Replace with `eachblockaxes(A)[bl]` once that is defined.
binds = map(Base.axes1 ∘ getindex, axes(A), Tuple(bl))
binds = map(axes1 ∘ getindex, axes(A), Tuple(bl))
Base.checkbounds_indices(Bool, binds, (blockindex(I),))
end
checkbounds(::Type{Bool}, A::AbstractArray{<:Any,N}, I::AbstractArray{<:BlockIndex{N}}) where N =
Expand Down Expand Up @@ -374,8 +374,8 @@ end
nextstate, nextstate
end

size(iter::BlockIndices) = map(dimlength, first(iter).α, last(iter).α)
length(iter::BlockIndices) = prod(size(iter))
axes(iter::BlockIndices) = map(axes1, iter.indices)
size(iter::BlockIndices) = map(length, iter.indices)


Block(bs::BlockIndices) = bs.block
Expand All @@ -388,7 +388,7 @@ function checkbounds(::Type{Bool}, A::AbstractArray{<:Any,N}, I::BlockIndices{N}
bl = block(I)
checkbounds(Bool, A, bl) || return false
# TODO: Replace with `eachblockaxes(A)[bl]` once that is defined.
binds = map(Base.axes1 ∘ getindex, axes(A), Tuple(bl))
binds = map(axes1 ∘ getindex, axes(A), Tuple(bl))
Base.checkbounds_indices(Bool, binds, I.indices)
end

Expand Down
7 changes: 7 additions & 0 deletions test/test_blockindices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ import BlockArrays: split_index, merge_indices
@test eltype(BlockIndices{3}) ≡ BlockIndex{3}
@test Base.IteratorSize(BlockIndices{3}) ≡ Base.HasShape{1}()
@test isnothing(iterate(Block(3,3)[[1,3],[3,1]]))

I1 = BlockVector([2,4,7,2,3], (blockedrange([2,3]),))
I2 = blockedrange(2, [4,3])
b = Block(1,2)[I1,I2]
@test blockisequal(axes(b), (blockedrange([2,3]),blockedrange([4,3])))
@test size(b) == (5,7)
@test length(b) == 35
end

@testset "BlockRange" begin
Expand Down
Loading