Skip to content

Commit b570971

Browse files
lgoettgensfingolfin
authored andcommitted
Add many @req !is_trivial checks
1 parent 2627b5e commit b570971

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/MPoly.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,5 +1655,7 @@ true
16551655
Like [`polynomial_ring(R::Ring, s::Vector{Symbol})`](@ref) but return only the
16561656
multivariate polynomial ring.
16571657
"""
1658-
polynomial_ring_only(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) where T<:Ring =
1659-
mpoly_ring_type(T)(R, s, internal_ordering, cached)
1658+
function polynomial_ring_only(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) where T<:Ring
1659+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
1660+
return mpoly_ring_type(T)(R, s, internal_ordering, cached)
1661+
end

src/NCPoly.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,10 @@ end
756756
Like [`polynomial_ring(R::NCRing, s::Symbol)`](@ref) but return only the
757757
polynomial ring.
758758
"""
759-
polynomial_ring_only(R::T, s::Symbol; cached::Bool=true) where T<:NCRing =
760-
poly_ring_type(T)(R, s, cached)
759+
function polynomial_ring_only(R::T, s::Symbol; cached::Bool=true) where T<:NCRing
760+
@req !is_trivial(R) "Zero rings are currently not supported as coefficient ring."
761+
return poly_ring_type(T)(R, s, cached)
762+
end
761763

762764
# Simplified constructor
763765

src/Residue.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ to the constructor with the same base ring $R$ and element $a$. A modulus
445445
of zero is not supported and throws an exception.
446446
"""
447447
function residue_ring(R::Ring, a::RingElement; cached::Bool = true)
448+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
448449
# Modulus of zero cannot be supported. E.g. A C library could not be expected to
449450
# do matrices over Z/0 using a Z/nZ type. The former is multiprecision, the latter not.
450451
iszero(a) && throw(DomainError(a, "Modulus must be nonzero"))
@@ -454,6 +455,7 @@ function residue_ring(R::Ring, a::RingElement; cached::Bool = true)
454455
end
455456

456457
function residue_ring(R::PolyRing, a::RingElement; cached::Bool = true)
458+
@req !is_trivial(R) "Zero rings are currently not supported as base ring."
457459
iszero(a) && throw(DomainError(a, "Modulus must be nonzero"))
458460
!is_unit(leading_coefficient(a)) && throw(DomainError(a, "Non-invertible leading coefficient"))
459461
T = elem_type(R)

src/generic/Misc/Localization.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ base_ring(L::LocalizedEuclideanRing) = L.base_ring::base_ring_type(L)
113113

114114
parent(a::LocalizedEuclideanRingElem) = a.parent
115115

116+
characteristic(::LocalizedEuclideanRing) = characteristic(base_ring(L))
117+
116118
###############################################################################
117119
#
118120
# Basic manipulation

0 commit comments

Comments
 (0)