Skip to content

Commit

Permalink
don't print very long stats entries by default
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed Apr 19, 2018
1 parent 3c5c09a commit 4ebb0e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fpylll/tools/bkz_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
from fpylll.tools.quality import basis_quality


def pretty_dict(d, keyword_width=None, round_bound=9999):
def pretty_dict(d, keyword_width=None, round_bound=9999, suppress_length=128):
"""Return 'pretty' string representation of the dictionary ``d``.
:param d: a dictionary
:param keyword_width: width allocated for keywords
:param round_bound: values beyond this bound are shown as `2^x`
:param suppress_length: don't print arbitrary data with ``len(str(data)) > suppress_length``
>>> from collections import OrderedDict
>>> str(pretty_dict(OrderedDict([('d', 2), ('f', 0.1), ('large', 4097)])))
Expand Down Expand Up @@ -48,7 +49,10 @@ def pretty_dict(d, keyword_width=None, round_bound=9999):
try:
v = float(v)
except TypeError:
s.append(u"%s: %s"%(k, v))
`` if len(str(v)) <= suppress_length:
s.append(u"%s: %s"%(k, v))
else:
s.append(u"%s: '...'"%(k,))
continue

if 0 <= v < 10.0:
Expand Down

0 comments on commit 4ebb0e3

Please sign in to comment.