Skip to content

Commit

Permalink
Set IndexStyle to IndexLinear for AbstractFill
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Oct 17, 2022
1 parent de36a50 commit 3536c0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ end
end

rank(F::AbstractFill) = iszero(getindex_value(F)) ? 0 : 1
IndexStyle(::Type{<:AbstractFill{<:Any,N,<:NTuple{N,Base.OneTo{Int}}}}) where N = IndexLinear()
IndexStyle(::Type{<:AbstractFill}) = IndexLinear()

issymmetric(F::AbstractFill{<:Any, 2}) = axes(F,1) == axes(F,2)
ishermitian(F::AbstractFill{<:Any, 2}) = issymmetric(F) && iszero(imag(getindex_value(F)))
Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,17 @@ end

@testset "IndexStyle" begin
@test IndexStyle(Zeros(5,5)) == IndexStyle(typeof(Zeros(5,5))) == IndexLinear()
for ax in (Base.OneTo(2), SOneTo(2), Base.IdentityUnitRange(2:3))
for f in (Fill(1, (ax,)), Fill(1, (ax,ax)),
Zeros{Int}((ax,)), Zeros{Int}((ax, ax)),
Ones{Int}((ax,)), Ones{Int}((ax, ax)),
)
@test IndexStyle(f) == IndexLinear()
for (CI, LI) in zip(CartesianIndices(f), LinearIndices(f))
@test f[CI] == f[LI]
end
end
end
end

@testset "Identities" begin
Expand Down

0 comments on commit 3536c0e

Please sign in to comment.