def parse_list_str(ar, compres):
"""
-1: unable to reduce in size
1: broadcastable array
todo:
for multiline array strings add extra space in line 2, 3..
use array2string-prefix for this
"""
# max_line_width = 80 # might set this to something different later
# precision = 8
# suppress_small = True # to mask some rounding issues
if compres == -1:
pre = '['
post = ']'
ar_str = ', '.join([item.string for item in ar])
string = pre + ar_str + post
elif compres == 1:
# l = np.unique(ar).size
if len(ar) == 1:
string = ar[0].string
else:
pre = str(len(ar)) + ' * ['
post = ']'
ar_str = ar[0].string
string = pre + ar_str + post
return string
评论列表
文章目录