From b38686c7b56b7c0c81c43e7e9c971c8fec7edf62 Mon Sep 17 00:00:00 2001 From: Joe Moudrik Date: Tue, 23 Jul 2013 20:39:12 +0200 Subject: [PATCH] some late comments :) --- config.py | 6 ++++-- data_about_players.py | 24 ++++++++++++++++++++++-- ipython_session.py | 2 ++ load_questionare.py | 3 +++ pachi.py | 3 +++ result_file.py | 3 +++ 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index 58f81ad..d5ec9c2 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,8 @@ +# Directory of the pachi go bot, patched as written in the readme PACHI_DIR='../pachi/' -DB_FILE='./GODB.db' QUESTIONARE_DIRECTORY = './QUESTIONARE' - +# where to store processed data (result files) OUTPUT_DIR = './OUTPUT' +DB_FILE='./GODB.db' + diff --git a/data_about_players.py b/data_about_players.py index fa767ac..f776d9d 100755 --- a/data_about_players.py +++ b/data_about_players.py @@ -7,7 +7,20 @@ import load_questionare from config import QUESTIONARE_DIRECTORY +""" +This file covers extracting and averaging data from style questionares, +both from fixed predefined results that were covered manually (below, +see the Data class) +""" + def questionare_average(questionare_list, silent=False, tex=False, cnt_limit=1): + """Averages data from different interviewees. + + Parameters: + cnt_limit -- minimum number of interviewees that filled the quest. for the + given pro to be included + silent -- do not print anything + tex -- print the results in the tex table linese, suitable for export""" # Otake Hideo & $4.3 \pm 0.5$ & $3.0 \pm 0.0$ & $4.6 \pm 1.2$ & $3.6 \pm 0.9$ \\ total={} count={} @@ -57,6 +70,7 @@ def questionare_average(questionare_list, silent=False, tex=False, cnt_limit=1): return result def questionare_average_raw(questionare_list): + """currently not used""" import numpy total={} count={} @@ -89,8 +103,6 @@ def questionare_average_raw(questionare_list): return result class Data: - ### Explicit list of players - ### ### Following code consist of expert based knowledge kindly supplied by ### Alexander Dinerstein 3-pro, Motoki Noguchi 7-dan and Vit Brunner 4-dan) @@ -101,6 +113,9 @@ class Data: ## the orthodox scale corresponds to novelty, the "name" of the scale remains # the same for historical reasons --- the scales are defined the same though + # a list of dictionaries (one dict per interviewee) that contain + # style estimates + questionare_list = [ #questionare_vit_brun { @@ -203,6 +218,8 @@ class Data: questionare_total = questionare_average(questionare_list, silent=True) def get_all_player_names(limit=1): + """Utility function returning a list of all players that are answered by + at least @limit interviewees""" pc = {} for q in Data.questionare_list: @@ -214,6 +231,9 @@ def get_all_player_names(limit=1): return ps def get_interesting_pros(style, top, bottom, without_dist=True): + """Computes euclidean distance from a given @style and returns @top N closest + pros and @bottom N farthest pros. If without_dist=False (default is True), + the function returns the pros in a tuple with the distance itself.""" style_vec = numpy.array(style) dist = [ diff --git a/ipython_session.py b/ipython_session.py index cf11906..4d9396c 100644 --- a/ipython_session.py +++ b/ipython_session.py @@ -11,5 +11,7 @@ from utils.godb_session import godb_session_maker import pachi from config import DB_FILE +"""Just a utility file to save imports""" + if __name__ == '__main__': s = godb_session_maker(filename=DB_FILE) diff --git a/load_questionare.py b/load_questionare.py index e5abacb..4750419 100644 --- a/load_questionare.py +++ b/load_questionare.py @@ -3,6 +3,9 @@ import os import json import logging +"""Utility module loading questionare answers from the json questionare results +listed in (see config) QUESTIONARE (by def) subdir.""" + def load_file(filename): with open(filename) as fin: dump = json.load(fin) diff --git a/pachi.py b/pachi.py index 3d3f532..8f4d64c 100644 --- a/pachi.py +++ b/pachi.py @@ -22,6 +22,9 @@ from config import PACHI_DIR PACHI_SPATIAL_DICT = os.path.join(PACHI_DIR, 'patterns.spat') + +"""A wrapper allowing more comfy use of the pachi go engine.""" + class Pattern: def __init__(self, pattern=None, fpairs=None): if pattern != None: diff --git a/result_file.py b/result_file.py index 609d687..cfa47c7 100644 --- a/result_file.py +++ b/result_file.py @@ -6,6 +6,9 @@ from config import OUTPUT_DIR from utils.colors import * from utils import misc +"""Utility class to generate a randomly named (without collisions) +file to output i.e. pattern files from pachi. """ + class ResultFile: def __init__(self, filename, create_empty=False): self.filename = filename -- 2.11.4.GIT