Skip to content
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

Make base_ring_type work for (M)SeriesRing #1686

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion src/AbsMSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ symbols(R::MSeriesRing) = R.sym

parent(a::MSeriesElem) = a.parent

base_ring_type(::Type{MSeriesRing{T}}) where T <: RingElement = parent_type(T)
base_ring_type(::Type{<:MSeriesRing{T}}) where T <: RingElement = parent_type(T)

function base_ring(R::MSeriesRing{T}) where T <: RingElement
return base_ring(poly_ring(R))::parent_type(T)
Expand Down
2 changes: 1 addition & 1 deletion src/RelSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end

parent(a::SeriesElem) = a.parent

base_ring_type(::Type{SeriesRing{T}}) where T <: RingElement = parent_type(T)
base_ring_type(::Type{<:SeriesRing{T}}) where T <: RingElement = parent_type(T)

base_ring(R::SeriesRing{T}) where T <: RingElement = R.base_ring::parent_type(T)

Expand Down
4 changes: 2 additions & 2 deletions src/generic/LaurentSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

elem_type(::Type{LaurentSeriesField{T}}) where T <: FieldElement = LaurentSeriesFieldElem{T}

base_ring_type(::Type{<:LaurentSeriesRing{T}}) where T <: RingElement = parent_type(T)
base_ring_type(::Type{LaurentSeriesRing{T}}) where T <: RingElement = parent_type(T)

base_ring_type(::Type{<:LaurentSeriesField{T}}) where T <: FieldElement = parent_type(T)
base_ring_type(::Type{LaurentSeriesField{T}}) where T <: FieldElement = parent_type(T)

Check warning on line 38 in src/generic/LaurentSeries.jl

View check run for this annotation

Codecov / codecov/patch

src/generic/LaurentSeries.jl#L38

Added line #L38 was not covered by tests

base_ring(R::LaurentSeriesRing{T}) where T <: RingElement = R.base_ring::parent_type(T)

Expand Down
9 changes: 9 additions & 0 deletions test/generic/AbsMSeries-test.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
function test_elem(R::AbstractAlgebra.Generic.AbsMSeriesRing{BigInt})
rand(R, 0:12, -10:10)
end

@testset "Generic.AbsMSeries.conformance" begin
R, (x, y) = power_series_ring(ZZ, [5, 3], ["x", "y"])
test_Ring_interface(R)
end

@testset "Generic.AbsMSeries.constructors" begin
S, x = polynomial_ring(ZZ, "x")

Expand Down
9 changes: 9 additions & 0 deletions test/generic/AbsSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
# Note: only useful to distinguish rings and fields for 1/2, 3/4, 5/6 if the
# algos differ, and 7 can often stand in for 5/6 if the algorithm supports it.

function test_elem(R::AbstractAlgebra.Generic.AbsPowerSeriesRing{BigInt})
rand(R, 0:12, -10:10)
end

@testset "Generic.AbsSeries.conformance" begin
R, x = power_series_ring(ZZ, 30, "x", model=:capped_absolute)
test_Ring_interface(R)
end

