Skip to content

Commit

Permalink
Return array in setindex (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Mar 11, 2024
1 parent 4072996 commit 47f4e7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BlockBandedMatrices"
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
version = "0.12.9"
version = "0.12.10"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
7 changes: 3 additions & 4 deletions src/BlockSkylineMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ end
bi = findblockindex.(axes(A), (i,j))
V = view(A, block.(bi)...)
@inbounds V[blockindex.(bi)...] = convert(T, v)::T
return v
return A
end

############
Expand Down Expand Up @@ -490,11 +490,10 @@ end
# TODO: What to do if b_start == 0 ?
b_stride = A.block_sizes.block_strides[J]
A.data[b_start + k-1 + (j-1)*b_stride ] = v
elseif iszero(v) # allow setindex for 0 data
v
else
elseif !iszero(v) # allow setindex for 0 data
throw(BandError(A, J-K))
end
return V
end

"""
Expand Down
7 changes: 6 additions & 1 deletion test/test_blockbanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ import BlockBandedMatrices: MemoryLayout, ColumnMajor, BroadcastStyle,

A[1,1] = -5
@test A[1,1] == -5
A[1,3] = -6
# setindex! should return the array
@test setindex!(A, -6, 1, 3) === A
@test A[1,3] == -6

A[Block(3,4)] = Matrix(Ones{Int}(3,4))
Expand All @@ -95,6 +96,10 @@ import BlockBandedMatrices: MemoryLayout, ColumnMajor, BroadcastStyle,
V = view(ret, Block(1), Block(2))
V[1,1] = 2
@test ret[1,2] == 0

# setindex! should return the array
@test setindex!(V, 4, 1, 2) === V
@test V[1,2] == 4
end

@testset "blockcol/rowsupport" begin
Expand Down

2 comments on commit 47f4e7e

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/102642

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.10 -m "<description of version>" 47f4e7ed2f69ccdb8fb42dd4b47ded4ae87b08d7
git push origin v0.12.10

Please sign in to comment.