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 = "0.16.31"
version = "0.16.32"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
2 changes: 1 addition & 1 deletion src/BlockArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Base: @propagate_inbounds, Array, to_indices, to_index,
RangeIndex, Int, Integer, Number,
+, -, *, /, \, min, max, isless, in, copy, copyto!, axes, @deprecate,
BroadcastStyle, checkbounds, throw_boundserror,
ones, zeros, intersect, Slice, resize!
oneunit, ones, zeros, intersect, Slice, resize!
using Base: ReshapedArray, dataids
import Base: AbstractArray

Expand Down
3 changes: 3 additions & 0 deletions src/blockindices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ getindex(B::Block, ::CartesianIndex{0}) = B
@inline (*)(a::Integer, index::Block{N}) where {N} = Block{N}(map(x->a*x, index.n))
@inline (*)(index::Block, a::Integer) = *(a,index)

Base.oneunit(B::Block{N,T}) where {N,T} = Block(ntuple(_->oneunit(T), Val(N)))
Base.one(B::Block) = true

# comparison
# _isless copied from Base in Julia 1.7 since it was removed in 1.8.
@inline function _isless(ret, I1::Tuple{Int,Vararg{Int,N}}, I2::Tuple{Int,Vararg{Int,N}}) where {N}
Expand Down
3 changes: 3 additions & 0 deletions test/test_blockindices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ import BlockArrays: BlockIndex, BlockIndexRange, BlockSlice
@test Block(1,2) + Block(2,3) == Block(3,5)
@test Block(1,2) + 1 == Block(2,3)
@test 1 + Block(1,2) == Block(2,3)
@test oneunit(Block(1,2)) + Block(1,2) == Block(2,3)
@test Block(2,3) - Block(1,2) == Block(1,1)
@test Block(1,2) - 1 == Block(0,1)
@test 1 - Block(1,2) == Block(0,-1)
@test 2*Block(1,2) == Block(2,4)
@test Block(1,2)*2 == Block(2,4)
@test one(Block(1,2))*Block(1,2) == Block(1,2)
@test one(Block(1,2))*Block(Int8(1)) === Block(Int8(1))

@test isless(Block(1,1), Block(2,2))
@test isless(Block(1,1), Block(2,1))
Expand Down