Skip to content

Commit b3bcef8

Browse files
committed
removed unnecessary fullinfo argument from table2str() and format_value()
1 parent 1d25477 commit b3bcef8

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

larray/core/array.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,8 +2282,7 @@ def __str__(self):
22822282
maxwidth = OPTIONS[DISPLAY_WIDTH]
22832283
precision = OPTIONS[DISPLAY_PRECISION]
22842284
table = list(self.as_table(maxlines))
2285-
return table2str(table, 'nan', fullinfo=True, maxwidth=maxwidth, keepcols=self.ndim - 1,
2286-
precision=precision)
2285+
return table2str(table, 'nan', maxwidth=maxwidth, keepcols=self.ndim - 1, precision=precision)
22872286
__repr__ = __str__
22882287

22892288
def __iter__(self):

larray/util/misc.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,20 @@ def prod(values):
8181
return reduce(operator.mul, values, 1)
8282

8383

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):
8686
# nans print as "-1.#J", let's use something nicer
8787
if value != value:
8888
return missing
8989
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('.')
9191
else:
92-
return '%2.f' % value
92+
return str(value)
9393
elif isinstance(value, np.ndarray) and value.shape:
9494
# prevent numpy's default wrapping
9595
return str(list(value)).replace(',', '')
9696
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)
10198

10299

103100
def get_col_width(table, index):
@@ -136,8 +133,7 @@ def get_min_width(table, index):
136133
return max(longest_word(row[index]) for row in table)
137134

138135

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='...',
141137
keepcols=0, precision=None):
142138
"""
143139
table is a list of lists
@@ -150,7 +146,7 @@ def table2str(table, missing, fullinfo=False, summarize=True, maxwidth=80, numed
150146
for row in table:
151147
if len(row) < numcol:
152148
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]
154150
for row in table]
155151
maxwidths = [get_col_width(formatted, i) for i in range(numcol)]
156152

0 commit comments

Comments
 (0)