Skip to content

Commit

Permalink
Tests and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joschmitt committed Sep 3, 2024
1 parent fd0380c commit 7bf9a01
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/LocalField/PowerSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function canonical_unit(a::LaurentSeriesFieldValuationRingElem)
iszero(a) && return one(parent(a), precision = precision(a))
v = valuation(a)
pi = uniformizer(parent(a))
return LaurentSeriesFieldValuationRingElem(parent(a), divexact(data(a), pi^v))
return divexact(data(a), pi^v)
end

################################################################################
Expand Down Expand Up @@ -104,7 +104,11 @@ function (Q::LaurentSeriesFieldValuationRing)(a::Generic.LaurentSeriesFieldElem)
@assert parent(a) === _field(Q)
@req valuation(a) >= 0 "Not an element of the valuation ring"
R = data(Q)
b = R([polcoeff(a, i) for i in 0:pol_length(a) - 1], pol_length(a), precision(a), valuation(a))
c = zeros(base_ring(R), pol_length(a) * Generic.scale(a))
for i in 0:pol_length(a) - 1
c[Generic.scale(a) * i + 1] = polcoeff(a, i)
end
b = R(c, Generic.scale(a) * pol_length(a), precision(a), valuation(a))
return Q(b)
end

Expand Down Expand Up @@ -291,11 +295,6 @@ function zero!(a::LaurentSeriesFieldValuationRingElem)
return a
end

function mul_red!(a::LaurentSeriesFieldValuationRingElem, b::LaurentSeriesFieldValuationRingElem, c::LaurentSeriesFieldValuationRingElem, f::Bool = false)
a.a = mul_red!(data(a), data(b), data(c), f)
return a
end

function mul!(a::LaurentSeriesFieldValuationRingElem, b::LaurentSeriesFieldValuationRingElem, c::LaurentSeriesFieldValuationRingElem)
a.a = mul!(data(a), data(b), data(c))
return a
Expand Down
1 change: 1 addition & 0 deletions test/LocalField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
include("LocalField/Completions.jl")
include("LocalField/Ring.jl")
include("LocalField/ResidueRing.jl")
include("LocalField/LaurentSeries.jl")
include("LocalField/PowerSeries.jl")
end
26 changes: 26 additions & 0 deletions test/LocalField/LaurentSeries.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@testset "Local field interface" begin
K, x = laurent_series_field(GF(3), 10, "x")
@test characteristic(K) == 3

p = uniformizer(K)
@test p == x

p = uniformizer(K, 3, prec = 5)
@test p == x^3
@test precision(p) == 5
q = setprecision(p, 10)
@test precision(p) == 5
@test precision(q) == 10

@test absolute_ramification_index(K) == 1

@test Hecke._valuation_integral(x^2) == 2

k, Ktok = residue_field(K)
@test k === base_ring(K)

@test_throws ErrorException Ktok(x^-1)
@test is_zero(Ktok(x))
@test is_one(Ktok(x + 1))
@test is_one(Ktok\one(k))
end
57 changes: 56 additions & 1 deletion test/LocalField/PowerSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,64 @@ end

@testset "Conformance tests" begin
K, x = laurent_series_field(GF(101), 30, "x", cached = false)
R = valuation_ring(K)
R = @inferred valuation_ring(K)
@test is_domain_type(elem_type(R))
@test !is_exact_type(elem_type(R))
test_Ring_interface(R)
#test_EuclideanRing_interface(R) # doesn't do anything for a non-exact ring
end

@testset "Ring to field" begin
K, x = laurent_series_field(GF(101), 30, "x")
R = @inferred valuation_ring(K)
p = uniformizer(R)
a = p + p^3 + 4*p^5
b = x + x^3 + 4*x^5
@test K(a) == b
@test R(b) == a

L, _ = laurent_series_field(GF(3), 10, "x")
@test_throws ErrorException L(a)

@test_throws AssertionError R(gen(L))
@test_throws ArgumentError R(x^-1)
end

@testset "Euclidean functionality" begin
K, x = laurent_series_field(GF(101), 30, "x")
R = @inferred valuation_ring(K)
p = uniformizer(R)

for a in [zero(R), p, p + 1, p^2]
for b in [p, p + 1, p^2]
q, r = divrem(a, b)
@test a == q*b + r
if !is_zero(r)
@test valuation(r) < valuation(b)
end
q = div(a, b)
if !is_zero(a - q*b)
@test valuation(a - q*b) < valuation(b)
end
end
end

for a in [zero(R), p, p + 1, p^2]
for b in [zero(R), p, p + 1, p^2]
g, u, v = gcdx(a, b)

@test u*a + v*b == g
if !is_zero(a) && !is_zero(b)
@test valuation(g) == min(valuation(a), valuation(b))
end
end
end
end

@testset "Construction" begin
# Test type stability for different field types
for F in [GF(3), Native.GF(3), Native.GF(ZZ(3)), Native.GF(3, 2), Native.GF(ZZ(3), 2)]
K, _ = laurent_series_field(F, 10, "x")
@inferred valuation_ring(K)
end
end
6 changes: 6 additions & 0 deletions test/LocalField/ResidueRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ end
@test is_exact_type(elem_type(R))
test_Ring_interface(R)

p = uniformizer(R)
@test p == R(pi)
@test p == R(uniformizer(K))
p = uniformizer(R, 2)
@test p == R(pi^2)

# the euclidean conformance test seems to assume that the ring is a domain
R, _ = residue_ring(O, pi)
test_EuclideanRing_interface(R)
Expand Down

0 comments on commit 7bf9a01

Please sign in to comment.