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) ``` diff --git a/src/root_object.jl b/src/root_object.jl index 3b997f7..5292cc5 100644 --- a/src/root_object.jl +++ b/src/root_object.jl @@ -57,23 +57,22 @@ 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 + 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