@testset "Generic.AbsSeries.types" begin
@test abs_series_type(BigInt) == Generic.AbsSeries{BigInt}
@test abs_series_type(Rational{BigInt}) == Generic.AbsSeries{Rational{BigInt}}
Expand Down
10 changes: 10 additions & 0 deletions test/generic/FunctionField-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ U2, z2 = R2["z2"]
P2 = [(x2 + 1)*z2 + (x2 + 2), z2 + (x2 + 1)//(x2 + 2), z2^2 + 3z2 + 1,
(x2^2 + 1)//(x2 + 1)*z2^5 + 4z2^4 + (x2 + 2)*z2^3 + x2//(x2 + 1)*z2 + 1//(x2 + 1)]

# FIXME/TODO: conformance tests run into infinite loop???
#function test_elem(R::AbstractAlgebra.Generic.FunctionField{Rational{BigInt}})
# rand(R, 1:10, -10:10)
#end
#
#@testset "Generic.FunctionField.conformance" begin
# S, y = function_field(P1[4], "y")
# test_Ring_interface(S)
#end

@testset "Generic.FunctionField.constructors" begin
@test function_field(P1[1], "y")[1] === function_field(P1[1], "y", cached=true)[1]
@test function_field(P1[1], "y", cached=true)[1] !== function_field(P1[1], "y", cached=false)[1]
Expand Down
9 changes: 9 additions & 0 deletions test/generic/LaurentSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
# Note: only useful to distinguish rings and fields for 1/2, 3/4, 5/6 if the
# algos differ, and 7 can often stand in for 5/6 if the algorithm supports it.

function test_elem(R::AbstractAlgebra.Generic.LaurentSeriesRing{BigInt})
rand(R, 0:12, -10:10)
end

@testset "Generic.LaurentSeries.conformance" begin
R, x = laurent_series_ring(ZZ, 10, "x")
test_Ring_interface(R)
end

@testset "Generic.LaurentSeries.constructors" begin
R, x = laurent_series_ring(ZZ, 30, "x")

Expand Down
9 changes: 9 additions & 0 deletions test/generic/PuiseuxSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
# Note: only useful to distinguish rings and fields for 1/2, 3/4, 5/6 if the
# algos differ, and 7 can often stand in for 5/6 if the algorithm supports it.

function test_elem(R::AbstractAlgebra.Generic.PuiseuxSeriesRing{BigInt})
rand(R, -12:12, 1:6, -10:10)
end

@testset "Generic.PuiseuxSeries.conformance" begin
R, x = puiseux_series_ring(ZZ, 10, "x")
test_Ring_interface(R)
end

@testset "Generic.PuiseuxSeries.constructors" begin
R, x = puiseux_series_ring(ZZ, 30, "x")

Expand Down
9 changes: 9 additions & 0 deletions test/generic/RationalFunctionField-test.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
function test_elem(R::AbstractAlgebra.Generic.RationalFunctionField{Rational{BigInt}})
rand(R, 0:3, -3:3)
end

@testset "Generic.FunctionField.conformance" begin
S, x = rational_function_field(QQ, "x")
test_Ring_interface(S)
end

@testset "Generic.RationalFunctionField.constructors" begin
# Univariate

Expand Down
9 changes: 9 additions & 0 deletions test/generic/RelSeries-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
# Note: only useful to distinguish rings and fields for 1/2, 3/4, 5/6 if the
# algos differ, and 7 can often stand in for 5/6 if the algorithm supports it.

function test_elem(R::AbstractAlgebra.Generic.RelPowerSeriesRing{BigInt})
rand(R, 0:12, -10:10)
end

@testset "Generic.RelSeries.conformance" begin
R, x = power_series_ring(ZZ, 10, "x")
test_Ring_interface(R)
end

@testset "Generic.RelSeries.types" begin
@test rel_series_type(BigInt) == Generic.RelSeries{BigInt}
@test rel_series_type(Rational{BigInt}) == Generic.RelSeries{Rational{BigInt}}
Expand Down
12 changes: 12 additions & 0 deletions test/generic/SparsePoly-test.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# FIXME/TODO: get these conformance tests to work and pass
#function test_elem(Rx::AbstractAlgebra.Generic.SparsePolyRing)
# R = base_ring(Rx)
# x = gen(Rx)
# return sum(x^(5*i) * test_elem(R) for i in 1:rand(0:6); init=zero(Rx))
#end
#
#@testset "Generic.SparsePoly.conformance" begin
# R, x = SparsePolynomialRing(ZZ, "x")
# test_Ring_interface(R)
#end

@testset "Generic.SparsePoly.constructors" begin
R, x = SparsePolynomialRing(ZZ, "x")
S, y = SparsePolynomialRing(R, "y")
Expand Down
Loading