Skip to content

Fix edge-case in ConformanceTests.generate_element(::MPolyRing) #2077

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

Merged
merged 3 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions docs/src/ring_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ throwing an exception, returning meaningless results, hanging or crashing. The
function should only be called with `check=false` if it is already known that the
division will be exact.

***Note:*** For the *recursive* ring tests to work, one needs to also implement `divides(f::MyElem, g::MyElem)`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think divides is only required for euclidean rings: only test_EuclideanRing_interface calls it. Which is in turn only invoked automatically for univariate polynomial rings over a field...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there are generic divides methods for that, i.e.:

divides(f::PolyRingElem{T}, g::PolyRingElem{T}) where T <: RingElement
divides(z::PolyRingElem{T}, x::T) where T <: RingElement

So it would be really good to know what the actual problem you run into was?


### Inverse

```julia
Expand Down
2 changes: 1 addition & 1 deletion src/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ function ConformanceTests.generate_element(Rx::MPolyRing)
len_bound = 8
exp_bound = rand(1:5)
len = rand(0:len_bound)
coeffs = [ConformanceTests.generate_element(R) for _ in 1:len]
coeffs = elem_type(R)[ConformanceTests.generate_element(R) for _ in 1:len]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of empty lists, this was of type Vector{Any} despite the generation function being type stable. This caused more problems down the road.

exps = [[rand(0:exp_bound) for _ in 1:num_gens] for _ in 1:len]
return Rx(coeffs, exps)
end
Expand Down
Loading