Skip to content

Commit c563791

Browse files
committed
modified displaying
1 parent be005d6 commit c563791

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/display.jl

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,31 @@ end
324324

325325
function representation(X::IntervalBox{N, T}, format=nothing) where {N, T}
326326

327-
isempty(X) && return string("", superscriptify(N))
328-
329327
if format == nothing
330328
format = display_params.format # default
331329
end
332330

333-
if all(==(first(X)), X)
334-
return string(representation(first(X), format), superscriptify(N))
331+
n = format == :full ? N : superscriptify(N)
332+
333+
if isempty(X)
334+
format == :full && return string("IntervalBox(∅, ", n, ")")
335+
return string("", n)
336+
end
337+
338+
x = first(X)
339+
if all(==(x), X)
340+
if format == :full
341+
return string("IntervalBox(", representation(x, format), ", ", n, ")")
342+
elseif format == :midpoint
343+
return string("(", representation(x, format), ")", n)
344+
else
345+
return string(representation(x, format), n)
346+
end
335347
end
336348

337349
if format == :full
338-
return string("IntervalBox(", join(X.v, ", "), ")")
350+
full_str = representation.(X.v, :full)
351+
return string("IntervalBox(", join(full_str, ", "), ")")
339352
elseif format == :midpoint
340353
return string("(", join(X.v, ") × ("), ")")
341354
else

test/display_tests/display.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ setprecision(Interval, Float64)
175175
@test string(X) == "[-∞, ∞]²"
176176

177177
setformat(:full)
178-
@test string(X) == "Interval(-Inf, Inf)²"
178+
@test string(X) == "IntervalBox(Interval(-Inf, Inf), 2)"
179179

180180
end
181181
end

0 commit comments

Comments
 (0)