mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-12-26 02:30:29 +01:00
fix error with printing of roots
This commit is contained in:
parent
34e19768d4
commit
d40a0fe117
@ -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
10
test/roots.jl
Normal 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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user