Skip to content

Commit 03e160f

Browse files
authored
Merge pull request #238 from JuliaDiff/ox/show
Include outer brackets in pretty printing
2 parents 7be0a92 + 32dac39 commit 03e160f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/tangent.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ function ExplicitTangentBundle{N,B,P}(primal::B, partials::P) where {N, B, P}
214214
end
215215

216216
function Base.show(io::IO, x::ExplicitTangentBundle)
217+
print(io, "(")
217218
print(io, x.primal)
218219
print(io, " + ")
219220
x = x.tangent
@@ -224,6 +225,7 @@ function Base.show(io::IO, x::ExplicitTangentBundle)
224225
length(x.partials) >= 5 && print(io, " + ", x.partials[5], " ∂₁ ∂₃")
225226
length(x.partials) >= 6 && print(io, " + ", x.partials[6], " ∂₂ ∂₃")
226227
length(x.partials) >= 7 && print(io, " + ", x.partials[7], " ∂₁ ∂₂ ∂₃")
228+
print(io, ")")
227229
end
228230

229231

@@ -250,12 +252,8 @@ end
250252
@ChainRulesCore.non_differentiable check_taylor_invariants(coeffs, primal, N)
251253

252254

253-
function Base.show(io::IO, x::TaylorBundle{1})
254-
print(io, x.primal)
255-
print(io, " + ")
256-
x = x.tangent
257-
print(io, x.coeffs[1], " ∂₁")
258-
end
255+
Base.show(io::IO, x::TaylorBundle{1}) = print(io, "($(x.primal) + $(only(x.tangent.coeffs)) ∂₁)")
256+
259257

260258
"for a TaylorTangent{N, <:Tuple} this breaks it up unto 1 TaylorTangent{N} for each element of the primal tuple"
261259
function destructure(r::TaylorBundle{N, B}) where {N, B<:Tuple}

0 commit comments

Comments
 (0)