Skip to content

Commit

Permalink
Merge pull request #532 from oscar-system/th/quograd
Browse files Browse the repository at this point in the history
Fix coercion into quotient rings
  • Loading branch information
fieker committed Jul 7, 2021
2 parents 209c89f + aa68a43 commit c9fde9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Rings/MPolyQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -652,16 +652,18 @@ function (Q::MPolyQuo)(a::MPolyQuoElem)
end

function (Q::MPolyQuo)(a::MPolyElem)
@assert parent(a) == Q.R
return MPolyQuoElem(Q.R(a), Q)
if base_ring(Q) === parent(a)
return MPolyQuoElem(a, Q)
else
return MPolyQuoElem(Q.R(a), Q)
end
end

function (Q::MPolyQuo)(a::Singular.spoly)
@assert singular_ring(Q) == parent(a)
return MPolyQuoElem(Q.R(a), Q)
end


function (S::Singular.PolyRing)(a::MPolyQuoElem)
Q = parent(a)
@assert singular_ring(Q) == S
Expand Down
6 changes: 6 additions & 0 deletions test/Rings/mpoly-graded-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ end
end
end

@testset "Coercion" begin
R, (x, y) = grade(PolynomialRing(QQ, ["x", "y"])[1]);
Q = quo(R, ideal([x^2, y]))[1];
@test parent(Q(x)) === Q
@test parent(Q(gens(R.R)[1])) === Q
end
@testset "Evaluation" begin
R, (x,y) = grade(PolynomialRing(QQ, ["x", "y"])[1]);
@test x(y, x) == y
Expand Down

0 comments on commit c9fde9d

Please sign in to comment.