@@ -137,14 +137,26 @@ def __rich_console__(
137137 table .add_row (col_1 , text .Text (col_2 ))
138138 elif isinstance (value , AbstractTensor ):
139139 table .add_row (col_1 , TensorDisplay (tensor = value ))
140- elif isinstance (value , (tuple , list )):
140+ elif isinstance (value , (tuple , list , set )):
141+ value_list = list (value )
141142 col_2 = ''
142- for i , x in enumerate (value ):
143+ for i , x in enumerate (value_list ):
143144 if len (col_2 ) + len (str (x )) < 50 :
144- col_2 = str (value [: i ])
145+ col_2 = str (value_list [: i + 1 ])
145146 else :
146- col_2 = f'{ col_2 [:- 1 ]} , ...] (length: { len (value )} )'
147+ col_2 = f'{ col_2 [:- 1 ]} , ...] (length: { len (value_list )} )'
147148 break
149+
150+ if type (value ) == tuple :
151+ col_2 = col_2 .replace ('[' , '(' , 1 ).replace (']' , ')' , - 1 )
152+ if type (value ) == set :
153+ col_2 = col_2 .replace ('[' , '{' , 1 ).replace (']' , '}' , - 1 )
154+
155+ table .add_row (col_1 , text .Text (col_2 ))
156+ elif isinstance (value , dict ):
157+ col_2 = f'{ value } '
158+ if len (col_2 ) > 50 :
159+ col_2 = f'{ col_2 [: 50 ]} ' + ' ... } ' + f'(length: { len (value )} )'
148160 table .add_row (col_1 , text .Text (col_2 ))
149161
150162 if table .rows :
0 commit comments