From 4a92638941eb105ab80ca3c1a1ecc41f5d18bf14 Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Sun, 22 Aug 2010 13:57:01 +0300 Subject: [PATCH] Return "hard" NA for missing/incalculable stats It makes very little sense to do a format string for nothing but zeroes in case of unknown values. Simply return a set of 'NA' strings in place of usual stats. This makes the error cases consistent throughout Stats.py --- pyfpdb/Stats.py | 211 ++++++++++++++++++++++++------------------------ 1 file changed, 105 insertions(+), 106 deletions(-) diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py index 22900da8..cfe82f0a 100755 --- a/pyfpdb/Stats.py +++ b/pyfpdb/Stats.py @@ -139,10 +139,10 @@ def vpip(stat_dict, player): _('Voluntarily Put In Pot Pre-Flop%') ) except: return (stat, - '%3.1f' % (0), - 'v=%3.1f%%' % (0), - 'vpip=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'v=NA', + 'vpip=NA', + '(0/0)', _('Voluntarily Put In Pot Pre-Flop%') ) @@ -160,10 +160,10 @@ def pfr(stat_dict, player): ) except: return (stat, - '%3.1f' % (0), - 'p=%3.1f%%' % (0), - 'pfr=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'p=NA', + 'pfr=NA', + '(0/0)', _('Pre-Flop Raise %') ) @@ -181,10 +181,10 @@ def wtsd(stat_dict, player): ) except: return (stat, - '%3.1f' % (0), - 'w=%3.1f%%' % (0), - 'wtsd=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'w=NA', + 'wtsd=NA', + '(0/0)', _('% went to showdown') ) @@ -202,10 +202,10 @@ def wmsd(stat_dict, player): ) except: return (stat, - '%3.1f' % (0), - 'w=%3.1f%%' % (0), - 'wmsd=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'w=NA', + 'wmsd=NA', + '(0/0)', _('% won money at showdown') ) @@ -224,10 +224,10 @@ def profit100(stat_dict, player): except: print _("exception calcing p/100: 100 * %d / %d") % (stat_dict[player]['net'], stat_dict[player]['n']) return (stat, - '%.0f' % (0.0), - 'p=%.0f' % (0.0), - 'p/100=%.0f' % (0.0), - '(%d/%d)' % (0, 0), + 'NA', + 'p=NA', + 'p/100=NA', + '(0/0)', _('profit/100hands') ) @@ -246,10 +246,10 @@ def bbper100(stat_dict, player): except: log.info("exception calcing bb/100: "+str(stat_dict[player])) return (stat, - '%.0f' % (0), - 'bb100=%.0f' % (0), - 'bb100=%.0f' % (0), - '(%f)' % (0), + 'NA', + 'bb100=NA', + 'bb100=NA', + '(--)', _('big blinds/100 hands') ) @@ -268,10 +268,10 @@ def BBper100(stat_dict, player): except: log.info(_("exception calcing BB/100: ")+str(stat_dict[player])) return (stat, - '%.0f' % (0.0), - 'BB100=%.0f' % (0.0), - 'BB100=%.0f' % (0.0), - '(%f)' % (0.0), + 'NA', + 'BB100=NA', + 'BB100=NA', + '(--)', _('Big Bets/100 hands') ) @@ -290,13 +290,11 @@ def saw_f(stat_dict, player): ) except: stat = 0.0 - num = 0 - den = 0 return (stat, - '%3.1f' % (stat), - 'sf=%3.1f%%' % (stat), - 'saw_f=%3.1f%%' % (stat), - '(%d/%d)' % (num, den), + 'NA', + 'sf=NA', + 'saw_f=NA', + '(0/0)', _('Flop Seen %') ) @@ -323,6 +321,7 @@ def n(stat_dict, player): _('number hands seen') ) except: + # Number of hands shouldn't ever be "NA"; zeroes are better here return (0, '%d' % (0), 'n=%d' % (0), @@ -345,10 +344,10 @@ def fold_f(stat_dict, player): ) except: return (stat, - '%3.1f' % (0), - 'ff=%3.1f%%' % (0), - 'fold_f=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'ff=NA', + 'fold_f=NA', + '(0/0)', _('folded flop/4th') ) @@ -440,10 +439,10 @@ def three_B(stat_dict, player): _('% 3/4 Bet preflop/3rd')) except: return (stat, - '%3.1f' % (0), - '3B=%3.1f%%' % (0), - '3B_pf=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + '3B=NA', + '3B_pf=NA', + '(0/0)', _('% 3/4 Bet preflop/3rd')) def WMsF(stat_dict, player): @@ -459,10 +458,10 @@ def WMsF(stat_dict, player): _('% won$/saw flop/4th')) except: return (stat, - '%3.1f' % (0), - 'wf=%3.1f%%' % (0), - 'w_w_f=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'wf=NA', + 'w_w_f=NA', + '(0/0)', _('% won$/saw flop/4th')) def a_freq1(stat_dict, player): @@ -478,10 +477,10 @@ def a_freq1(stat_dict, player): _('Aggression Freq flop/4th')) except: return (stat, - '%3.1f' % (0), - 'a1=%3.1f%%' % (0), - 'a_fq_1=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'a1=NA', + 'a_fq_1=NA', + '(0/0)', _('Aggression Freq flop/4th')) def a_freq2(stat_dict, player): @@ -497,10 +496,10 @@ def a_freq2(stat_dict, player): _('Aggression Freq turn/5th')) except: return (stat, - '%3.1f' % (0), - 'a2=%3.1f%%' % (0), - 'a_fq_2=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'a2=NA', + 'a_fq_2=NA', + '(0/0)', _('Aggression Freq turn/5th')) def a_freq3(stat_dict, player): @@ -516,10 +515,10 @@ def a_freq3(stat_dict, player): _('Aggression Freq river/6th')) except: return (stat, - '%3.1f' % (0), - 'a3=%3.1f%%' % (0), - 'a_fq_3=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'a3=NA', + 'a_fq_3=NA', + '(0/0)', _('Aggression Freq river/6th')) def a_freq4(stat_dict, player): @@ -535,10 +534,10 @@ def a_freq4(stat_dict, player): _('Aggression Freq 7th')) except: return (stat, - '%3.1f' % (0), - 'a4=%3.1f%%' % (0), - 'a_fq_4=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'a4=NA', + 'a_fq_4=NA', + '(0/0)', _('Aggression Freq 7th')) def a_freq_123(stat_dict, player): @@ -561,10 +560,10 @@ def a_freq_123(stat_dict, player): _('Post-Flop Aggression Freq')) except: return (stat, - '%2.0f' % (0), - 'a3=%2.0f%%' % (0), - 'a_fq_3=%2.0f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'a3=NA', + 'a_fq_3=NA', + '(0/0)', _('Post-Flop Aggression Freq')) def agg_freq(stat_dict, player): @@ -589,10 +588,10 @@ def agg_freq(stat_dict, player): _('Aggression Freq')) except: return (stat, - '%2.1f' % (0), - 'af=%3.1f%%' % (0), - 'agg_f=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'af=NA', + 'agg_f=NA', + '(0/0)', _('Aggression Freq')) def agg_fact(stat_dict, player): @@ -615,10 +614,10 @@ def agg_fact(stat_dict, player): _('Aggression Factor')) except: return (stat, - '%2.2f' % (0) , - 'afa=%2.2f' % (0) , - 'agg_fa=%2.2f' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'afa=NA', + 'agg_fa=NA', + '(0/0)', _('Aggression Factor')) def cbet(stat_dict, player): @@ -639,10 +638,10 @@ def cbet(stat_dict, player): _('% continuation bet ')) except: return (stat, - '%3.1f' % (0), - 'cbet=%3.1f%%' % (0), - 'cbet=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'cbet=NA', + 'cbet=NA', + '(0/0)', _('% continuation bet ')) def cb1(stat_dict, player): @@ -658,10 +657,10 @@ def cb1(stat_dict, player): _('% continuation bet flop/4th')) except: return (stat, - '%3.1f' % (0), - 'cb1=%3.1f%%' % (0), - 'cb_1=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'cb1=NA', + 'cb_1=NA', + '(0/0)', _('% continuation bet flop/4th')) def cb2(stat_dict, player): @@ -677,10 +676,10 @@ def cb2(stat_dict, player): _('% continuation bet turn/5th')) except: return (stat, - '%3.1f' % (0), - 'cb2=%3.1f%%' % (0), - 'cb_2=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'cb2=NA', + 'cb_2=NA', + '(0/0)', _('% continuation bet turn/5th')) def cb3(stat_dict, player): @@ -696,10 +695,10 @@ def cb3(stat_dict, player): _('% continuation bet river/6th')) except: return (stat, - '%3.1f' % (0), - 'cb3=%3.1f%%' % (0), - 'cb_3=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'cb3=NA', + 'cb_3=NA', + '(0/0)', _('% continuation bet river/6th')) def cb4(stat_dict, player): @@ -715,10 +714,10 @@ def cb4(stat_dict, player): _('% continuation bet 7th')) except: return (stat, - '%3.1f' % (0), - 'cb4=%3.1f%%' % (0), - 'cb_4=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'cb4=NA', + 'cb_4=NA', + '(0/0)', _('% continuation bet 7th')) def ffreq1(stat_dict, player): @@ -753,10 +752,10 @@ def ffreq2(stat_dict, player): _('% fold frequency turn/5th')) except: return (stat, - '%3.1f' % (0), - 'ff2=%3.1f%%' % (0), - 'ff_2=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'ff2=NA', + 'ff_2=NA', + '(0/0)', _('% fold frequency turn/5th')) def ffreq3(stat_dict, player): @@ -772,10 +771,10 @@ def ffreq3(stat_dict, player): _('% fold frequency river/6th')) except: return (stat, - '%3.1f' % (0), - 'ff3=%3.1f%%' % (0), - 'ff_3=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'ff3=NA', + 'ff_3=NA', + '(0/0)', _('% fold frequency river/6th')) def ffreq4(stat_dict, player): @@ -791,10 +790,10 @@ def ffreq4(stat_dict, player): _('% fold frequency 7th')) except: return (stat, - '%3.1f' % (0), - 'ff4=%3.1f%%' % (0), - 'ff_4=%3.1f%%' % (0), - '(%d/%d)' % (0, 0), + 'NA', + 'ff4=NA', + 'ff_4=NA', + '(0/0)', _('% fold frequency 7th')) if __name__== "__main__":