@@ -2,7 +2,7 @@ using Term
2
2
3
3
const TRACE_COLORS = (" bright_green" , " hot_pink" , " bright_blue" , " light_coral" , " bright_cyan" , " sandy_brown" , " violet" )
4
4
5
- Base. show (io:: IO , :: MIME"text/plain" , t:: Union{Trace,Traces,Episode,Episodes} ) = tprint (io, convert (Term. AbstractRenderable, t; width= displaysize (io)[2 ]) |> string)
5
+ Base. show (io:: IO , :: MIME"text/plain" , t:: Union{Trace,Traces,Episode,Episodes,Trajectory } ) = tprint (io, convert (Term. AbstractRenderable, t; width= displaysize (io)[2 ]) |> string)
6
6
7
7
inner_convert (:: Type{Term.AbstractRenderable} , s:: String ; style= " gray1" , width= 88 ) = Panel (s, width= width, style= style, justify= :center )
8
8
inner_convert (t:: Type{Term.AbstractRenderable} , x:: Union{Symbol,Number} ; kw... ) = inner_convert (t, string (x); kw... )
@@ -63,7 +63,8 @@ function Base.convert(::Type{Term.AbstractRenderable}, t::Traces; width=88)
63
63
style= " yellow3" ,
64
64
subtitle= " $N traces in total" ,
65
65
subtitle_justify= :right ,
66
- width= width
66
+ width= width,
67
+ fit= true
67
68
)
68
69
end
69
70
@@ -74,7 +75,8 @@ function Base.convert(::Type{Term.AbstractRenderable}, e::Episode; width=88)
74
75
style= " green_yellow" ,
75
76
subtitle= e[] ? " Episode END" : " Episode growing..." ,
76
77
subtitle_justify= :right ,
77
- width= width
78
+ width= width,
79
+ fit= true
78
80
)
79
81
end
80
82
@@ -99,6 +101,35 @@ function Base.convert(::Type{Term.AbstractRenderable}, e::Episodes; width=88)
99
101
subtitle= " $n episodes in total" ,
100
102
subtitle_justify= :right ,
101
103
width= width,
104
+ fit= true ,
102
105
style= " wheat1"
103
106
)
104
- end
107
+ end
108
+
109
+ function Base. convert (r:: Type{Term.AbstractRenderable} , t:: Trajectory ; width= 88 )
110
+ Panel (
111
+ convert (r, t. container; width= width - 8 ) /
112
+ Panel (convert (Term. Tree, t. sampler); title= " sampler" , style= " yellow3" , fit= true , width= width - 8 ) /
113
+ Panel (convert (Term. Tree, t. controler); title= " controler" , style= " yellow3" , fit= true , width= width - 8 );
114
+ title= " Trajectory" ,
115
+ style= " yellow3" ,
116
+ width= width,
117
+ fit= true
118
+ )
119
+ end
120
+
121
+ # general converter
122
+
123
+ Base. convert (:: Type{Term.Tree} , x) = Tree (to_tree_body (x); title= to_tree_title (x))
124
+ Base. convert (:: Type{Term.Tree} , x:: Tree ) = x
125
+
126
+ function to_tree_body (x)
127
+ pts = propertynames (x)
128
+ if length (pts) > 0
129
+ Dict (" $p => $(summary (getproperty (x, p))) " => to_tree_body (getproperty (x, p)) for p in pts)
130
+ else
131
+ x
132
+ end
133
+ end
134
+
135
+ to_tree_title (x) = " $(summary (x)) "
0 commit comments