Skip to content

Commit

Permalink
Change eltype defs to Type{...} and some iterator cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 2, 2024
1 parent 11bbd58 commit 308175a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ function Base.iterate(a::MatrixElem{T}, ij=(0, 1)) where T <: NCRingElement
end

Base.IteratorSize(::Type{<:MatrixElem}) = Base.HasShape{2}()
Base.IteratorEltype(::Type{<:MatrixElem}) = Base.HasEltype() # default

Base.pairs(M::MatElem) = Base.pairs(IndexCartesian(), M)
Base.pairs(::IndexCartesian, M::MatElem) = Base.Iterators.Pairs(M, CartesianIndices(axes(M)))
Expand Down
2 changes: 1 addition & 1 deletion src/Module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
###############################################################################

Base.eltype(M::FPModule{T}) where T <: FinFieldElem = elem_type(M)
Base.eltype(T::Type{<:FPModule{<:FinFieldElem}}) = elem_type(T)

Check warning on line 13 in src/Module.jl

View check run for this annotation

Codecov / codecov/patch

src/Module.jl#L13

Added line #L13 was not covered by tests

function zero(M::FPModule{T}) where T <: RingElement
R = base_ring(M)
Expand Down
14 changes: 2 additions & 12 deletions src/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,10 @@ function Base.iterate(PCR::Iterators.Reverse{<:PolyCoeffs{<:PolyRingElem}},
end
end

Base.IteratorEltype(M::PolyRingElem) = Base.HasEltype()
Base.eltype(::Type{<:PolyRingElem{T}}) where {T} = T

Base.eltype(M::PolyRingElem{T}) where {T} = T

Base.eltype(M::PolyCoeffs) = Base.eltype(M.f)
Base.eltype(::Type{PolyCoeffs{T}}) where {T} = Base.eltype(T)

Base.eltype(M::Iterators.Reverse{<:PolyCoeffs}) = Base.eltype(M.itr.f)

Base.eltype(M::Iterators.Take{<:PolyCoeffs}) = Base.eltype(M.xs.f)

Base.eltype(M::Iterators.Take{<:Iterators.Reverse{<:PolyCoeffs}}) = Base.eltype(M.xs.itr.f)

Base.IteratorSize(M::PolyCoeffs{<:PolyRingElem}) = Base.HasLength()

Base.length(M::PolyCoeffs{<:PolyRingElem}) = length(M.f)

function Base.lastindex(a::PolyCoeffs{<:PolyRingElem})
Expand Down
2 changes: 1 addition & 1 deletion src/generic/FreeAssociativeAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function Base.length(
end

function Base.eltype(
x::FreeAssAlgExponentWords{T},
::Type{FreeAssAlgExponentWords{T}},
) where {S <: RingElement, T <: FreeAssociativeAlgebraElem{S}}
return Vector{Int}
end
Expand Down
8 changes: 4 additions & 4 deletions src/generic/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -931,19 +931,19 @@ function Base.length(x::Union{MPolyCoeffs, MPolyExponentVectors, MPolyTerms, MPo
return length(x.poly)
end

function Base.eltype(x::MPolyCoeffs{T}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{MPolyCoeffs{T}}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
return S
end

function Base.eltype(x::MPolyExponentVectors{T}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{MPolyExponentVectors{T}}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
return Vector{Int}
end

function Base.eltype(x::MPolyMonomials{T}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{MPolyMonomials{T}}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
return T
end

function Base.eltype(x::MPolyTerms{T}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{MPolyTerms{T}}) where T <: AbstractAlgebra.MPolyRingElem{S} where S <: RingElement
return T
end

Expand Down
2 changes: 0 additions & 2 deletions src/generic/PermGroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,6 @@ julia> unique(A)
"""
elements!(G::SymmetricGroup)= (p for p in AllPerms(G.n))

Base.IteratorSize(::Type{<:SymmetricGroup}) = Base.HasLength()

@inline function Base.iterate(G::SymmetricGroup)
A = AllPerms(G.n)
a, b = iterate(A)
Expand Down
8 changes: 4 additions & 4 deletions src/generic/UnivPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -466,19 +466,19 @@ function Base.length(x::Union{UnivPolyCoeffs, UnivPolyExponentVectors, UnivPolyT
return length(x.poly)
end

function Base.eltype(x::UnivPolyCoeffs{T}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{UnivPolyCoeffs{T}}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement
return S
end

function Base.eltype(x::UnivPolyExponentVectors{T}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{UnivPolyExponentVectors{T}}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement
return Vector{Int}
end

function Base.eltype(x::UnivPolyMonomials{T}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{UnivPolyMonomials{T}}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement
return T
end

function Base.eltype(x::UnivPolyTerms{T}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement
function Base.eltype(::Type{UnivPolyTerms{T}}) where T <: AbstractAlgebra.UniversalPolyRingElem{S} where S <: RingElement

Check warning on line 481 in src/generic/UnivPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/generic/UnivPoly.jl#L481

Added line #L481 was not covered by tests
return T
end

Expand Down

0 comments on commit 308175a

Please sign in to comment.