rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
expected_win_rate = 0.5
|
expected_win_rate = 1.0
|
def do_some_calc(self): left_count = -1
|
lines.append("%s%d:\t%s" % (header, score, bar(score_map[score] / float(self.count))))
|
lines.append("%s%3d:\t%s" % (header, score, bar(score_map[score] / float(self.count))))
|
def bar(percentage): length = 25 bar_length = length * percentage
|
print "Total Game:" total_game.dump(" ")
|
def dump(self, header): game_count = float(self.count)
|
|
if total_game.count > 0:
|
if header: print "Total Game:" total_game.dump(header)
|
def dump(self, header): game_count = float(self.count)
|
valid_game.dump(" ")
|
valid_game.dump(header)
|
def dump(self, header): game_count = float(self.count)
|
self.attention = 4.5
|
self.attention = 4.0
|
def __init__(self, verbose): self.count = 0 self.result_list = []
|
def format(self, indent):
|
def gen_content(self, indent):
|
def format(self, indent): if self.count <= 0: self.add_line("%sGame Count: %d" % (header, self.count), Color.PURPLE) return
|
self.add_line("\n\n")
|
self.add_line("\n")
|
def format(self, indent): if self.count <= 0: self.add_line("%sGame Count: %d" % (header, self.count), Color.PURPLE) return
|
self.format(0)
|
self.gen_content(0)
|
def generate(self): self.add_line("No.\tScore\tPoint", Color.PURPLE)
|
self.add_line("\n")
|
def generate(self): self.add_line("No.\tScore\tPoint", Color.PURPLE)
|
|
count = 0
|
def __init__(self): self.count = 0
|
def gen_indent(indent) : header = "" for i in range(indent): header += " " return header
|
left_goals = 0 right_goals = 0
|
self.left_goals = 0 self.right_goals = 0
|
def gen_indent(indent) : header = "" for i in range(indent): header += " " return header
|
left_points = 0 right_points = 0
|
self.left_points = 0 self.right_points = 0
|
def gen_indent(indent) : header = "" for i in range(indent): header += " " return header
|
win_count = 0 draw_count = 0 lost_count = 0
|
self.win_count = 0 self.draw_count = 0 self.lost_count = 0
|
def gen_indent(indent) : header = "" for i in range(indent): header += " " return header
|
left_score_map = {} right_score_map = {} diff_score_map = {}
|
self.left_score_map = {} self.right_score_map = {} self.diff_score_map = {}
|
def gen_indent(indent) : header = "" for i in range(indent): header += " " return header
|
with open("total_rounds", "r") as f: left_count = int(f.read().strip()) - self.count
|
try: with open("total_rounds", "r") as f: left_count = int(f.read().strip()) - self.count except IOError: pass
|
def do_some_calc(self): left_count = -1 with open("total_rounds", "r") as f: left_count = int(f.read().strip()) - self.count
|
self.add_line("Game Count: %d (%d left)" % (self.count, left_count))
|
if left_count > 0: self.add_line("Game Count: %d (%d left)" % (self.count, left_count)) else: self.add_line("Game Count: %d" % (self.count))
|
def do_some_calc(self): left_count = -1 with open("total_rounds", "r") as f: left_count = int(f.read().strip()) - self.count
|
max_win_rate = (self.win_count + left_count) / game_count
|
max_win_rate = (self.win_count + left_count) / (game_count + left_count)
|
def do_some_calc(self): left_count = -1 with open("total_rounds", "r") as f: left_count = int(f.read().strip()) - self.count
|
self.attention = 5
|
self.attention = 4.5
|
def __init__(self, verbose): self.count = 0 self.result_list = []
|
self.add_line(" No. Score Point")
|
def do_some_formatting(self): self.add_line(self.title, color=Color.BLUE) #title self.add_newline() self.add_line(" No. Score Point") #head
|
|
print "Non Valid Game Rate: %f" % ((total_game.count - valid_game.count) / float(total_game.count))
|
print "Non Valid Game Rate: %f%%" % ((total_game.count - valid_game.count) / float(total_game.count) * 100)
|
def dump(self, header): game_count = float(self.count)
|
parser.add_option("-a", "--analyze", action="store_true", dest="analyze", default=False, help="output simplify")
|
parser.add_option("-A", "--analyze", action="store_true", dest="analyze", default=False, help="output simplify")
|
def run(self, lines, method): self.generate_context(lines) self.context.dump(method)
|
string += "[b]" + line.string + "[/b]"
|
string += line.string
|
def discuz(line): string = "" if line.color == Color.RED: string += "[color=Red]" elif line.color == Color.ORANGE: string += "[color=Orange]" elif line.color == Color.GREEN: string += "[color=Green]" elif line.color == Color.BLUE: string += "[color=Blue]" elif line.color == Color.PURPLE: string += "[color=Purple]" if line.face == Face.MONOSPACE: string += "[font=Monospace]" string += "[b]" + line.string + "[/b]" if line.face != Face.NORMAL: string += "[/font]" if line.color != Color.NONE: string += "[/color]" return string
|
string += "<strong>" + line.string.replace(" ", " ") + "</strong>"
|
string += line.string.replace(" ", " ")
|
def html(line): string = "" line.face = Face.MONOSPACE if line.color == Color.RED: string += "<font color=Red>" elif line.color == Color.ORANGE: string += "<font color=Orange>" elif line.color == Color.GREEN: string += "<font color=Green>" elif line.color == Color.BLUE: string += "<font color=Blue>" elif line.color == Color.PURPLE: string += "<font color=Purple>" if line.face == Face.MONOSPACE: string += "<font face=Monospace>" string += "<strong>" + line.string.replace(" ", " ") + "</strong>" if line.face != Face.NORMAL: string += "</font>" if line.color != Color.NONE: string += "</font>" return string + "<br />"
|
print "Only Valid Game:"
|
print "Valid Game:"
|
def dump(self, header): game_count = float(self.count)
|
header = gen_indent(indent)
|
print "%sLeft Team Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.left_score_map) : print line print print "%sRight Team Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.right_score_map) : print line print print "%sDiff Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.diff_score_map) : print line print
|
def dump(self, indent): game_count = float(self.count)
|
if self.count <= 0: print return
|
def dump(self, indent): game_count = float(self.count)
|
|
print "\n%sLeft Team Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.left_score_map) : print line print "\n%sRight Team Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.right_score_map) : print line print "\n%sDiff Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.diff_score_map) : print line
|
def dump(self, indent): game_count = float(self.count)
|
|
indent += 1
|
def bar(percentage): length = 33 bar_length = int(length * percentage)
|
|
def dump(self, header):
|
def dump_score_map(self, indent, score_map): def bar(percentage): length = 25 bar_length = length * percentage line = "[" for i in range(bar_length): line += " for i in range(length - bar_length): line += " " line += "%.2f%%" % (percentage * 100) return line indent += 1 header = gen_indent(indent) lines = [] for score in sorted(score_map.keys()): lines.append("%s%d:\t%s" % (header, score, bar(score_map[score] / float(self.count)))) return lines def dump(self, indent):
|
def dump(self, header): game_count = float(self.count)
|
if header: print "%sCount: %d" % (header, self.count)
|
header = gen_indent(indent) print "%sCount: %d" % (header, self.count)
|
def dump(self, header): game_count = float(self.count)
|
print "%sAvg Goals: %f : %f (diff: %f)" % (header, avg_left_goals, avg_right_goals, avg_left_goals - avg_right_goals)
|
print "%sAvg Goals: %.2f : %.2f (diff: %.2f)" % (header, avg_left_goals, avg_right_goals, avg_left_goals - avg_right_goals)
|
def dump(self, header): game_count = float(self.count)
|
print "%sAvg Points: %f : %f (diff: %f)" % (header, avg_left_points, avg_right_points, avg_left_points - avg_right_points)
|
print "%sAvg Points: %.2f : %.2f (diff: %.2f)" % (header, avg_left_points, avg_right_points, avg_left_points - avg_right_points)
|
def dump(self, header): game_count = float(self.count)
|
print "%sLeft Team: WinRate %f%%, ExpectedWinRate %f%%" % (header, win_rate * 100, expected_win_rate * 100)
|
print "%sLeft Team: WinRate %.2f%%, ExpectedWinRate %.2f%%" % (header, win_rate * 100, expected_win_rate * 100) print "\n%sLeft Team Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.left_score_map) : print line print "\n%sRight Team Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.right_score_map) : print line print "\n%sDiff Goals Distribution:" % (header) for line in self.dump_score_map(indent, self.diff_score_map) : print line
|
def dump(self, header): game_count = float(self.count)
|
header = ""
|
indent = 0
|
def dump(self, header): game_count = float(self.count)
|
header = " "
|
indent = 1
|
def dump(self, header): game_count = float(self.count)
|
if header:
|
if indent:
|
def dump(self, header): game_count = float(self.count)
|
total_game.dump(header)
|
total_game.dump(indent)
|
def dump(self, header): game_count = float(self.count)
|
valid_game.dump(header)
|
valid_game.dump(indent)
|
def dump(self, header): game_count = float(self.count)
|
print "Non Valid Game Rate: %f%%" % ((total_game.count - valid_game.count) / float(total_game.count) * 100)
|
print "Non Valid Game Rate: %.2f%%" % ((total_game.count - valid_game.count) / float(total_game.count) * 100)
|
def dump(self, header): game_count = float(self.count)
|
def update(self, index, left_score, rigt_score, valid) : count += 1
|
def update(self, index, left_score, rigt_score, valid): global g_max_sub self.count += 1
|
def update(self, index, left_score, rigt_score, valid) : count += 1
|
if sub >= g_max_sub :
|
if sub >= g_max_sub: g_max_sub = sub
|
def update(self, index, left_score, rigt_score, valid) : count += 1
|
return "%d\t%d:%d\t%d:%d\t%d" % (index, left_score, rigt_score, left_points, right_points, valid)
|
return "%s%d\t%d:%d\t%d:%d\t%d\033[0m" % (header, index, left_score, rigt_score, left_points, right_points, valid) def dump(self, header): print "%sCount: %d" % (header, self.count) print "%sGoals: %d : %d" % (header, self.left_goals, self.right_goals) print
|
def update(self, index, left_score, rigt_score, valid) : count += 1
|
parser.add_option("-C", "--console", action="store_true", dest="console", default=True, help="print console format [default]") parser.add_option("-N", "--no-color", action="store_true", dest="no_color", default=False, help="print no-color console format")
|
parser.add_option("-C", "--console", action="store_true", dest="console", default=True, help="print with color to console [default]") parser.add_option("-N", "--no-color", action="store_true", dest="no_color", default=False, help="print without color to console")
|
def run(self, lines, method): self.generate_context(lines) self.context.dump(method)
|
elif options.console:
|
else:
|
def run(self, lines, method): self.generate_context(lines) self.context.dump(method)
|
win_rate_standard_deviation = math.sqrt(win_rate - win_rate * win_rate); print self.count, win_rate, 1.0 - win_rate_standard_deviation
|
win_rate_standard_deviation = math.sqrt(win_rate * (1.0 - win_rate)); confidence_intervel_left = win_rate - 1.96 * win_rate_standard_deviation / math.sqrt(game_count) confidence_intervel_right = win_rate + 1.96 * win_rate_standard_deviation / math.sqrt(game_count) if confidence_intervel_left < 0.0: confidence_intervel_left = 0.0 if confidence_intervel_right > 1.0: confidence_intervel_right = 1.0 print self.count, win_rate, confidence_intervel_left, confidence_intervel_right
|
def update(self, left_score, right_score, valid): self.count += 1
|
self.win_rate_standard_deviation = math.sqrt(self.win_rate - self.win_rate * self.win_rate);
|
self.win_rate_standard_deviation = math.sqrt(self.win_rate * (1.0 - self.win_rate)); self.confidence_intervel_left = self.win_rate - 1.96 * self.win_rate_standard_deviation / math.sqrt(game_count) self.confidence_intervel_right = self.win_rate + 1.96 * self.win_rate_standard_deviation / math.sqrt(game_count)
|
def do_some_calculating(self): game_count = float(self.count)
|
line = "["
|
percentage_string = "%.2f%%" % (percentage * 100) while len(percentage_string) <= 6: percentage_string = " " + percentage_string line = "%s [" % (percentage_string)
|
def bar(percentage): length = 25 bar_length = length * percentage
|
for i in range(length - bar_length): line += "-" line += "] %.2f%%" % (percentage * 100)
|
def bar(percentage): length = 25 bar_length = length * percentage
|
|
lines.append("%s%3d:\t%s" % (header, score, bar(score_map[score] / float(self.count))))
|
lines.append("%s%3d: %s" % (header, score, bar(score_map[score] / float(self.count))))
|
def bar(percentage): length = 25 bar_length = length * percentage
|
for line in self.gen_score_map(self.left_score_map) : self.context.add_line(line)
|
map(lambda line: self.context.add_line(line), self.gen_score_map(self.left_score_map))
|
def do_some_calc(self): if self.count <= 0: self.add_line("Game Count: %d" % (self.count)) return
|
for line in self.gen_score_map(self.right_score_map) : self.context.add_line(line)
|
map(lambda line: self.context.add_line(line), self.gen_score_map(self.right_score_map))
|
def do_some_calc(self): if self.count <= 0: self.add_line("Game Count: %d" % (self.count)) return
|
for line in self.gen_score_map(self.diff_score_map) : self.context.add_line(line)
|
map(lambda line: self.context.add_line(line), self.gen_score_map(self.diff_score_map))
|
def do_some_calc(self): if self.count <= 0: self.add_line("Game Count: %d" % (self.count)) return
|
lines.append(line.rstrip())
|
line = line.rstrip() if len(line) > 0: lines.append(line)
|
def run(self, lines, method): self.generate_context(lines) self.context.dump(method)
|
if self.verbose: self.add_newline() self.add_line(" No. Score Point")
|
self.add_newline() self.add_line(" No. Score Point")
|
def generate_context(self, lines): index = -1 non_valid = 0 for line in lines: index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) #title if self.verbose: self.add_newline() self.add_line(" No. Score Point") #head continue parts = line.split() for i in range(len(parts)): parts[i] = int(parts[i])
|
with open("total_rounds", "r") as f: left_count = int(f.read().strip()) - self.count except IOError:
|
file = open("total_rounds", "r") left_count = int(file.read().strip()) - self.count file.close() except:
|
def do_some_calc(self): left_count = -1
|
expected_win_rate = win_rate / (win_rate + lost_rate)
|
expected_win_rate = 0.5 try: expected_win_rate = win_rate / (win_rate + lost_rate) except: pass
|
def do_some_calc(self): left_count = -1
|
self.add_line("Total Miss Count: %d (in %d matches, %.2f%%)" % (miss_count, miss_matches, miss_matches / float(self.count) * 100)), Color.RED)
|
self.add_line("Total Miss Count: %d (in %d matches, %.2f%%)" % (miss_count, miss_matches, miss_matches / float(self.count) * 100), Color.RED)
|
def do_some_formatting(self): self.add_line(self.title, color=Color.BLUE) self.add_newline()
|
self.add_line("Left Team: WinRate Standard Deviation %.4f" % (self.win_rate_standard_deviation))
|
def do_some_formatting(self): self.add_line(self.title, color=Color.BLUE) self.add_newline()
|
|
print
|
def dump(self, header): game_count = float(self.count)
|
|
def generate_context(self):
|
def generate_context(self, lines):
|
def generate_context(self): index = -1 non_valid = 0 for line in sys.stdin: index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) #title self.add_newline() self.add_line(" No. Score Point") #head continue parts = line.split() for i in range(len(parts)): parts[i] = int(parts[i])
|
for line in sys.stdin:
|
for line in lines:
|
def generate_context(self): index = -1 non_valid = 0 for line in sys.stdin: index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) #title self.add_newline() self.add_line(" No. Score Point") #head continue parts = line.split() for i in range(len(parts)): parts[i] = int(parts[i])
|
def run(self, method): self.generate_context()
|
def run(self, lines, method): self.generate_context(lines)
|
def run(self, method): self.generate_context() self.context.dump(method)
|
GameData().run(html)
|
GameData().run(lines, html)
|
def run(self, method): self.generate_context() self.context.dump(method)
|
elif options.discuz: GameData().run(discuz) else: GameData().run(console)
|
def run(self, method): self.generate_context() self.context.dump(method)
|
|
print "No.\tScore\tPoint\tValid";
|
def dump(self, header): game_count = float(self.count)
|
|
header = "" if total_game.count > 0 and valid_game.count < total_game.count: header = " "
|
def dump(self, header): game_count = float(self.count)
|
|
total_game.dump(header)
|
total_game.dump(" ")
|
def dump(self, header): game_count = float(self.count)
|
if header:
|
if total_game.count > 0:
|
def dump(self, header): game_count = float(self.count)
|
valid_game.dump(header)
|
valid_game.dump(" ")
|
def dump(self, header): game_count = float(self.count)
|
for score in sorted(score_map.keys()): lines.append("%s%3d:%s%3d %s" % (header, score, gen_indent(1), score_map[score], bar(score_map[score] / float(self.count))))
|
scores = sorted(score_map.keys()) for score in range(scores[0], scores[-1] + 1): if score_map.has_key(score): lines.append("%s%3d:%s%3d %s" % (header, score, gen_indent(1), score_map[score], bar(score_map[score] / float(self.count)))) else: lines.append("%s%3d:%s%3d %s" % (header, score, gen_indent(1), 0, bar(0)))
|
def bar(percentage): length = 33 bar_length = int(length * percentage)
|
self.add_line("Non Valid Game Count: %d" % (non_valid_game_count), Color.RED) self.add_line("Non Valid Game Rate: %.2f%%" % (non_valid_game_count / float(self.count) * 100), Color.RED)
|
self.add_line("Non Valid Game Count: %d (%.2f%%)" % (non_valid_game_count, non_valid_game_count / float(self.count) * 100), Color.RED)
|
def generate(self): self.add_line("No.\tScore\tPoint", Color.PURPLE)
|
if self.verbose: self.context.add_line(self.update(index, left_score, right_score, valid)) else: self.update(index, left_score, right_score, valid)
|
single_line = self.update(index, left_score, right_score, valid) if self.verbose or single_line.color != Color.NONE: self.context.add_line(single_line)
|
def generate_context(self, lines): index = -1 non_valid = 0 for line in lines: index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) #title if self.verbose: self.add_newline() self.add_line(" No. Score Point") #head continue parts = line.split() for i in range(len(parts)): parts[i] = int(parts[i])
|
if options.console: GameData().run(lines, console)
|
def run(self, lines, method): self.generate_context(lines) self.context.dump(method)
|
|
if options.html:
|
elif options.html:
|
def run(self, lines, method): self.generate_context(lines) self.context.dump(method)
|
elif options.console: GameData().run(lines, console)
|
def run(self, lines, method): self.generate_context(lines) self.context.dump(method)
|
|
self.max_sub = 0
|
self.attention = 5 self.max_sub = self.attention
|
def __init__(self, verbose): self.count = 0
|
elif sub >= 5:
|
elif sub >= self.attention:
|
def update(self, index, left_score, right_score, valid): self.count += 1
|
if sub >= g_max_sub: g_max_sub = sub header = "\033[01;33m\n" elif sub > 4:
|
if sub > 4:
|
def update(self, index, left_score, rigt_score, valid): global g_max_sub
|
self.max_sub = self.attention
|
def __init__(self, verbose): self.count = 0
|
|
def update(self, index, left_score, right_score, valid):
|
def update(self, left_score, right_score, valid):
|
def update(self, index, left_score, right_score, valid): self.count += 1
|
line = Context.Line("%3d%6d:%d%6d:%d" % (index, left_score, right_score, left_points, right_points)) if valid: sub = abs(left_score - right_score) if sub >= self.max_sub: self.max_sub = sub line.color = Color.ORANGE elif sub >= self.attention: line.color = Color.GREEN else: line.color = Color.RED return line
|
def update(self, index, left_score, right_score, valid): self.count += 1
|
|
left_count = -1
|
game_count = float(self.count)
|
def do_some_calc(self): left_count = -1
|
left_count = int(file.read().strip()) - self.count
|
self.left_count = int(file.read().strip()) - self.count
|
def do_some_calc(self): left_count = -1
|
if self.count <= 0: if left_count > 0: self.add_line("Game Count: %d (%d left)" % (self.count, left_count))
|
self.avg_left_goals = self.left_goals / game_count self.avg_right_goals = self.right_goals / game_count self.avg_left_points = self.left_points / game_count self.avg_right_points = self.right_points / game_count self.win_rate = self.win_count / game_count self.lost_rate = self.lost_count / game_count try: self.expected_win_rate = self.win_rate / (self.win_rate + self.lost_rate) except: pass if self.left_count > 0: self.max_win_rate = (self.win_count + self.left_count) / (game_count + self.left_count) self.min_win_rate = self.win_count / (game_count + self.left_count) def do_some_formatting(self): self.add_line(self.title, color=Color.BLUE) self.add_newline() self.add_line(" No. Score Point") left_attention = self.avg_left_goals - self.avg_right_goals - self.attention right_attention = self.avg_left_goals - self.avg_right_goals + self.attention min_diff = left_attention max_diff = right_attention non_valid = 0 for result in self.result_list: line = Context.Line("%3d%6d:%d%6d:%d" % (result.index, result.left_score, result.right_score, result.left_points, result.right_points)) if result.valid: diff = result.left_score - result.right_score if diff <= min_diff: min = diff line.color = Color.ORANGE elif diff >= max_diff: max_diff = diff line.color = Color.ORANGE elif diff <= left_attention: line.color = Color.GREEN elif diff >= right_attention: line.color = Color.GREEN
|
def do_some_calc(self): left_count = -1
|
self.add_line("Game Count: %d" % (self.count)) return game_count = float(self.count)
|
non_valid += 1 line.color = Color.RED if self.verbose or line.color != Color.NONE: self.context.add_line(line) self.add_newline()
|
def do_some_calc(self): left_count = -1
|
if left_count > 0: self.add_line("Game Count: %d (%d left)" % (self.count, left_count))
|
if self.left_count > 0: self.add_line("Game Count: %d (%d left)" % (self.count, self.left_count))
|
def do_some_calc(self): left_count = -1
|
avg_left_goals = self.left_goals / game_count avg_right_goals = self.right_goals / game_count self.add_line("Avg Goals: %.2f : %.2f (diff: %.2f)" % (avg_left_goals, avg_right_goals, avg_left_goals - avg_right_goals)) avg_left_points = self.left_points / game_count avg_right_points = self.right_points / game_count self.add_line("Avg Points: %.2f : %.2f (diff: %.2f)" % (avg_left_points, avg_right_points, avg_left_points - avg_right_points)) win_rate = self.win_count / game_count lost_rate = self.lost_count / game_count expected_win_rate = 1.0 try: expected_win_rate = win_rate / (win_rate + lost_rate) except: pass
|
self.add_line("Avg Goals: %.2f : %.2f (diff: %.2f)" % (self.avg_left_goals, self.avg_right_goals, self.avg_left_goals - self.avg_right_goals)) self.add_line("Avg Points: %.2f : %.2f (diff: %.2f)" % (self.avg_left_points, self.avg_right_points, self.avg_left_points - self.avg_right_points))
|
def do_some_calc(self): left_count = -1
|
self.add_line("Left Team: WinRate %.2f%%, ExpectedWinRate %.2f%%" % (win_rate * 100, expected_win_rate * 100)) if left_count > 0: max_win_rate = (self.win_count + left_count) / (game_count + left_count) min_win_rate = self.win_count / (game_count + left_count) self.add_line("Left Team: MaxWinRate %.2f%%, MinWinRate %.2f%%" % (max_win_rate * 100, min_win_rate * 100), Color.GRAY)
|
self.add_line("Left Team: WinRate %.2f%%, ExpectedWinRate %.2f%%" % (self.win_rate * 100, self.expected_win_rate * 100)) self.add_line("Left Team: MaxWinRate %.2f%%, MinWinRate %.2f%%" % (self.max_win_rate * 100, self.min_win_rate * 100), Color.GRAY) if non_valid: self.add_line("Non Valid Game Count: %d (%.2f%%)" % (non_valid, non_valid / float(self.count) * 100), Color.RED)
|
def do_some_calc(self): left_count = -1
|
index = -1 non_valid = 0
|
self.title = lines[0].strip() lines.pop(0)
|
def generate_context(self, lines): index = -1 non_valid = 0 for line in lines: index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) #title self.add_newline() self.add_line(" No. Score Point") #head continue parts = line.split() for i in range(len(parts)): parts[i] = int(parts[i])
|
index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) self.add_newline() self.add_line(" No. Score Point") continue
|
def generate_context(self, lines): index = -1 non_valid = 0 for line in lines: index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) #title self.add_newline() self.add_line(" No. Score Point") #head continue parts = line.split() for i in range(len(parts)): parts[i] = int(parts[i])
|
|
single_line = self.update(index, left_score, right_score, valid) if self.verbose or single_line.color != Color.NONE: self.context.add_line(single_line) if not valid: non_valid += 1 self.add_newline() if self.count <= 0: self.add_line("No results found, exit") else: self.do_some_calc() if non_valid: self.add_line("Non Valid Game Count: %d (%.2f%%)" % (non_valid, non_valid / float(self.count) * 100), Color.RED)
|
self.update(left_score, right_score, valid) self.do_some_calc() self.do_some_formatting()
|
def generate_context(self, lines): index = -1 non_valid = 0 for line in lines: index += 1 if index <= 0: self.add_line(line, color=Color.BLUE) #title self.add_newline() self.add_line(" No. Score Point") #head continue parts = line.split() for i in range(len(parts)): parts[i] = int(parts[i])
|
win_rate = self.win_count / game_count win_rate_standard_deviation = math.sqrt(win_rate * (1.0 - win_rate)); confidence_intervel_left = win_rate - 1.96 * win_rate_standard_deviation / math.sqrt(game_count) confidence_intervel_right = win_rate + 1.96 * win_rate_standard_deviation / math.sqrt(game_count) if confidence_intervel_left < 0.0: confidence_intervel_left = 0.0 if confidence_intervel_right > 1.0: confidence_intervel_right = 1.0 print self.count, win_rate, confidence_intervel_left, confidence_intervel_right
|
self.win_rate = self.win_count / game_count self.calc_confidence_interval() print self.count, self.win_rate, self.confidence_intervel_left, self.confidence_intervel_right
|
def update(self, left_score, right_score, valid): self.count += 1
|
self.win_rate_standard_deviation = math.sqrt(self.win_rate * (1.0 - self.win_rate)); self.confidence_intervel_left = self.win_rate - 1.96 * self.win_rate_standard_deviation / math.sqrt(game_count) self.confidence_intervel_right = self.win_rate + 1.96 * self.win_rate_standard_deviation / math.sqrt(game_count)
|
self.calc_confidence_interval()
|
def do_some_calculating(self): game_count = float(self.count)
|
lines.append("%s%3d:%s%3d %s" % (header, score, gen_indent(1), score_map[score], bar(score_map[score] / float(self.count)))) else: lines.append("%s%3d:%s%3d %s" % (header, score, gen_indent(1), 0, bar(0)))
|
count = score_map[score] percentage = score_map[score] / float(self.count) lines.append("%s%3d:%s%3d %s" % (header, score, gen_indent(1), count, bar(percentage)))
|
def bar(percentage): length = 33 bar_length = int(length * percentage)
|
line = Context.Line("%d\t%d:%d\t%d:%d" % (index, left_score, right_score, left_points, right_points))
|
line = Context.Line("%3d%6d:%d%6d:%d" % (index, left_score, right_score, left_points, right_points))
|
def update(self, index, left_score, right_score, valid): self.count += 1
|
self.add_line("No.\tScore\tPoint") index = 0
|
index = -1
|
def generate_context(self): self.add_line("No.\tScore\tPoint")
|
parser.add_option("-C", "--console", action="store_true", dest="console", default=True, help="print to console [default]") parser.add_option("-D", "--discuz", action="store_true", dest="discuz", default=False, help="print to stdout using discuz code")
|
parser.add_option("-C", "--console", action="store_true", dest="console", default=True, help="print console format [default]") parser.add_option("-D", "--discuz", action="store_true", dest="discuz", default=False, help="print as discuz code format") parser.add_option("-H", "--html", action="store_true", dest="html", default=False, help="print as html format")
|
def run(self, method): self.generate_context() self.context.dump(method)
|
if options.discuz:
|
if options.html: print "<head> " print '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' print "<title>Test Results</title> " print "</head>" print "<body>" print "<h1>Test Results</h1>" print "<hr>" GameData().run(html) print "</body>" elif options.discuz:
|
def run(self, method): self.generate_context() self.context.dump(method)
|
sub = abs(left_score - rigt_score) if sub >= g_max_sub: g_max_sub = sub header = "\033[01;33m" elif sub >= 5: header = "\033[01;32m" if not valid:
|
if valid: sub = abs(left_score - rigt_score) if sub >= g_max_sub: g_max_sub = sub header = "\033[01;33m" elif sub >= 5: header = "\033[01;32m" else:
|
def update(self, index, left_score, rigt_score, valid): global g_max_sub
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.