@@ -81,23 +81,20 @@ def prod(values):
81
81
return reduce (operator .mul , values , 1 )
82
82
83
83
84
- def format_value (value , missing , fullinfo = False , precision = None ):
85
- if isinstance (value , float ) and not fullinfo :
84
+ def format_value (value , missing , precision = None ):
85
+ if isinstance (value , float ):
86
86
# nans print as "-1.#J", let's use something nicer
87
87
if value != value :
88
88
return missing
89
89
elif precision is not None :
90
- return '{:2 .{precision}f}' .format (value , precision = precision ).rstrip ('0' ).rstrip ('.' )
90
+ return '{:.{precision}f}' .format (value , precision = precision ).rstrip ('0' ).rstrip ('.' )
91
91
else :
92
- return '%2.f' % value
92
+ return str ( value )
93
93
elif isinstance (value , np .ndarray ) and value .shape :
94
94
# prevent numpy's default wrapping
95
95
return str (list (value )).replace (',' , '' )
96
96
else :
97
- if isinstance (value , float ) and precision is not None :
98
- return '{:2.{precision}f}' .format (value , precision = precision ).rstrip ('0' ).rstrip ('.' )
99
- else :
100
- return str (value )
97
+ return str (value )
101
98
102
99
103
100
def get_col_width (table , index ):
@@ -136,8 +133,7 @@ def get_min_width(table, index):
136
133
return max (longest_word (row [index ]) for row in table )
137
134
138
135
139
- # XXX: what fullinfo is used for and when ?
140
- def table2str (table , missing , fullinfo = False , summarize = True , maxwidth = 80 , numedges = 'auto' , sep = ' ' , cont = '...' ,
136
+ def table2str (table , missing , summarize = True , maxwidth = 80 , numedges = 'auto' , sep = ' ' , cont = '...' ,
141
137
keepcols = 0 , precision = None ):
142
138
"""
143
139
table is a list of lists
@@ -150,7 +146,7 @@ def table2str(table, missing, fullinfo=False, summarize=True, maxwidth=80, numed
150
146
for row in table :
151
147
if len (row ) < numcol :
152
148
row .extend (['' ] * (numcol - len (row )))
153
- formatted = [[format_value (value , missing , fullinfo , precision ) for value in row ]
149
+ formatted = [[format_value (value , missing , precision ) for value in row ]
154
150
for row in table ]
155
151
maxwidths = [get_col_width (formatted , i ) for i in range (numcol )]
156
152
0 commit comments