Skip to content

Commit

Permalink
Add Base.keys(::MatElem) (#1906)
Browse files Browse the repository at this point in the history
* Add `Base.keys(::MatElem)`

* Bump version to 0.43.11

* Add test
  • Loading branch information
lgoettgens authored Nov 15, 2024
1 parent 25a7ea8 commit 21aac12
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "AbstractAlgebra"
uuid = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
version = "0.43.10"
version = "0.43.11"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
1 change: 1 addition & 0 deletions src/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ end

Base.IteratorSize(::Type{<:MatrixElem}) = Base.HasShape{2}()

Base.keys(M::MatElem) = CartesianIndices(axes(M))
Base.pairs(M::MatElem) = Base.pairs(IndexCartesian(), M)
Base.pairs(::IndexCartesian, M::MatElem) = Base.Iterators.Pairs(M, CartesianIndices(axes(M)))

Expand Down
15 changes: 15 additions & 0 deletions test/Matrix-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ end
@test Matrix(Sa) == a
end

@testset "Matrix.keys and pairs" begin
a = matrix(ZZ, 2, 3, [6, 3, 0, 10, 12, 14])
@test keys(a) == CartesianIndices((2, 3))
@test issetequal(
keys(a),
[CartesianIndex(1, 1), CartesianIndex(1, 2), CartesianIndex(1, 3),
CartesianIndex(2, 1), CartesianIndex(2, 2), CartesianIndex(2, 3)],
)
@test issetequal(
pairs(a),
[CartesianIndex(1, 1) => 6, CartesianIndex(1, 2) => 3, CartesianIndex(1, 3) => 0,
CartesianIndex(2, 1) => 10, CartesianIndex(2, 2) => 12, CartesianIndex(2, 3) => 14],
)
end

@testset "Strassen" begin
S = matrix(QQ, rand(-10:10, 100, 100))
T = S*S
Expand Down

2 comments on commit 21aac12

@lgoettgens
Copy link
Collaborator 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/119544

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.43.11 -m "<description of version>" 21aac12040f8f5877af9e7161982b13a1f7a6faa
git push origin v0.43.11

Please sign in to comment.