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
This commit is contained in:
Mika Bostrom 2010-08-22 13:57:01 +03:00 committed by Gerko de Roo
parent 8265d9fc6e
commit a75ba5a288

View File

@ -139,10 +139,10 @@ def vpip(stat_dict, player):
_('Voluntarily Put In Pot Pre-Flop%') _('Voluntarily Put In Pot Pre-Flop%')
) )
except: return (stat, except: return (stat,
'%3.1f' % (0), 'NA',
'v=%3.1f%%' % (0), 'v=NA',
'vpip=%3.1f%%' % (0), 'vpip=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Voluntarily Put In Pot Pre-Flop%') _('Voluntarily Put In Pot Pre-Flop%')
) )
@ -160,10 +160,10 @@ def pfr(stat_dict, player):
) )
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'p=%3.1f%%' % (0), 'p=NA',
'pfr=%3.1f%%' % (0), 'pfr=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Pre-Flop Raise %') _('Pre-Flop Raise %')
) )
@ -181,10 +181,10 @@ def wtsd(stat_dict, player):
) )
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'w=%3.1f%%' % (0), 'w=NA',
'wtsd=%3.1f%%' % (0), 'wtsd=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% went to showdown') _('% went to showdown')
) )
@ -202,10 +202,10 @@ def wmsd(stat_dict, player):
) )
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'w=%3.1f%%' % (0), 'w=NA',
'wmsd=%3.1f%%' % (0), 'wmsd=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% won money at showdown') _('% won money at showdown')
) )
@ -224,10 +224,10 @@ def profit100(stat_dict, player):
except: except:
print _("exception calcing p/100: 100 * %d / %d") % (stat_dict[player]['net'], stat_dict[player]['n']) print _("exception calcing p/100: 100 * %d / %d") % (stat_dict[player]['net'], stat_dict[player]['n'])
return (stat, return (stat,
'%.0f' % (0.0), 'NA',
'p=%.0f' % (0.0), 'p=NA',
'p/100=%.0f' % (0.0), 'p/100=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('profit/100hands') _('profit/100hands')
) )
@ -246,10 +246,10 @@ def bbper100(stat_dict, player):
except: except:
log.info("exception calcing bb/100: "+str(stat_dict[player])) log.info("exception calcing bb/100: "+str(stat_dict[player]))
return (stat, return (stat,
'%.0f' % (0), 'NA',
'bb100=%.0f' % (0), 'bb100=NA',
'bb100=%.0f' % (0), 'bb100=NA',
'(%f)' % (0), '(--)',
_('big blinds/100 hands') _('big blinds/100 hands')
) )
@ -268,10 +268,10 @@ def BBper100(stat_dict, player):
except: except:
log.info(_("exception calcing BB/100: ")+str(stat_dict[player])) log.info(_("exception calcing BB/100: ")+str(stat_dict[player]))
return (stat, return (stat,
'%.0f' % (0.0), 'NA',
'BB100=%.0f' % (0.0), 'BB100=NA',
'BB100=%.0f' % (0.0), 'BB100=NA',
'(%f)' % (0.0), '(--)',
_('Big Bets/100 hands') _('Big Bets/100 hands')
) )
@ -290,13 +290,11 @@ def saw_f(stat_dict, player):
) )
except: except:
stat = 0.0 stat = 0.0
num = 0
den = 0
return (stat, return (stat,
'%3.1f' % (stat), 'NA',
'sf=%3.1f%%' % (stat), 'sf=NA',
'saw_f=%3.1f%%' % (stat), 'saw_f=NA',
'(%d/%d)' % (num, den), '(0/0)',
_('Flop Seen %') _('Flop Seen %')
) )
@ -323,6 +321,7 @@ def n(stat_dict, player):
_('number hands seen') _('number hands seen')
) )
except: except:
# Number of hands shouldn't ever be "NA"; zeroes are better here
return (0, return (0,
'%d' % (0), '%d' % (0),
'n=%d' % (0), 'n=%d' % (0),
@ -345,10 +344,10 @@ def fold_f(stat_dict, player):
) )
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'ff=%3.1f%%' % (0), 'ff=NA',
'fold_f=%3.1f%%' % (0), 'fold_f=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('folded flop/4th') _('folded flop/4th')
) )
@ -440,10 +439,10 @@ def three_B(stat_dict, player):
_('% 3/4 Bet preflop/3rd')) _('% 3/4 Bet preflop/3rd'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'3B=%3.1f%%' % (0), '3B=NA',
'3B_pf=%3.1f%%' % (0), '3B_pf=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% 3/4 Bet preflop/3rd')) _('% 3/4 Bet preflop/3rd'))
def WMsF(stat_dict, player): def WMsF(stat_dict, player):
@ -459,10 +458,10 @@ def WMsF(stat_dict, player):
_('% won$/saw flop/4th')) _('% won$/saw flop/4th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'wf=%3.1f%%' % (0), 'wf=NA',
'w_w_f=%3.1f%%' % (0), 'w_w_f=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% won$/saw flop/4th')) _('% won$/saw flop/4th'))
def a_freq1(stat_dict, player): def a_freq1(stat_dict, player):
@ -478,10 +477,10 @@ def a_freq1(stat_dict, player):
_('Aggression Freq flop/4th')) _('Aggression Freq flop/4th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'a1=%3.1f%%' % (0), 'a1=NA',
'a_fq_1=%3.1f%%' % (0), 'a_fq_1=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Aggression Freq flop/4th')) _('Aggression Freq flop/4th'))
def a_freq2(stat_dict, player): def a_freq2(stat_dict, player):
@ -497,10 +496,10 @@ def a_freq2(stat_dict, player):
_('Aggression Freq turn/5th')) _('Aggression Freq turn/5th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'a2=%3.1f%%' % (0), 'a2=NA',
'a_fq_2=%3.1f%%' % (0), 'a_fq_2=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Aggression Freq turn/5th')) _('Aggression Freq turn/5th'))
def a_freq3(stat_dict, player): def a_freq3(stat_dict, player):
@ -516,10 +515,10 @@ def a_freq3(stat_dict, player):
_('Aggression Freq river/6th')) _('Aggression Freq river/6th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'a3=%3.1f%%' % (0), 'a3=NA',
'a_fq_3=%3.1f%%' % (0), 'a_fq_3=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Aggression Freq river/6th')) _('Aggression Freq river/6th'))
def a_freq4(stat_dict, player): def a_freq4(stat_dict, player):
@ -535,10 +534,10 @@ def a_freq4(stat_dict, player):
_('Aggression Freq 7th')) _('Aggression Freq 7th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'a4=%3.1f%%' % (0), 'a4=NA',
'a_fq_4=%3.1f%%' % (0), 'a_fq_4=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Aggression Freq 7th')) _('Aggression Freq 7th'))
def a_freq_123(stat_dict, player): def a_freq_123(stat_dict, player):
@ -561,10 +560,10 @@ def a_freq_123(stat_dict, player):
_('Post-Flop Aggression Freq')) _('Post-Flop Aggression Freq'))
except: except:
return (stat, return (stat,
'%2.0f' % (0), 'NA',
'a3=%2.0f%%' % (0), 'a3=NA',
'a_fq_3=%2.0f%%' % (0), 'a_fq_3=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Post-Flop Aggression Freq')) _('Post-Flop Aggression Freq'))
def agg_freq(stat_dict, player): def agg_freq(stat_dict, player):
@ -589,10 +588,10 @@ def agg_freq(stat_dict, player):
_('Aggression Freq')) _('Aggression Freq'))
except: except:
return (stat, return (stat,
'%2.1f' % (0), 'NA',
'af=%3.1f%%' % (0), 'af=NA',
'agg_f=%3.1f%%' % (0), 'agg_f=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Aggression Freq')) _('Aggression Freq'))
def agg_fact(stat_dict, player): def agg_fact(stat_dict, player):
@ -615,10 +614,10 @@ def agg_fact(stat_dict, player):
_('Aggression Factor')) _('Aggression Factor'))
except: except:
return (stat, return (stat,
'%2.2f' % (0) , 'NA',
'afa=%2.2f' % (0) , 'afa=NA',
'agg_fa=%2.2f' % (0), 'agg_fa=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('Aggression Factor')) _('Aggression Factor'))
def cbet(stat_dict, player): def cbet(stat_dict, player):
@ -639,10 +638,10 @@ def cbet(stat_dict, player):
_('% continuation bet ')) _('% continuation bet '))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'cbet=%3.1f%%' % (0), 'cbet=NA',
'cbet=%3.1f%%' % (0), 'cbet=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% continuation bet ')) _('% continuation bet '))
def cb1(stat_dict, player): def cb1(stat_dict, player):
@ -658,10 +657,10 @@ def cb1(stat_dict, player):
_('% continuation bet flop/4th')) _('% continuation bet flop/4th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'cb1=%3.1f%%' % (0), 'cb1=NA',
'cb_1=%3.1f%%' % (0), 'cb_1=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% continuation bet flop/4th')) _('% continuation bet flop/4th'))
def cb2(stat_dict, player): def cb2(stat_dict, player):
@ -677,10 +676,10 @@ def cb2(stat_dict, player):
_('% continuation bet turn/5th')) _('% continuation bet turn/5th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'cb2=%3.1f%%' % (0), 'cb2=NA',
'cb_2=%3.1f%%' % (0), 'cb_2=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% continuation bet turn/5th')) _('% continuation bet turn/5th'))
def cb3(stat_dict, player): def cb3(stat_dict, player):
@ -696,10 +695,10 @@ def cb3(stat_dict, player):
_('% continuation bet river/6th')) _('% continuation bet river/6th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'cb3=%3.1f%%' % (0), 'cb3=NA',
'cb_3=%3.1f%%' % (0), 'cb_3=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% continuation bet river/6th')) _('% continuation bet river/6th'))
def cb4(stat_dict, player): def cb4(stat_dict, player):
@ -715,10 +714,10 @@ def cb4(stat_dict, player):
_('% continuation bet 7th')) _('% continuation bet 7th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'cb4=%3.1f%%' % (0), 'cb4=NA',
'cb_4=%3.1f%%' % (0), 'cb_4=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% continuation bet 7th')) _('% continuation bet 7th'))
def ffreq1(stat_dict, player): def ffreq1(stat_dict, player):
@ -753,10 +752,10 @@ def ffreq2(stat_dict, player):
_('% fold frequency turn/5th')) _('% fold frequency turn/5th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'ff2=%3.1f%%' % (0), 'ff2=NA',
'ff_2=%3.1f%%' % (0), 'ff_2=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% fold frequency turn/5th')) _('% fold frequency turn/5th'))
def ffreq3(stat_dict, player): def ffreq3(stat_dict, player):
@ -772,10 +771,10 @@ def ffreq3(stat_dict, player):
_('% fold frequency river/6th')) _('% fold frequency river/6th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'ff3=%3.1f%%' % (0), 'ff3=NA',
'ff_3=%3.1f%%' % (0), 'ff_3=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% fold frequency river/6th')) _('% fold frequency river/6th'))
def ffreq4(stat_dict, player): def ffreq4(stat_dict, player):
@ -791,10 +790,10 @@ def ffreq4(stat_dict, player):
_('% fold frequency 7th')) _('% fold frequency 7th'))
except: except:
return (stat, return (stat,
'%3.1f' % (0), 'NA',
'ff4=%3.1f%%' % (0), 'ff4=NA',
'ff_4=%3.1f%%' % (0), 'ff_4=NA',
'(%d/%d)' % (0, 0), '(0/0)',
_('% fold frequency 7th')) _('% fold frequency 7th'))
if __name__== "__main__": if __name__== "__main__":