Skip to content

Commit

Permalink
Change eltype methods for objects to types (#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Oct 2, 2024
1 parent 2c10798 commit bdeaacb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Misc/Cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function Base.length(F::CartesianProductIt)
return prod(length(x) for x in F.ranges)
end

Base.IteratorSize(::Type{CartesianProductIt{T}}) where T = Base.HasLength()
Base.IteratorSize(::Type{<:CartesianProductIt{T}}) where T = Base.HasLength()

Base.eltype(::CartesianProductIt{T}) where T = Vector{eltype(T)}
Base.eltype(::Type{<:CartesianProductIt{T}}) where T = Vector{eltype(T)}

function Base.getindex(F::CartesianProductIt{T}, i::Int) where T
v = Vector{eltype{T}}(undef, length(F.ranges))
Expand Down
2 changes: 1 addition & 1 deletion src/Misc/Integer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ mutable struct Divisors{T}
end
end

Base.IteratorSize(::Divisors) = Base.HasLength()
Base.IteratorSize(::Type{Divisors{T}}) where {T} = Base.HasLength()
Base.length(D::Divisors) = length(D.s)
Base.eltype(::Type{Divisors{T}}) where {T} = T

Expand Down
4 changes: 2 additions & 2 deletions src/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -992,5 +992,5 @@ function Base.iterate(
return (f, (p, exp))
end

Base.IteratorSize(::FactorsOfSquarefree) = Base.SizeUnknown()
Base.eltype(::FactorsOfSquarefree{T}) where T = T
Base.IteratorSize(::Type{FactorsOfSquarefree{T}}) where T = Base.SizeUnknown()
Base.eltype(::Type{FactorsOfSquarefree{T}}) where T = T
2 changes: 1 addition & 1 deletion src/Misc/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ end
# return A.to != -1 && st > A.to
#end

Base.eltype(::PrimesSet{T}) where {T <: IntegerUnion} = T
Base.eltype(::Type{PrimesSet{T}}) where {T <: IntegerUnion} = T

Base.length(A::PrimesSet) = length(collect(A))

Expand Down
2 changes: 1 addition & 1 deletion src/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ function length(A::SMat)
return nrows(A)
end

Base.eltype(A::SMat{T}) where {T} = SRow{T}
Base.eltype(::Type{<:SMat{T}}) where {T} = SRow{T}

################################################################################
#
Expand Down
4 changes: 2 additions & 2 deletions src/Sparse/Row.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ function Base.iterate(A::SRow, st::Int = 1)
return (A.pos[st], A.values[st]), st + 1
end

Base.eltype(::Type{SRow{T}}) where T = Tuple{Int, T}
Base.eltype(::Type{<:SRow{T}}) where T = Tuple{Int, T}

Base.IteratorSize(::SRow{T}) where T = Base.HasLength()
Base.IteratorSize(::Type{<:SRow{T}}) where T = Base.HasLength()

################################################################################
#
Expand Down

0 comments on commit bdeaacb

Please sign in to comment.