File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 18
18
_color = True
19
19
#print('using colored output')
20
20
except ImportError :
21
+ #print('colored not found')
21
22
_color = False
22
- def fg (): return ''
23
- def bg (): return ''
24
- def attr (): return ''
23
+
25
24
26
25
# try:
27
26
# import colorama
@@ -498,10 +497,18 @@ def __repr__(self):
498
497
# return str.rstrip("\n") # Remove trailing newline character
499
498
# else:
500
499
# raise ValueError('no elements in the value list')
501
- return self .__str__ ( )
500
+ return self ._st
8000
ring ( color = _color )
502
501
503
502
def __str__ (self ):
503
+ return self ._string (color = False )
504
+
505
+ def _string (self , color = False ):
504
506
#print('in __str__')
507
+
508
+ FG = lambda c : fg (c ) if color else ''
509
+ BG = lambda c : bg (c ) if color else ''
510
+ ATTR = lambda c : attr (c ) if color else ''
511
+
505
512
def mformat (self , X ):
506
513
# X is an ndarray value to be display
507
514
# self provides set type for formatting
@@ -518,15 +525,15 @@ def mformat(self, X):
518
525
if rownum < n :
519
526
if colnum < n :
520
527
# rotation part
521
- s = fg ('red' ) + bg ('grey_93' ) + s + attr (0 )
528
+ s = FG ('red' ) + BG ('grey_93' ) + s + ATTR (0 )
522
529
else :
523
530
# translation part
524
- s = fg ('blue' ) + bg ('grey_93' ) + s + attr (0 )
531
+ s = FG ('blue' ) + BG ('grey_93' ) + s + ATTR (0 )
525
532
else :
526
533
# bottom row
527
- s = fg ('grey_50' ) + bg ('grey_93' ) + s + attr (0 )
534
+ s = FG ('grey_50' ) + BG ('grey_93' ) + s + ATTR (0 )
528
535
rowstr += s
529
- out += rowstr + bg ('grey_93' ) + ' ' + attr (0 ) + '\n '
536
+ out += rowstr + BG ('grey_93' ) + ' ' + ATTR (0 ) + '\n '
530
537
return out
531
538
532
539
output_str = ''
You can’t perform that action at this time.
0 commit comments