Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change eltype defs to Type{...} and some iterator cleanup #1824

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
Loading