From bc3889c4e0a47c5aad7646b81ba2ebb0b9af48fe Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 20 Sep 2020 00:45:38 +0000 Subject: [PATCH] superscript.py v 0.7.0 Signed-off-by: Arthur Lu --- data-analysis/config.json | 2 +- data-analysis/superscript.py | 71 +++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/data-analysis/config.json b/data-analysis/config.json index 78930573..eca2d09a 100644 --- a/data-analysis/config.json +++ b/data-analysis/config.json @@ -1,6 +1,6 @@ { "team": "", - "competition": "", + "competition": "2020ilch", "key":{ "database":"", "tba":"" diff --git a/data-analysis/superscript.py b/data-analysis/superscript.py index 05d3e809..fdd4e5a5 100644 --- a/data-analysis/superscript.py +++ b/data-analysis/superscript.py @@ -3,10 +3,12 @@ # Notes: # setup: -__version__ = "0.6.2" +__version__ = "0.7.0" # changelog should be viewed using print(analysis.__changelog__) __changelog__ = """changelog: + 0.7.0: + - finished implementing main function 0.6.2: - integrated get_team_rankings.py as get_team_metrics() function - integrated visualize_pit.py as graph_pit_histogram() function @@ -120,6 +122,65 @@ import matplotlib.pyplot as plt import time import warnings +def main(): + + warnings.filterwarnings("ignore") + + while (True): + + current_time = time.time() + print("[OK] time: " + str(current_time)) + + config = load_config("config.json") + competition = config["competition"] + match_tests = config["statistics"]["match"] + pit_tests = config["statistics"]["pit"] + metrics_tests = config["statistics"]["metric"] + print("[OK] configs loaded") + + apikey = config["key"]["database"] + tbakey = config["key"]["tba"] + print("[OK] loaded keys") + + previous_time = get_previous_time(apikey) + print("[OK] analysis backtimed to: " + str(previous_time)) + + print("[OK] loading data") + start = time.time() + match_data = load_match(apikey, competition) + pit_data = load_pit(apikey, competition) + print("[OK] loaded data in " + str(time.time() - start) + " seconds") + + print("[OK] running tests") + start = time.time() + matchloop(apikey, competition, match_data, match_tests) + print("[OK] finished tests in " + str(time.time() - start) + " seconds") + + print("[OK] running metrics") + start = time.time() + metricloop(tbakey, apikey, competition, previous_time, metrics_tests) + print("[OK] finished metrics in " + str(time.time() - start) + " seconds") + + print("[OK] running pit analysis") + start = time.time() + pitloop(apikey, competition, pit_data, pit_tests) + print("[OK] finished pit analysis in " + str(time.time() - start) + " seconds") + + set_current_time(apikey, current_time) + print("[OK] finished all tests, looping") + + clear() + +def clear(): + + # for windows + if name == 'nt': + _ = system('cls') + + # for mac and linux(here, os.name is 'posix') + else: + _ = system('clear') + def load_config(file): config_vector = {} @@ -148,6 +209,10 @@ def get_previous_time(apikey): return previous_time +def set_current_time(apikey, current_time): + + d.set_analysis_flags(apikey, "latest_update", {"latest_update":current_time}) + def load_match(apikey, competition): return d.get_match_data_formatted(apikey, competition) @@ -402,4 +467,6 @@ def graph_pit_histogram(apikey, competition, figsize=(80,15)): i+=1 - plt.show() \ No newline at end of file + plt.show() + +main() \ No newline at end of file