fix error with printing of roots

This commit is contained in:
Marek Kaluba 2023-05-09 01:02:39 +02:00
parent 34e19768d4
commit d40a0fe117
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
3 changed files with 14 additions and 3 deletions

View File

@ -5,7 +5,7 @@ using LinearAlgebra
export Root, isproportional, isorthogonal, ~,
abstract type AbstractRoot{N,T} end
abstract type AbstractRoot{N,T} end # <: AbstractVector{T} ?
₂length(r::AbstractRoot) = norm(r, 2)
ambient_dim(r::AbstractRoot) = length(r)
@ -37,8 +37,8 @@ end
function Base.show(io::IO, ::MIME"text/plain", r::AbstractRoot)
l₂l = ₂length(r)
l = isinteger(l₂l) ? "$(l₂l)" : "$(l₂l^2)"
return print(io, "Root in ^$N of length $l\n", r.coord)
l = round(Int, l₂l) l₂l ? "$(round(Int, l₂l))" : "$(round(Int, l₂l^2))"
return print(io, "Root in ^$(length(r)) of length $l\n", r.coord)
end
function reflection(α::AbstractRoot, β::AbstractRoot)

10
test/roots.jl Normal file
View File

@ -0,0 +1,10 @@
using PropertyT.Roots
@testset "Roots" begin
@test Roots.Root{3,Int}([1, 2, 3]) isa Roots.AbstractRoot{}
@test Roots.Root([1, 2, 3]) isa Roots.AbstractRoot{3,Int}
# io
r = Roots.Root{3,Int}([1, 2, 3])
@test contains(sprint(show, MIME"text/plain"(), r), "of length √14\n")
r = Roots.Root{3,Int}([1, 2, 2])
@test contains(sprint(show, MIME"text/plain"(), r), "of length 3\n")
end

View File

@ -24,6 +24,7 @@ if haskey(ENV, "FULL_TEST") || haskey(ENV, "CI")
include("1712.07167.jl")
include("1812.03456.jl")
include("roots.jl")
include("graded_adj.jl")
include("Chevalley.jl")
end