@@ -250,6 +250,44 @@ def __str__(self):
250250 str += f"States ({ self .nstates } ): { self .state_labels } "
251251 return str
252252
253+ def _label_repr (self , show_count = True ):
254+ out , count = "" , 0
255+
256+ # Include the system name if not generic
257+ if not self ._generic_name_check ():
258+ name_spec = f"name='{ self .name } '"
259+ count += len (name_spec )
260+ out += name_spec
261+
262+ # Include the state, output, and input names if not generic
263+ for sig_name , sig_default , sig_labels in zip (
264+ ['states' , 'outputs' , 'inputs' ],
265+ ['x' , 'y' , 'u' ], # TODO: replace with defaults
266+ [self .state_labels , self .output_labels , self .input_labels ]):
267+ if sig_name == 'states' and self .nstates is None :
268+ continue
269+
270+ # Check if the signal labels are generic
271+ if any ([re .match (r'^' + sig_default + r'\[\d*\]$' , label ) is None
272+ for label in sig_labels ]):
273+ spec = f"{ sig_name } ={ sig_labels } "
274+ elif show_count :
275+ spec = f"{ sig_name } ={ len (sig_labels )} "
276+
277+ # Append the specification string to the output, with wrapping
278+ if count == 0 :
279+ count = len (spec ) # no system name => suppress comma
280+ elif count + len (spec ) > 72 :
281+ # TODO: check to make sure a single line is enough (minor)
282+ out += ",\n "
283+ count = len (spec )
284+ else :
285+ out += ", "
286+ count += len (spec ) + 2
287+ out += spec
288+
289+ return out
290+
253291 # Find a list of signals by name, index, or pattern
254292 def _find_signals (self , name_list , sigdict ):
255293 if not isinstance (name_list , (list , tuple )):
0 commit comments