Skip to content

Commit e0f2992

Browse files
authored
import setindex and extend without specifying namespace (#291)
1 parent 1eb848f commit e0f2992

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/BlockArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export blockappend!, blockpush!, blockpushfirst!, blockpop!, blockpopfirst!
2121
import Base: @propagate_inbounds, Array, to_indices, to_index,
2222
unsafe_indices, first, last, size, length, unsafe_length,
2323
unsafe_convert,
24-
getindex, ndims, show, view,
24+
getindex, setindex!, ndims, show, view,
2525
step,
2626
broadcast, eltype, convert, similar,
2727
tail, reindex,

src/abstractblockarray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,21 +159,21 @@ false
159159
"""
160160
@inline blockcheckindex(::Type{Bool}, inds::BlockRange{1}, i::Integer) = Block(i) in inds
161161

162-
@propagate_inbounds Base.setindex!(block_arr::AbstractBlockArray{T,N}, v, block::Block{N}) where {T,N} =
162+
@propagate_inbounds setindex!(block_arr::AbstractBlockArray{T,N}, v, block::Block{N}) where {T,N} =
163163
setindex!(block_arr, v, Block.(block.n)...)
164-
@inline @propagate_inbounds function Base.setindex!(block_arr::AbstractBlockArray{T,N}, v, block::Vararg{Block{1}, N}) where {T,N}
164+
@inline @propagate_inbounds function setindex!(block_arr::AbstractBlockArray{T,N}, v, block::Vararg{Block{1}, N}) where {T,N}
165165
blockcheckbounds(block_arr, block...)
166166
dest = view(block_arr, block...)
167167
size(dest) == size(v) || throw(DimensionMismatch(string("tried to assign $(size(v)) array to $(size(dest)) block")))
168168
copyto!(dest, v)
169169
block_arr
170170
end
171171

172-
@inline @propagate_inbounds Base.setindex!(block_arr::AbstractBlockArray{T,N}, v, blockindex::BlockIndex{N}) where {T,N} =
172+
@inline @propagate_inbounds setindex!(block_arr::AbstractBlockArray{T,N}, v, blockindex::BlockIndex{N}) where {T,N} =
173173
view(block_arr, block(blockindex))[blockindex.α...] = v
174-
@inline @propagate_inbounds Base.setindex!(block_arr::AbstractBlockVector{T}, v, blockindex::BlockIndex{1}) where {T} =
174+
@inline @propagate_inbounds setindex!(block_arr::AbstractBlockVector{T}, v, blockindex::BlockIndex{1}) where {T} =
175175
view(block_arr, block(blockindex))[blockindex.α...] = v
176-
@inline @propagate_inbounds Base.setindex!(block_arr::AbstractBlockArray{T,N}, v, blockindex::Vararg{BlockIndex{1},N}) where {T,N} =
176+
@inline @propagate_inbounds setindex!(block_arr::AbstractBlockArray{T,N}, v, blockindex::Vararg{BlockIndex{1},N}) where {T,N} =
177177
block_arr[BlockIndex(blockindex)] = v
178178

179179
viewblock(block_arr, block) = Base.invoke(view, Tuple{AbstractArray, Any}, block_arr, block)

src/blockarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ const OffsetAxis = Union{Integer, UnitRange, Base.OneTo, Base.IdentityUnitRange}
387387
return v
388388
end
389389

390-
@inline function Base.setindex!(block_arr::BlockArray{T, N}, v, i::Vararg{Integer, N}) where {T,N}
390+
@inline function setindex!(block_arr::BlockArray{T, N}, v, i::Vararg{Integer, N}) where {T,N}
391391
@boundscheck checkbounds(block_arr, i...)
392392
@inbounds block_arr[findblockindex.(axes(block_arr), i)...] = v
393393
return block_arr
@@ -406,7 +406,7 @@ function _check_setblock!(block_arr::BlockArray{T, N}, v, block::NTuple{N, Integ
406406
end
407407
end
408408

409-
@inline function Base.setindex!(block_arr::BlockArray{T, N}, v, block::Vararg{Block{1}, N}) where {T,N}
409+
@inline function setindex!(block_arr::BlockArray{T, N}, v, block::Vararg{Block{1}, N}) where {T,N}
410410
blks = Int.(block)
411411
@boundscheck blockcheckbounds(block_arr, blks...)
412412
@boundscheck _check_setblock!(block_arr, v, blks)

src/blocks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ Base.axes(a::BlocksView) = map(br -> only(br.indices), blockaxes(a.array))
8282
This is broken for now. See: https://github.com/JuliaArrays/BlockArrays.jl/issues/120
8383
# IndexLinear implementations
8484
@propagate_inbounds getindex(a::BlocksView, i::Int) = view(a.array, Block(i))
85-
@propagate_inbounds Base.setindex!(a::BlocksView, b, i::Int) = copyto!(a[i], b)
85+
@propagate_inbounds setindex!(a::BlocksView, b, i::Int) = copyto!(a[i], b)
8686
=#
8787

8888
# IndexCartesian implementations
8989
@propagate_inbounds getindex(a::BlocksView{T,N}, i::Vararg{Int,N}) where {T,N} =
9090
view(a.array, Block.(i)...)
91-
@propagate_inbounds Base.setindex!(a::BlocksView{T,N}, b, i::Vararg{Int,N}) where {T,N} =
91+
@propagate_inbounds setindex!(a::BlocksView{T,N}, b, i::Vararg{Int,N}) where {T,N} =
9292
copyto!(a[i...], b)
9393

9494
function Base.showarg(io::IO, a::BlocksView, toplevel::Bool)

src/pseudo_blockarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ to_axes(n::Integer) = Base.oneto(n)
177177
PseudoBlockArray{T}(undef, map(to_axes,axes))
178178

179179
@propagate_inbounds getindex(block_arr::PseudoBlockArray{T, N}, i::Vararg{Integer, N}) where {T,N} = block_arr.blocks[i...]
180-
@propagate_inbounds Base.setindex!(block_arr::PseudoBlockArray{T, N}, v, i::Vararg{Integer, N}) where {T,N} = setindex!(block_arr.blocks, v, i...)
180+
@propagate_inbounds setindex!(block_arr::PseudoBlockArray{T, N}, v, i::Vararg{Integer, N}) where {T,N} = setindex!(block_arr.blocks, v, i...)
181181

182182
################################
183183
# AbstractBlockArray Interface #

0 commit comments

Comments
 (0)