From 6af74c4ad8b9b51fe6815e32510b4f9dc10483b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Richard?= Date: Wed, 24 Jun 2026 17:20:15 +0200 Subject: [PATCH 1/3] Change display in :compact IOContext --- src/root_object.jl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/root_object.jl b/src/root_object.jl index 3b997f7..e5ae3eb 100644 --- a/src/root_object.jl +++ b/src/root_object.jl @@ -57,11 +57,8 @@ isunique(rt::Root{T}) where {T} = (rt.status == :unique) function show(io::IO, rt::Root) print(io, "Root($(rt.region), :$(rt.status))") -end -function show(io::IO, ::MIME"text/plain", rt::Root) - show(io, rt) - if rt.status == :unknown + if !get(io, :compact, false) && rt.status == :unknown if rt.convergence == :tolerance print(io, "\n Not converged: region size smaller than the tolerance") elseif rt.convergence == :max_iterartion From c06f8e4d830366d218f340335083007b9d9bf768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Richard?= Date: Wed, 24 Jun 2026 17:20:15 +0200 Subject: [PATCH 2/3] Use fancy connectors to group the information --- src/root_object.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/root_object.jl b/src/root_object.jl index e5ae3eb..5292cc5 100644 --- a/src/root_object.jl +++ b/src/root_object.jl @@ -59,18 +59,20 @@ function show(io::IO, rt::Root) print(io, "Root($(rt.region), :$(rt.status))") if !get(io, :compact, false) && rt.status == :unknown + connector = isnothing(rt.error) ? "└" : "├" + if rt.convergence == :tolerance - print(io, "\n Not converged: region size smaller than the tolerance") + print(io, "\n $connector Not converged: region size smaller than the tolerance") elseif rt.convergence == :max_iterartion - print(io, "\n Not converged: reached maximal number of iterations") + print(io, "\n $connector Not converged: reached maximal number of iterations") elseif rt.convergence == :none - print(io, "\n Not converged: the root is still being processed") + print(io, "\n $connector Not converged: the root is still being processed") else - print(io, "\n Not converged: unknown reason $(rt.convergence)") + print(io, "\n $connector Not converged: unknown reason $(rt.convergence)") end if !isnothing(rt.error) - print(io, "\n Warning: error encountered during computation (use showerror(root.error) to see the whole stacktrace)\n ") + print(io, "\n ├ Warning: error encountered during computation (use showerror(root.error) to see the whole stacktrace)\n └ ") showerror(io, rt.error[1]) end end From 0bcfd9b08c6500a72eaf4fcb4d07bcec96f1c341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Richard?= Date: Wed, 24 Jun 2026 17:56:27 +0200 Subject: [PATCH 3/3] Fix doctests --- docs/src/index.md | 3 +++ docs/src/internals.md | 5 +++++ docs/src/roots.md | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/docs/src/index.md b/docs/src/index.md index 61669de..d78de8f 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -29,6 +29,7 @@ julia> using IntervalArithmetic, IntervalArithmetic.Symbols, IntervalRootFinding julia> rts = roots(x -> x^2 - 2x, 0..10) 2-element Vector{Root{Interval{Float64}}}: Root([0.0, 3.73951e-8]_com_NG, :unknown) + └ Not converged: region size smaller than the tolerance Root([1.99999, 2.00001]_com_NG, :unique) ``` @@ -71,7 +72,9 @@ julia> roots(g, -10..10) 4-element Vector{Root{Interval{Float64}}}: Root([-1.73206, -1.73205]_com_NG, :unique) Root([-1.41422, -1.41421]_com_NG, :unknown) + └ Not converged: region size smaller than the tolerance Root([1.41421, 1.41422]_com_NG, :unknown) + └ Not converged: region size smaller than the tolerance Root([1.73205, 1.73206]_com_NG, :unique) ``` diff --git a/docs/src/internals.md b/docs/src/internals.md index e64fbf0..0b1c7c3 100644 --- a/docs/src/internals.md +++ b/docs/src/internals.md @@ -100,10 +100,15 @@ SearchState{BreadthFirst{Root{Interval{Float64}}}, Root{Interval{Float64}}} iteration: 15 5 regions being processed Root([-0.078125, 1.15235]_com, :unknown) + └ Not converged: the root is still being processed Root([-3.84735, -2.5975]_com, :unknown) + └ Not converged: the root is still being processed Root([-5.07782, -3.84734]_com, :unknown) + └ Not converged: the root is still being processed Root([-8.78861, -7.55813]_com, :unknown) + └ Not converged: the root is still being processed Root([-10.0, -8.7886]_com, :unknown) + └ Not converged: the root is still being processed 1 finalized regions Root([-6.28132, -6.28131]_com, :unique) diff --git a/docs/src/roots.md b/docs/src/roots.md index 12b1b94..a43985c 100644 --- a/docs/src/roots.md +++ b/docs/src/roots.md @@ -28,6 +28,7 @@ julia> roots(log, -2..2 ; contractor = Krawczyk) julia> roots(log, -2..2 ; contractor = Bisection) 1-element Vector{Root{Interval{Float64}}}: Root([0.999999, 1.00001]_com, :unknown) + └ Not converged: region size smaller than the tolerance ``` Note that as shown in the example, the `log` function does not complain about being given an interval going outside its domain. While this may be surprising, this is the expected behavior and no root will ever be found outside the domain of a function. @@ -168,6 +169,9 @@ julia> roots(f, -10 .. 10) 3-element Vector{Root{Interval{Float64}}}: Root([0.0, 0.0]_com, :unique) Root([1.99999, 2.00001]_com, :unknown) + ├ Not converged: region size smaller than the tolerance + ├ Warning: error encountered during computation (use showerror(root.error) to see the whole stacktrace) + └ InconclusiveBooleanOperation: The operation `[2.0, 2.0]_com_NG < [1.99999, 2.00001]_com` cannot be determined unambiguously. See the documentation for more information. See also `strictprecedes`. Root([7.0, 7.0]_com_NG, :unique) ```