Skip to content

Commit bc05d53

Browse files
shorten model
1 parent 5d4b36c commit bc05d53

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

  • src/frontend/specification

src/frontend/specification/Sem.jl

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,35 @@ for f in (
2828
end
2929

3030
function Base.show(io::IO, term::LossTerm)
31-
print(io, nameof(losstype(term)))
32-
print(io, "\n")
33-
if !isnothing(id(term))
34-
print(io, " - id: $(id(term)) \n")
35-
end
36-
if issemloss(term)
37-
print(io, " - observed: $(nameof(typeof(observed(loss(term))))) \n")
38-
print(io, " - implied: $(nameof(typeof(implied(loss(term))))) \n")
39-
end
40-
if !isnothing(weight(term))
41-
print(io, " - weight: $(round(weight(term), digits=3))")
31+
if (:compact => true) in io
32+
if !isnothing(id(term))
33+
print(io, ":$(id(term)): ")
34+
end
35+
print(io, nameof(losstype(term)))
36+
if issemloss(term)
37+
print(
38+
io,
39+
" ($(nsamples(term)) samples, $(nobserved_vars(term)) observed, $(nlatent_vars(term)) latent variables)",
40+
)
41+
end
42+
if !isnothing(weight(term))
43+
print(io, " w=$(round(weight(term), digits=3))")
44+
else
45+
print(io, " w=1")
46+
end
47+
else
48+
print(io, nameof(losstype(term)))
49+
print(io, "\n")
50+
if !isnothing(id(term))
51+
print(io, " - id: $(id(term)) \n")
52+
end
53+
if issemloss(term)
54+
print(io, " - observed: $(nameof(typeof(observed(loss(term))))) \n")
55+
print(io, " - implied: $(nameof(typeof(implied(loss(term))))) \n")
56+
end
57+
if !isnothing(weight(term))
58+
print(io, " - weight: $(round(weight(term), digits=3))")
59+
end
4260
end
4361
end
4462

@@ -609,6 +627,7 @@ function Base.show(io::IO, sem::AbstractSem)
609627
print(io, _subtype_info(sem))
610628
print("\n")
611629
print(io, "- Loss Functions \n")
630+
io = length(loss_terms(sem)) >= 5 ? IOContext(io, :compact => true) : io
612631
for term in loss_terms(sem)
613632
print(io, " > ")
614633
print(io, term)

0 commit comments

Comments
 (0)