From 94ab5849fa165b39d110beb6b7b0d2bb592deacd Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Sun, 7 Feb 2010 14:23:29 +0200 Subject: [PATCH] Modify display of 'n' in HUD for large numbers When sample size grows to larger than 1000, use "X.Yk" notation to show the approximate value. --- pyfpdb/Stats.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py index 18913eed..ab92c99f 100755 --- a/pyfpdb/Stats.py +++ b/pyfpdb/Stats.py @@ -245,8 +245,20 @@ def saw_f(stat_dict, player): def n(stat_dict, player): """ Number of hands played.""" try: + # If sample is large enough, use X.Yk notation instead + _n = stat_dict[player]['n'] + fmt = '%d' % _n + if _n >= 1000: + k = _n / 1000 + c = _n % 1000 + _c = float(c) / 100.0 + d = int(round(_c)) + if d == 10: + k += 1 + d = 0 + fmt = '%d.%dk' % (k, d) return (stat_dict[player]['n'], - '%d' % (stat_dict[player]['n']), + '%s' % fmt, 'n=%d' % (stat_dict[player]['n']), 'n=%d' % (stat_dict[player]['n']), '(%d)' % (stat_dict[player]['n']),