ugc.utils package¶
Submodules¶
ugc.utils.commands_helpers module¶
- ugc.utils.commands_helpers.dataframe_get_weighted_average(df, data_col, weight_col, by_col) float ¶
Calculate the weighted average in a dataframe from a numerical column and an integer column (weight) where the results are grouped by the column by_col.
- Parameters:
df (DataFrame) – Pandas dataframe, used to temporarily store new columns.
data_col (number) – int or float column from a dataframe.
weight_col (number) – int or float column from a dataframe.
by_col ([type]) – A dataframe column from which weights should be grouped.
- Returns:
- Weighted average calculated from data_col and weight_col
and grouped by by_col.
- Return type:
float
- ugc.utils.commands_helpers.dataframe_map_module_to_weight(row) int ¶
Return the weight of a given module from a dataframe row based on the module level and the module name (since the final project is worth more).
- Parameters:
row (dataframe row) – A row from a dataframe containing at least two columns, Level and Module name.
- Returns:
Integer value corresponding to the weight of a module.
- Return type:
int
- ugc.utils.commands_helpers.dataframe_parse_datetime_as_month_year(row) str ¶
Take in a dataframe row, get a timestamp from a column and return a formatted string in the form MMM YYYY, where MMM is the abbreviation of a month’s name.
- Parameters:
row – A dataframe row.
- Returns:
A formatted string of the form “MMM YYYY”.
- Return type:
str
- ugc.utils.commands_helpers.generate_sample_copy_config_file_and_print_message(config_path: str) dict ¶
- ugc.utils.commands_helpers.get_module_score_rounded_up(module) float ¶
- ugc.utils.commands_helpers.get_modules_done_dataframe(grades: Grades, finished_modules: list) DataFrame ¶
- ugc.utils.commands_helpers.get_template() dict ¶
Return the default grades template used for the initial configuration as a dict.
- ugc.utils.commands_helpers.get_template_location() Path ¶
- ugc.utils.commands_helpers.pprint_dataframe_done(dataframe: DataFrame, title: str) None ¶
- ugc.utils.commands_helpers.pprint_dataframe_in_progress(dataframe: DataFrame, title: str) None ¶
- ugc.utils.commands_helpers.print_modules_in_progress(pretty_printer, grades)¶
- ugc.utils.commands_helpers.print_unweighted_average_in_progress(uavg, only_in_progress=False) None ¶
- ugc.utils.commands_helpers.print_weighted_average_in_progress(wavg, only_in_progress=False) None ¶
- ugc.utils.commands_helpers.there_are_no_modules_in_progress(grades) bool ¶
ugc.utils.grades_helpers module¶
- ugc.utils.grades_helpers.get_classification(average) str ¶
Return a string containing the classification of the student according to the Programme Specification.
- ugc.utils.grades_helpers.get_ects_equivalent_score(score: float) str ¶
Return the grade in the ECTS equivalent form. Range from A to E/F.
- ugc.utils.grades_helpers.get_grades_list_as_list_of_dicts(grades: list) list ¶
- ugc.utils.grades_helpers.get_module_score(module) float ¶
- ugc.utils.grades_helpers.get_score_of_module_in_progress(module: dict) float ¶
- ugc.utils.grades_helpers.get_total_score_modules_finished(modules: list) float ¶
- ugc.utils.grades_helpers.get_total_weight_modules_finished(modules: list) float ¶
- ugc.utils.grades_helpers.get_total_weight_modules_in_progress(modules: list) float ¶
- ugc.utils.grades_helpers.get_uk_gpa(average) float ¶
Return the GPA as calculated in the UK.
- ugc.utils.grades_helpers.get_unweighted_total_score_modules_in_progress(modules: list) float ¶
- ugc.utils.grades_helpers.get_us_gpa(average) float ¶
Return the GPA as calculated in the US.
- ugc.utils.grades_helpers.get_us_letter_equivalent_score(score: float) str ¶
Get the letter equivalent in the US grading system for a given score.
- ugc.utils.grades_helpers.get_weight_of(level: int) int ¶
Return the weight of a given level. The ratio is 1:3:5 for modules of L4:L5:L6 respectively.
- ugc.utils.grades_helpers.get_weighted_total_score_modules_in_progress(modules: list) float ¶
- ugc.utils.grades_helpers.load_short_module_names()¶
- ugc.utils.grades_helpers.score_is_valid(module_score: float) bool ¶
Check whether a given score is a valid numeric value. Return a Boolean value.
ugc.utils.mathtools module¶
Math helper functions.
- ugc.utils.mathtools.round_half_up(num: float, decimals: int = 0)¶
Round a float up and return it.
Assumes 10 decimals is enough precision. Also assumes we won’t be rounding anything beyond 1,000,000 as that’s far outside the range of expected values and would lead to overflow errors in this implementation.