From b1b7079eb9374ba0c1ce3550ce1331d3afceb968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 16 May 2024 18:38:51 +0200 Subject: [PATCH] Adress some more JET warnings --- src/PrettyPrinting.jl | 8 ++++---- src/generic/MPoly.jl | 10 +++++----- src/generic/Residue.jl | 4 ++-- src/generic/UnivPoly.jl | 28 ++++++++++++++-------------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/PrettyPrinting.jl b/src/PrettyPrinting.jl index 869e4e7b41..a195daa3bd 100644 --- a/src/PrettyPrinting.jl +++ b/src/PrettyPrinting.jl @@ -148,7 +148,7 @@ function show_obj(io::IO, mi::MIME, obj) finish(S) end -global _html_as_latex = Ref(false) +global _html_as_latex = Ref{Bool}(false) @doc raw""" get_html_as_latex() @@ -552,8 +552,8 @@ end # ################################################################################ -mutable struct printer - io::IO +mutable struct printer{IOT <: IO} + io::IOT array::Vector{String} # if terse_level is positive we print a+b instead of a + b @@ -565,7 +565,7 @@ end function printer(io::IO) terse_level = get(io, :terse_level, 0) size_limit = get(io, :size_limit, -1) - return printer(io, String[], terse_level, Int[size_limit]) + return printer{typeof(io)}(io, String[], terse_level, Int[size_limit]) end # TODO since the subexpressions are not changing much, cache the leaf_count diff --git a/src/generic/MPoly.jl b/src/generic/MPoly.jl index 3505740990..79e99c112e 100644 --- a/src/generic/MPoly.jl +++ b/src/generic/MPoly.jl @@ -38,22 +38,22 @@ number_of_generators(a::MPolyRing) = a.num_vars function gen(a::MPolyRing{T}, i::Int, ::Val{:lex}) where {T <: RingElement} n = nvars(a) @boundscheck 1 <= i <= n || throw(ArgumentError("variable index out of range")) - return a([one(base_ring(a))], reshape([UInt(j == n - i + 1) + return a([one(base_ring(a))], reshape(UInt[UInt(j == n - i + 1) for j = 1:n], n, 1)) end function gen(a::MPolyRing{T}, i::Int, ::Val{:deglex}) where {T <: RingElement} n = nvars(a) @boundscheck 1 <= i <= n || throw(ArgumentError("variable index out of range")) - return a([one(base_ring(a))], reshape([[UInt(j == n - i + 1) - for j in 1:n]..., UInt(1)], n + 1, 1)) + return a([one(base_ring(a))], reshape(UInt[(UInt(j == n - i + 1) + for j in 1:n)..., UInt(1)], n + 1, 1)) end function gen(a::MPolyRing{T}, i::Int, ::Val{:degrevlex}) where {T <: RingElement} n = nvars(a) @boundscheck 1 <= i <= n || throw(ArgumentError("variable index out of range")) - return a([one(base_ring(a))], reshape([[UInt(j == i) - for j in 1:n]..., UInt(1)], n + 1, 1)) + return a([one(base_ring(a))], reshape(UInt[(UInt(j == i) + for j in 1:n)..., UInt(1)], n + 1, 1)) end @doc raw""" diff --git a/src/generic/Residue.jl b/src/generic/Residue.jl index c7b1cf2369..431ab8285f 100644 --- a/src/generic/Residue.jl +++ b/src/generic/Residue.jl @@ -49,14 +49,14 @@ function (a::EuclideanRingResidueRing{T})(b::Integer) where {T <: RingElement} end function (a::EuclideanRingResidueRing{T})(b::T) where {T <: RingElem} - base_ring(a) != parent(b) && error("Operation on incompatible objects") + base_ring(a) !== parent(b) && error("Operation on incompatible objects") z = EuclideanRingResidueRingElem{T}(mod(b, modulus(a))) z.parent = a return z end function (a::EuclideanRingResidueRing{T})(b::AbstractAlgebra.ResElem{T}) where {T <: RingElement} - a != parent(b) && error("Operation on incompatible objects") + a !== parent(b) && error("Operation on incompatible objects") return b end diff --git a/src/generic/UnivPoly.jl b/src/generic/UnivPoly.jl index c599410596..7454876ebc 100644 --- a/src/generic/UnivPoly.jl +++ b/src/generic/UnivPoly.jl @@ -24,7 +24,7 @@ function is_exact_type(::Type{T}) where {S <: RingElement, U <: MPolyRingElem{S} return is_exact_type(S) end -parent(p::UnivPoly) = p.parent +parent(p::UnivPoly) = p.parent::parent_type(p) elem_type(::Type{UniversalPolyRing{T, U}}) where {T <: RingElement, U <: AbstractAlgebra.MPolyRingElem{T}} = UnivPoly{T, U} @@ -252,7 +252,7 @@ function gen(S::UniversalPolyRing{T, U}, s::VarName) where {T <: RingElement, U i = findfirst(==(Symbol(s)), S.S) if i === nothing push!(S.S, Symbol(s)) - S.mpoly_ring = MPolyRing{T}(S.base_ring, S.S, S.ord, false) + S.mpoly_ring = MPolyRing{T}(base_ring(S), S.S, S.ord, false) i = length(S.S) end return UnivPoly{T, U}(gen(mpoly_ring(S), i), S) @@ -297,7 +297,7 @@ function Base.hash(p::UnivPoly, h::UInt) end function deepcopy_internal(p::UnivPoly{T, U}, dict::IdDict) where {T, U} - return UnivPoly{T, U}(deepcopy_internal(p.p, dict), p.parent) + return UnivPoly{T, U}(deepcopy_internal(p.p, dict), parent(p)) end ############################################################################### @@ -355,7 +355,7 @@ end ############################################################################### function -(p::UnivPoly{T, U}) where {T, U} - return UnivPoly{T, U}(-p.p, p.parent) + return UnivPoly{T, U}(-p.p, parent(p)) end ############################################################################### @@ -377,19 +377,19 @@ end function +(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T, U} check_parent(a, b) a, b = univ_promote(a, b) - return UnivPoly{T, U}(a.p + b.p, a.parent) + return UnivPoly{T, U}(a.p + b.p, parent(a)) end function -(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T, U} check_parent(a, b) a, b = univ_promote(a, b) - return UnivPoly{T, U}(a.p - b.p, a.parent) + return UnivPoly{T, U}(a.p - b.p, parent(a)) end function *(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T, U} check_parent(a, b) a, b = univ_promote(a, b) - return UnivPoly{T, U}(a.p*b.p, a.parent) + return UnivPoly{T, U}(a.p*b.p, parent(a)) end ############################################################################### @@ -680,14 +680,14 @@ end function divexact(a::UnivPoly{T, U}, b::UnivPoly{T, U}; check::Bool=true) where {T, U} check_parent(a, b) a, b = univ_promote(a, b) - return UnivPoly{T, U}(divexact(a.p, b.p; check=check), a.parent) + return UnivPoly{T, U}(divexact(a.p, b.p; check=check), parent(a)) end function divides(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T, U} check_parent(a, b) a, b = univ_promote(a, b) flag, q = divides(a.p, b.p) - return flag, UnivPoly{T, U}(q, a.parent) + return flag, UnivPoly{T, U}(q, parent(a)) end ############################################################################### @@ -699,14 +699,14 @@ end function Base.div(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T, U} check_parent(a, b) a, b = univ_promote(a, b) - return UnivPoly{T, U}(div(a.p, b.p), a.parent) + return UnivPoly{T, U}(div(a.p, b.p), parent(a)) end function Base.divrem(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T, U} check_parent(a, b) a, b = univ_promote(a, b) q, r = divrem(a.p, b.p) - return UnivPoly{T, U}(q, a.parent), UnivPoly{T, U}(r, a.parent) + return UnivPoly{T, U}(q, parent(a)), UnivPoly{T, U}(r, parent(a)) end ############################################################################### @@ -720,7 +720,7 @@ function derivative(p::UnivPoly{T, U}, j::Int) where {T, U} if j > nvars(parent(p.p)) return zero(parent(p)) end - return UnivPoly{T, U}(derivative(p.p, j), p.parent) + return UnivPoly{T, U}(derivative(p.p, j), parent(p)) end function derivative(p::UnivPoly{T, U}, x::UnivPoly{T, U}) where {T, U} @@ -872,13 +872,13 @@ end function gcd(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T <: RingElement, U} check_parent(a, b) a, b = univ_promote(a, b) - return UnivPoly{T, U}(gcd(a.p, b.p), a.parent) + return UnivPoly{T, U}(gcd(a.p, b.p), parent(a)) end function lcm(a::UnivPoly{T, U}, b::UnivPoly{T, U}) where {T <: RingElement, U} check_parent(a, b) a, b = univ_promote(a, b) - return UnivPoly{T, U}(lcm(a.p, b.p), a.parent) + return UnivPoly{T, U}(lcm(a.p, b.p), parent(a)) end ###############################################################################