From d5ebb0348bec81a3c7ce0a908c2ca5eb7ea57fd5 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 21 Oct 2021 21:27:35 +0000 Subject: [PATCH] finished rough outline for Match module Signed-off-by: Arthur Lu --- src/cli/module.py | 53 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/src/cli/module.py b/src/cli/module.py index 6fdfb2e..e9d85a7 100644 --- a/src/cli/module.py +++ b/src/cli/module.py @@ -1,4 +1,7 @@ import data as d +import signal +import numpy as np +import tra_analysis as an class AutoVivification(dict): def __getitem__(self, item): @@ -31,6 +34,7 @@ class Match: teams = None data = [] + results = [] def __init__(self, config, apikey, tbakey, timestamp, teams): self.config = config @@ -63,10 +67,53 @@ class Match: for competition in competitions: for variable in self.config["tests"]: match_data = d.get_team_match_data(self.apikey, competition, team, variable) # needs modified implementation - self.data.append((team, competition, variable, match_data)) + variable_tests = self.config["tests"][variable] + self.data.append({"team": team, "competition": competition, "variable": variable, "tests": variable_tests, "data": match_data}) + + def tests(test_data): + signal.signal(signal.SIGINT, signal.SIG_IGN) + + if(test_data["data"] == None): + return None + + data = np.array(test_data["data"]) + data = data[np.isfinite(data)] + ranges = list(range(len(data))) + + tests = test_data["tests"] + + results = AutoVivification() + + if "basic_stats" in tests: + results["basic_stats"] = an.basic_stats(data) + if "historical_analysis" in tests: + results["historical_analysis"] = an.histo_analysis([ranges, data]) + if "regression_linear" in tests: + results["regression_linear"] = an.regression(ranges, data, ['lin']) + if "regression_logarithmic" in tests: + results["regression_logarithmic"] = an.regression(ranges, data, ['log']) + if "regression_exponential" in tests: + results["regression_exponential"] = an.regression(ranges, data, ['exp']) + if "regression_polynomial" in tests: + results["regression_polynomial"] = an.regression(ranges, data, ['ply']) + if "regression_sigmoidal" in tests: + results["regression_sigmoidal"] = an.regression(ranges, data, ['sig']) + + return results def process_data(self, exec_threads): - pass + self.results = list(exec_threads.map(self.tests, self.data)) def push_results(self): - pass \ No newline at end of file + short_mapping = {"regression_linear": "lin", "regression_logarithmic": "log", "regression_exponential": "exp", "regression_polynomial": "ply", "regression_sigmoidal": "sig"} + results_short = AutoVivification() + i = 0 + for result in self.results: + for variable in result: + if variable in short_mapping: + short = short_mapping[variable] + else: + short = variable + d.push_team_match_results(self.data[i]["team"], self.data[i]["competition"], self.data[i]["variable"], short, result[variable]) + #results_short[ self.data["team"] ][ self.data["competition"] ][ self.data["variable"] ][short] = result[variable] + i+=1 \ No newline at end of file