Skip to content

Commit 47f4e7e

Browse files
authored
Return array in setindex (#186)
1 parent 4072996 commit 47f4e7e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockBandedMatrices"
22
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
3-
version = "0.12.9"
3+
version = "0.12.10"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/BlockSkylineMatrix.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ end
408408
bi = findblockindex.(axes(A), (i,j))
409409
V = view(A, block.(bi)...)
410410
@inbounds V[blockindex.(bi)...] = convert(T, v)::T
411-
return v
411+
return A
412412
end
413413

414414
############
@@ -490,11 +490,10 @@ end
490490
# TODO: What to do if b_start == 0 ?
491491
b_stride = A.block_sizes.block_strides[J]
492492
A.data[b_start + k-1 + (j-1)*b_stride ] = v
493-
elseif iszero(v) # allow setindex for 0 data
494-
v
495-
else
493+
elseif !iszero(v) # allow setindex for 0 data
496494
throw(BandError(A, J-K))
497495
end
496+
return V
498497
end
499498

500499
"""

test/test_blockbanded.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ import BlockBandedMatrices: MemoryLayout, ColumnMajor, BroadcastStyle,
8282

8383
A[1,1] = -5
8484
@test A[1,1] == -5
85-
A[1,3] = -6
85+
# setindex! should return the array
86+
@test setindex!(A, -6, 1, 3) === A
8687
@test A[1,3] == -6
8788

8889
A[Block(3,4)] = Matrix(Ones{Int}(3,4))
@@ -95,6 +96,10 @@ import BlockBandedMatrices: MemoryLayout, ColumnMajor, BroadcastStyle,
9596
V = view(ret, Block(1), Block(2))
9697
V[1,1] = 2
9798
@test ret[1,2] == 0
99+
100+
# setindex! should return the array
101+
@test setindex!(V, 4, 1, 2) === V
102+
@test V[1,2] == 4
98103
end
99104

100105
@testset "blockcol/rowsupport" begin

0 commit comments

Comments
 (0)