@@ -23,6 +23,16 @@ function Base.show(io::IO, ::MIME"text/plain", @nospecialize(nw::Network))
23
23
print (io, nw. layer. aggregator)
24
24
# print(io, "\n ├─ vertex output dimension: $(nw.im.vdepth)")
25
25
# print(io, "\n └─ edge output dimension: $(nw.im.edepth)")
26
+
27
+ Ncb = length (collect_callbackbatches (nw))
28
+ if Ncb ≥ 1
29
+ nvert = mapreduce (has_callback, + , nw. im. vertexm)
30
+ nedge = mapreduce (has_callback, + , nw. im. edgem)
31
+ _, setword = maybe_plural (Ncb, " callback set" )
32
+ _, vertword = maybe_plural (nvert, " vertex" , " vertices" )
33
+ _, edgeword = maybe_plural (nedge, " edge" )
34
+ print (io, " \n $Ncb $setword across $nvert $vertword and $nedge $edgeword " )
35
+ end
26
36
end
27
37
end
28
38
@@ -78,6 +88,17 @@ function print_states_params(io, @nospecialize(c::ComponentModel), styling)
78
88
push! (info, styled " $num &ext in: &&$arr" )
79
89
end
80
90
91
+ if has_callback (c)
92
+ cbs = get_callbacks (c)
93
+ num, word = maybe_plural (length (cbs), " callback" )
94
+ str = " "
95
+ str *= styled " $num &$word: &&$(shortrepr(first(cbs)))"
96
+ for cb in Base. tail (cbs)
97
+ str *= styled "\n &&&$(shortrepr(cb))"
98
+ end
99
+ push! (info, str)
100
+ end
101
+
81
102
print_treelike (io, align_strings (info))
82
103
end
83
104
function _inout_string (@nospecialize (c:: VertexModel ), f, name)
@@ -329,3 +350,46 @@ function str_significant(x; sigdigits, phantom_minus=false)
329
350
end
330
351
formatted
331
352
end
353
+
354
+ function Base. show (io:: IO , :: MIME"text/plain" , @nospecialize (cb:: ComponentCallback ))
355
+ basename = readuntil (IOBuffer (repr (cb)), ' {' )
356
+ print (io, basename)
357
+ print (io, " (" )
358
+ _print_condsyms (io, cb)
359
+ print (io, " affecting " )
360
+ _print_affectsyms (io, cb)
361
+ if cb isa VectorContinousComponentCallback
362
+ print (io, " , len=" , cb. len)
363
+ end
364
+ print (io, " )" )
365
+ end
366
+
367
+ function shortrepr (cb:: ComponentCallback )
368
+ io = IOBuffer ()
369
+ _print_condsyms (io, cb)
370
+ print (io, " affecting " )
371
+ _print_affectsyms (io, cb)
372
+ String (take! (io))
373
+ end
374
+
375
+ function _print_condsyms (io, @nospecialize (cb:: ComponentCallback ))
376
+ print (io, " (" )
377
+ _print_syms (io, cb. condition. sym, true )
378
+ _print_syms (io, cb. condition. psym, isempty (cb. condition. sym))
379
+ print (io, " )" )
380
+ end
381
+ function _print_affectsyms (io, @nospecialize (cb:: ComponentCallback ))
382
+ print (io, " (" )
383
+ _print_syms (io, cb. affect. sym, true )
384
+ _print_syms (io, cb. affect. psym, isempty (cb. affect. sym))
385
+ print (io, " )" )
386
+ end
387
+ function _print_syms (io, syms:: Tuple , isfirst)
388
+ for s in syms
389
+ if ! isfirst
390
+ print (io, " , " )
391
+ end
392
+ print (io, ' :' , s)
393
+ isfirst = false
394
+ end
395
+ end
0 commit comments