Refactore RoutineStatistics code
This commit is contained in:
parent
ef48f14db2
commit
74d9ea89ee
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
This application read à ***CSV file*** whitch contain trampoline routines and make some analyses :
|
This application read à ***XLSX file*** whitch contain trampoline routines and make some analyses :
|
||||||
|
|
||||||
- number of routines,
|
- number of routines,
|
||||||
- number of unfinished routines,
|
- number of unfinished routines,
|
||||||
|
@ -10,7 +10,7 @@ This application read à ***CSV file*** whitch contain trampoline routines and m
|
||||||
- number of tucked/picked/straight skills,
|
- number of tucked/picked/straight skills,
|
||||||
- …
|
- …
|
||||||
|
|
||||||
All these results are exported in two CSV files.
|
All these results are exported in a .xlsx file.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
144
analyse.py
144
analyse.py
|
@ -16,86 +16,72 @@ from skill import (
|
||||||
BACKWARD,
|
BACKWARD,
|
||||||
)
|
)
|
||||||
from routine import Routine
|
from routine import Routine
|
||||||
|
from routine_statistics import RoutineStatistics
|
||||||
|
|
||||||
|
|
||||||
class RoutineStatistics:
|
class RoutineStatistics:
|
||||||
|
def __get_number_of_skill(self):
|
||||||
|
"""Compute the total number of skills"""
|
||||||
|
self.number_of_skill = 0
|
||||||
|
for routine in self.routines:
|
||||||
|
self.number_of_skill += routine.get_number_of_skill()
|
||||||
|
|
||||||
|
def __get_number_of_unfinished_routine(self):
|
||||||
|
"""Compute the number of unfinished routine"""
|
||||||
|
self.number_of_unfinished_routine = 0
|
||||||
|
for routine in self.routines:
|
||||||
|
if not routine.is_complete():
|
||||||
|
self.number_of_unfinished_routine += 1
|
||||||
|
|
||||||
|
def __get_number_of_skill_by_position(self):
|
||||||
|
"""Compute the number of skill for each position"""
|
||||||
|
self.number_of_tucked = self.get_number_of_skill_for_position("o")
|
||||||
|
self.number_of_picked = self.get_number_of_skill_for_position("<")
|
||||||
|
self.number_of_straight = self.get_number_of_skill_for_position("/")
|
||||||
|
|
||||||
|
def __get_number_of_skill_by_quantity_of_rotation(self):
|
||||||
|
"""Compute the number of skill for each summmersault quantity"""
|
||||||
|
self.number_of_simple = self.get_number_of_skill_with_rotation_quantity(1)
|
||||||
|
self.number_of_double = self.get_number_of_skill_with_rotation_quantity(2)
|
||||||
|
self.number_of_triple = self.get_number_of_skill_with_rotation_quantity(3)
|
||||||
|
self.number_of_quadriple = self.get_number_of_skill_with_rotation_quantity(4)
|
||||||
|
|
||||||
|
def __get_number_of_skill_by_quantity_of_twist_at_end(self):
|
||||||
|
"""Compute the number of skill for each twisting out quantity"""
|
||||||
|
self.number_of_no_twist_out = self.get_number_of_skill_with_twisting_out(0)
|
||||||
|
self.number_of_half_out = self.get_number_of_skill_with_twisting_out(1)
|
||||||
|
self.number_of_full_out = self.get_number_of_skill_with_twisting_out(2)
|
||||||
|
self.number_of_rudy_out = self.get_number_of_skill_with_twisting_out(3)
|
||||||
|
self.number_of_double_full_out = self.get_number_of_skill_with_twisting_out(4)
|
||||||
|
self.number_of_randy_out = self.get_number_of_skill_with_twisting_out(5)
|
||||||
|
|
||||||
|
def __get_number_of_skill_by_quantity_of_twist_at_begin(self):
|
||||||
|
"""Compute the number of skill for each twisting in quantity"""
|
||||||
|
self.number_of_no_twist_in = self.get_number_of_skill_with_twisting_in(0)
|
||||||
|
self.number_of_half_in = self.get_number_of_skill_with_twisting_in(1)
|
||||||
|
self.number_of_full_in = self.get_number_of_skill_with_twisting_in(2)
|
||||||
|
self.number_of_rudy_in = self.get_number_of_skill_with_twisting_in(3)
|
||||||
|
self.number_of_double_full_in = self.get_number_of_skill_with_twisting_in(4)
|
||||||
|
self.number_of_randy_in = self.get_number_of_skill_with_twisting_in(5)
|
||||||
|
|
||||||
|
def __get_number_of_skill_by_direction(self):
|
||||||
|
"""Compute the number of skill for each position"""
|
||||||
|
self.number_of_frontward = self.get_number_of_skill_for_direction(FRONTWARD)
|
||||||
|
self.number_of_backward = self.get_number_of_skill_for_direction(BACKWARD)
|
||||||
|
|
||||||
def __init__(self, routine_list) -> None:
|
def __init__(self, routine_list) -> None:
|
||||||
self.routines = routine_list
|
self.routines = routine_list
|
||||||
self.skills_dict = dict()
|
self.skills_dict = dict()
|
||||||
self.combination_dict = dict()
|
self.combination_dict = dict()
|
||||||
|
self.number_of_routine = len(self.routines)
|
||||||
|
|
||||||
if len(self.routines) > 0:
|
self.__get_number_of_skill()
|
||||||
self.number_of_skill = self.get_number_of_skill()
|
self.__get_number_of_unfinished_routine()
|
||||||
self.number_of_routine = len(self.routines)
|
self.__get_number_of_skill_by_position()
|
||||||
self.number_of_unfinished_routine = self.get_number_of_unfinished_routine()
|
self.__get_number_of_skill_by_quantity_of_rotation()
|
||||||
|
self.__get_number_of_skill_by_quantity_of_twist_at_end()
|
||||||
# Position
|
self.__get_number_of_skill_by_quantity_of_twist_at_begin()
|
||||||
self.number_of_tucked = self.get_number_of_skill_for_position("o")
|
self.__get_number_of_skill_by_direction()
|
||||||
self.number_of_picked = self.get_number_of_skill_for_position("<")
|
|
||||||
self.number_of_straight = self.get_number_of_skill_for_position("/")
|
|
||||||
|
|
||||||
# Quantity of rotation
|
|
||||||
self.number_of_simple = self.get_number_of_skill_with_rotation_quantity(1)
|
|
||||||
self.number_of_double = self.get_number_of_skill_with_rotation_quantity(2)
|
|
||||||
self.number_of_triple = self.get_number_of_skill_with_rotation_quantity(3)
|
|
||||||
self.number_of_quadriple = self.get_number_of_skill_with_rotation_quantity(
|
|
||||||
4
|
|
||||||
)
|
|
||||||
|
|
||||||
# Quantity of twist at the end of skill
|
|
||||||
self.number_of_no_twist_out = self.get_number_of_skill_with_twisting_out(0)
|
|
||||||
self.number_of_half_out = self.get_number_of_skill_with_twisting_out(1)
|
|
||||||
self.number_of_full_out = self.get_number_of_skill_with_twisting_out(2)
|
|
||||||
self.number_of_rudy_out = self.get_number_of_skill_with_twisting_out(3)
|
|
||||||
self.number_of_double_full_out = self.get_number_of_skill_with_twisting_out(
|
|
||||||
4
|
|
||||||
)
|
|
||||||
self.number_of_randy_out = self.get_number_of_skill_with_twisting_out(5)
|
|
||||||
|
|
||||||
# Quantity of twist at the begin of skill
|
|
||||||
self.number_of_no_twist_in = self.get_number_of_skill_with_twisting_in(0)
|
|
||||||
self.number_of_half_in = self.get_number_of_skill_with_twisting_in(1)
|
|
||||||
self.number_of_full_in = self.get_number_of_skill_with_twisting_in(2)
|
|
||||||
self.number_of_rudy_in = self.get_number_of_skill_with_twisting_in(3)
|
|
||||||
self.number_of_double_full_in = self.get_number_of_skill_with_twisting_in(4)
|
|
||||||
|
|
||||||
# Direction
|
|
||||||
self.number_of_frontward = self.get_number_of_skill_for_direction(FRONTWARD)
|
|
||||||
self.number_of_backward = self.get_number_of_skill_for_direction(BACKWARD)
|
|
||||||
else:
|
|
||||||
self.number_of_skill = 0
|
|
||||||
self.number_of_routine = 0
|
|
||||||
self.number_of_unfinished_routine = 0
|
|
||||||
|
|
||||||
# Position
|
|
||||||
self.number_of_tucked = 0
|
|
||||||
self.number_of_picked = 0
|
|
||||||
self.number_of_straight = 0
|
|
||||||
|
|
||||||
# Quantity of rotation
|
|
||||||
self.number_of_simple = 0
|
|
||||||
self.number_of_double = 0
|
|
||||||
self.number_of_triple = 0
|
|
||||||
self.number_of_quadriple = 0
|
|
||||||
|
|
||||||
# Quantity of twist at the end of skill
|
|
||||||
self.number_of_no_twist_out = 0
|
|
||||||
self.number_of_half_out = 0
|
|
||||||
self.number_of_full_out = 0
|
|
||||||
self.number_of_rudy_out = 0
|
|
||||||
self.number_of_double_full_out = 0
|
|
||||||
self.number_of_randy_out = 0
|
|
||||||
|
|
||||||
# Quantity of twist at the begin of skill
|
|
||||||
self.number_of_no_twist_in = 0
|
|
||||||
self.number_of_half_in = 0
|
|
||||||
self.number_of_full_in = 0
|
|
||||||
self.number_of_rudy_in = 0
|
|
||||||
self.number_of_double_full_in = 0
|
|
||||||
|
|
||||||
# Direction
|
|
||||||
self.number_of_frontward = 0
|
|
||||||
self.number_of_backward = 0
|
|
||||||
|
|
||||||
self.table_conditionnal_format = ColorScaleRule(
|
self.table_conditionnal_format = ColorScaleRule(
|
||||||
start_type="percentile",
|
start_type="percentile",
|
||||||
|
@ -114,7 +100,6 @@ class RoutineStatistics:
|
||||||
Crée le dictionnaire de combinaison par rapport à toutes les figures contenues dans le
|
Crée le dictionnaire de combinaison par rapport à toutes les figures contenues dans le
|
||||||
dictionnaire de figures.
|
dictionnaire de figures.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.combination_dict["end"] = dict()
|
self.combination_dict["end"] = dict()
|
||||||
self.combination_dict["crash"] = dict()
|
self.combination_dict["crash"] = dict()
|
||||||
|
|
||||||
|
@ -133,19 +118,6 @@ class RoutineStatistics:
|
||||||
self.skills_dict.get(skill.numeric_code, 0) + 1
|
self.skills_dict.get(skill.numeric_code, 0) + 1
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_number_of_skill(self):
|
|
||||||
number_of_skill = 0
|
|
||||||
for routine in self.routines:
|
|
||||||
number_of_skill += routine.get_number_of_skill()
|
|
||||||
return number_of_skill
|
|
||||||
|
|
||||||
def get_number_of_unfinished_routine(self):
|
|
||||||
number_of_unfinished_routine = 0
|
|
||||||
for routine in self.routines:
|
|
||||||
if not routine.is_complete():
|
|
||||||
number_of_unfinished_routine += 1
|
|
||||||
return number_of_unfinished_routine
|
|
||||||
|
|
||||||
def get_score(self):
|
def get_score(self):
|
||||||
score = 0
|
score = 0
|
||||||
for routine in self.routines:
|
for routine in self.routines:
|
||||||
|
|
12
routine.py
12
routine.py
|
@ -9,11 +9,14 @@ from skill import (
|
||||||
class Routine:
|
class Routine:
|
||||||
"""Class routine
|
"""Class routine
|
||||||
|
|
||||||
Each object `routine` is composed by `skills`, a list of skill.
|
Each object `routine` is composed by two fields :
|
||||||
|
- skills: list of skill
|
||||||
|
- difficulty difficulty score of a routine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.skills = []
|
self.skills = []
|
||||||
|
self.__difficulty = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
routine = ""
|
routine = ""
|
||||||
|
@ -27,6 +30,13 @@ class Routine:
|
||||||
def is_complete(self):
|
def is_complete(self):
|
||||||
return len(self.skills) == 10
|
return len(self.skills) == 10
|
||||||
|
|
||||||
|
def get_difficulty_value(self):
|
||||||
|
if self.__difficulty is None:
|
||||||
|
self.__difficulty = 0
|
||||||
|
for skill in skills:
|
||||||
|
self.__difficulty += skill.difficulty
|
||||||
|
return self.__difficulty
|
||||||
|
|
||||||
def get_number_of_skill(self):
|
def get_number_of_skill(self):
|
||||||
return len(self.skills)
|
return len(self.skills)
|
||||||
|
|
||||||
|
|
1
skill.py
1
skill.py
|
@ -103,7 +103,6 @@ class Skill:
|
||||||
self.difficulty += (int(self.quart_summersault_rotation) // 4) * 0.1
|
self.difficulty += (int(self.quart_summersault_rotation) // 4) * 0.1
|
||||||
self.difficulty += (int(self.quart_summersault_rotation) // 12) * 0.1
|
self.difficulty += (int(self.quart_summersault_rotation) // 12) * 0.1
|
||||||
self.difficulty += (int(self.quart_summersault_rotation) // 16) * 0.1
|
self.difficulty += (int(self.quart_summersault_rotation) // 16) * 0.1
|
||||||
|
|
||||||
if self.position == "<" or self.position == "/":
|
if self.position == "<" or self.position == "/":
|
||||||
self.difficulty += (int(self.quart_summersault_rotation) // 4) * 0.1
|
self.difficulty += (int(self.quart_summersault_rotation) // 4) * 0.1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue