Skip to content

Commit

Permalink
Fix show for tangent types with free diff level
Browse files Browse the repository at this point in the history
Follows up #136
  • Loading branch information
Keno committed Apr 9, 2023
1 parent 3751c0f commit 44c0094
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tangent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,20 @@ wrapper_name(::Type{<:AbstractZeroBundle}) = "AbstractZeroBundle"

function Base.show(io::IO, T::Type{<:AbstractZeroBundle{N, B}}) where {N,B}
print(io, wrapper_name(T))
print(io, "{$N, ")
print(io, @isdefined(N) ? "{$N, " : "{N, ")
show(io, B)
print(io, "}")
end

function Base.show(io::IO, T::Type{<:AbstractZeroBundle{N}}) where {N}
print(io, wrapper_name(T))
print(io, "{$N}")
@isdefined(N) && print(io, "{$N}")
end

function Base.show(io::IO, t::AbstractZeroBundle{N}) where N
print(io, wrapper_name(typeof(t)))
print(io, "{$N}(")
@isdefined(N) && print(io, "{$N}")
print(io, "(")
show(io, t.primal)
print(io, ")")
end
Expand Down
2 changes: 2 additions & 0 deletions test/tangent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ using Test
@test repr(ZeroBundle{1}) == "ZeroBundle{1}"
@test repr(ZeroBundle{1, Float64}) == "ZeroBundle{1, Float64}"

@test repr((ZeroBundle{N, Float64} where N).body) == "ZeroBundle{N, Float64}"

@test repr(typeof(DNEBundle{1}(getfield))) == "DNEBundle{1, typeof(getfield)}"
end
end
Expand Down

0 comments on commit 44c0094

Please sign in to comment.