Skip to content

Commit

Permalink
Add one and copy for Diagonal (#52)
Browse files Browse the repository at this point in the history
* Update infarrays.jl

* Update runtests.jl

* Update infarrays.jl

* Update runtests.jl

* Update infarrays.jl

Co-authored-by: Sheehan Olver <[email protected]>
  • Loading branch information
putianyi889 and dlfivefifty authored Mar 7, 2021
1 parent a9437da commit 058032d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/infarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ end
# Diagonal
#####

one(D::Diagonal{T,<:AbstractFill{T,1,Tuple{OneToInf{Int}}}}) where T = Eye{T}(size(D,1))
copy(D::Diagonal{T,<:AbstractFill{T,1,Tuple{OneToInf{Int}}}}) where T = D

BroadcastStyle(::Type{<:Diagonal{<:Any,<:AbstractInfUnitRange}}) = LazyArrayStyle{2}()

Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,12 @@ end

@test Eye{Int}(∞) * D Eye{Int}(∞) * D D
@test Eye(∞) * D == Eye(∞) * D == D
@test Eye(∞) == Eye(∞)^0 == Eye(∞)^1 == Eye(∞)^2 == one(Eye(∞)) == copy(Eye(∞)) == one(Diagonal(Fill(2,∞)))
@test Diagonal(Fill(2,∞)) == copy(Diagonal(Fill(2,∞)))


@test permutedims(D) D

end

@testset "concat" begin
Expand Down

2 comments on commit 058032d

@dlfivefifty
Copy link
Member

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/31433

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.10.4 -m "<description of version>" 058032d4bc192e28771ea4cbba8144ea4d163a17
git push origin v0.10.4

Please sign in to comment.