diff --git a/Project.toml b/Project.toml index e03faf6d4..3145c94e3 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ RandomExtensions = "fb686558-2515-59ef-acaa-46db3789a887" SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" [compat] -AbstractAlgebra = "0.32.3" +AbstractAlgebra = "0.32.4" Antic_jll = "~0.201.500" Arb_jll = "~200.2300.000" Calcium_jll = "~0.401.100" diff --git a/src/flint/FlintTypes.jl b/src/flint/FlintTypes.jl index 4294fffd8..eb236fd58 100644 --- a/src/flint/FlintTypes.jl +++ b/src/flint/FlintTypes.jl @@ -37,6 +37,8 @@ end const FlintZZ = ZZRing() +integer_ring() = ZZRing() + @doc zz_ring_doc mutable struct ZZRingElem <: RingElem d::Int @@ -163,6 +165,8 @@ end const FlintQQ = QQField() +rational_field() = FlintQQ + @doc qq_field_doc mutable struct QQFieldElem <: FracElem{ZZRingElem} num::Int diff --git a/src/flint/fmpq.jl b/src/flint/fmpq.jl index c79abc283..6db998f60 100644 --- a/src/flint/fmpq.jl +++ b/src/flint/fmpq.jl @@ -8,7 +8,7 @@ export QQFieldElem, FlintQQ, fraction_field, Rational, QQField, height, height_bits, isless, reconstruct, next_minimal, next_signed_minimal, next_calkin_wilf, next_signed_calkin_wilf, dedekind_sum, harmonic, bernoulli, bernoulli_cache, rand_bits, simplest_between, valuation!, - remove! + remove!, rational_field ############################################################################### # @@ -218,8 +218,7 @@ end function show(io::IO, a::QQField) if get(io, :supercompact, false) # no nested printing - io = AbstractAlgebra.pretty(io) - print(io, AbstractAlgebra.LowercaseOff(), "QQ") + print(pretty(io), LowercaseOff(), "QQ") else # nested printing allowed, preferably supercompact print(io, "Rational field") diff --git a/src/flint/fmpz.jl b/src/flint/fmpz.jl index 4bfc3a2fe..dc65ba2e5 100644 --- a/src/flint/fmpz.jl +++ b/src/flint/fmpz.jl @@ -38,7 +38,7 @@ export ZZRingElem, FlintZZ, ZZRing, parent, show, convert, hash, bell, one, zero, divexact, fits, sign, nbits, deepcopy, tdivpow2, fdivpow2, cdivpow2, flog, clog, cmpabs, clrbit!, setbit!, combit!, crt, crt_with_lcm, divisible, divisors, prime_divisors, divisor_lenstra, - fmodpow2, + fmodpow2, integer_ring, gcdinv, gcd_with_cofactors, is_probable_prime, jacobi_symbol, kronecker_symbol, remove, root, size, isqrtrem, sqrtmod, trailing_zeros, divisor_sigma, euler_phi, fibonacci, @@ -271,9 +271,8 @@ show(io::IO, x::ZZRingElem) = print(io, string(x)) function show(io::IO, a::ZZRing) if get(io, :supercompact, false) - io = pretty(io) # no nested printing - print(io, LowercaseOff(), "ZZ") + print(pretty(io), LowercaseOff(), "ZZ") else # nested printing allowed, preferably supercompact print(io, "Integer ring") diff --git a/test/flint/fmpq-test.jl b/test/flint/fmpq-test.jl index 373569a26..29a54651d 100644 --- a/test/flint/fmpq-test.jl +++ b/test/flint/fmpq-test.jl @@ -1,3 +1,5 @@ +import Nemo: AbstractAlgebra.PrettyPrinting + function test_elem(R::QQField) return rand_bits(ZZ, rand(0:100))//rand_bits(ZZ, rand(1:100)) end @@ -538,3 +540,14 @@ end @test b_copy == b @test c_copy == c end + +@testset "QQFieldElem.printing" begin + @test FlintQQ === rational_field() + @test PrettyPrinting.detailed(FlintQQ) == "Rational field" + @test PrettyPrinting.oneline(FlintQQ) == "Rational field" + @test PrettyPrinting.supercompact(FlintQQ) == "QQ" + + io = PrettyPrinting.pretty(IOBuffer()) + print(IOContext(io, :supercompact => true), PrettyPrinting.Lowercase(), FlintQQ) + @test String(take!(io)) == "QQ" +end diff --git a/test/flint/fmpz-test.jl b/test/flint/fmpz-test.jl index a9c3d4fda..9d79f05ac 100644 --- a/test/flint/fmpz-test.jl +++ b/test/flint/fmpz-test.jl @@ -1,8 +1,10 @@ +import Nemo: AbstractAlgebra.PrettyPrinting + function test_elem(R::ZZRing) return rand_bits(ZZ, rand(0:100)) end -@testset "ZZFieldElem.conformance_tests" begin +@testset "ZZRingElem.conformance_tests" begin test_Ring_interface_recursive(FlintZZ) end @@ -1371,3 +1373,13 @@ end @test ncdivrem(ZZ(-6), ZZ(-4)) == (+2, +2) end +@testset "ZZRingElem.printing" begin + @test FlintZZ === integer_ring() + @test PrettyPrinting.detailed(FlintZZ) == "Integer ring" + @test PrettyPrinting.oneline(FlintZZ) == "Integer ring" + @test PrettyPrinting.supercompact(FlintZZ) == "ZZ" + + io = PrettyPrinting.pretty(IOBuffer()) + print(IOContext(io, :supercompact => true), PrettyPrinting.Lowercase(), FlintZZ) + @test String(take!(io)) == "ZZ" +end