Skip to content

Commit

Permalink
fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha Demin committed Aug 31, 2024
1 parent 4c77d39 commit 7efb268
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ext/GroebnerDynamicPolynomialsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end

function dp_ordering_sym2typed(ord::Symbol)
if !(ord in (:lex, :deglex, :degrevlex))
__throw_input_not_supported(ord, "Not a supported ordering.")
throw(DomainError("Not a supported ordering."))
end
if ord === :lex
Lex()
Expand Down
9 changes: 3 additions & 6 deletions src/input_output/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,14 @@ function _io_check_input(polynomials::Vector{T}) where {T}
R = AbstractAlgebra.parent(first(polynomials))
K = AbstractAlgebra.base_ring(R)
if !(K isa AbstractAlgebra.Field)
__throw_input_not_supported("Coefficient ring must be a field", K)
throw(DomainError("Coefficient ring must be a field: $K"))
end
if (AbstractAlgebra.characteristic(K) > typemax(UInt64))
__throw_input_not_supported(
"Field characteristic must be less than 2^64",
AbstractAlgebra.characteristic(K)
)
throw(DomainError("Field characteristic must be less than 2^64"))
end
if !iszero(AbstractAlgebra.characteristic(K))
if !isone(AbstractAlgebra.degree(K))
__throw_input_not_supported("Non-prime coefficient fields are not supported", K)
throw(DomainError("Non-prime coefficient fields are not supported"))
end
end
true
Expand Down
3 changes: 2 additions & 1 deletion src/monomials/exponent_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Base.showerror(io::IO, e::MonomialDegreeOverflow) = print(io, e.msg)
@noinline __throw_monom_overflow_error(c, B) =
throw(MonomialDegreeOverflow("Overflow may happen with the entry $c of type $B."))

monom_overflow_threshold(::Type{T}) where {T <: Integer} = div(typemax(T), 2)
monom_overflow_check(a::T) where {T <: Integer} = monom_overflow_check(a, T)

function monom_overflow_check(a::Integer, ::Type{T}) where {T}
a >= div(typemax(T), 2) && __throw_monom_overflow_error(a, T)
a >= monom_overflow_threshold(T) && __throw_monom_overflow_error(a, T)
true
end

Expand Down
2 changes: 1 addition & 1 deletion test/monoms/exponentvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@test Groebner.monom_to_vector!(tmp, ev) == x
@test tmp == x

@test Groebner._monom_overflow_check(ev)
@test Groebner.monom_overflow_check(ev)

ev = Groebner.monom_construct_from_vector(PV{UInt32}, x)
@test ev == UInt32.([10, 1, 2, 3, 0, 4])
Expand Down
2 changes: 1 addition & 1 deletion test/monoms/monom_arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ implementations_to_test = [

t = div(typemax(UInt8), 2k) - 1
x, y = rand(1:t, k), rand(1:t, k)
if sum(x) + sum(y) >= Groebner._monom_overflow_threshold(UInt8)
if sum(x) + sum(y) >= Groebner.monom_overflow_threshold(UInt8)
continue
end
as =
Expand Down
11 changes: 2 additions & 9 deletions test/monoms/monom_orders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ implementations_to_test = [

t = div(typemax(UInt8), k) - 1
x, y = rand(1:t, k), rand(1:t, k)
if sum(x) >= Groebner._monom_overflow_threshold(UInt8)
if sum(x) >= Groebner.monom_overflow_threshold(UInt8)
continue
end
if sum(y) >= Groebner._monom_overflow_threshold(UInt8)
if sum(y) >= Groebner.monom_overflow_threshold(UInt8)
continue
end
as = [
Expand Down Expand Up @@ -403,13 +403,6 @@ end
1 0;
]
)
@test_throws DomainError Groebner.MatrixOrdering(
x,
[
1 -8 1
2 0 3
]
)

mo_to_test = [
(ord=ord1, ans=[true, false]),
Expand Down

0 comments on commit 7efb268

Please sign in to comment.