Helper Functions¶
- general_functions.helper_functions.apply_mask_to_list(values, mask)
Apply a mask to a list of values.
- Parameters:
values (list) – The list of values to be masked.
mask (list of bool) – The mask to apply. Each element of the mask corresponds to an element in values.
- Returns:
A new list containing only the values where the mask is True.
- Return type:
list
- general_functions.helper_functions.convert_accel_units(val, input_unit, output_unit)
Convert an acceleration value from one unit to another.
- Parameters:
val (float) – The acceleration value to be converted.
input_unit (str) – The unit of the input value. Must be one of “g”, “m/s^2”.
output_unit (str) – The desired output unit. Must be one of “g”, “m/s^2”.
- Returns:
The converted acceleration value.
- Return type:
float
Notes
The function first converts the input value to meters per second squared and then to the desired output unit.
- general_functions.helper_functions.convert_length_units(val, input_unit, output_unit)
Convert a length value from one unit to another.
- Parameters:
val (float) – The length value to be converted.
input_unit (str) – The unit of the input value. Must be one of “cm”, “mm”, “m”.
output_unit (str) – The desired output unit. Must be one of “cm”, “mm”, “m”.
- Returns:
The converted length value.
- Return type:
float
Notes
The function first converts the input value to meters and then to the desired output unit.
- general_functions.helper_functions.convert_mass_units(val, input_unit, output_unit)
Convert a mass value from one unit to another.
- Parameters:
val (float) – The mass value to be converted.
input_unit (str) – The unit of the input value. Must be one of “g”, “lb”, “kg”.
output_unit (str) – The desired output unit. Must be one of “g”, “lb”, “kg”.
- Returns:
The converted mass value.
- Return type:
float
Notes
The function first converts the input value to kilograms and then to the desired output unit.
- general_functions.helper_functions.convert_time_units(val, input_unit, output_unit)
Convert a time value from one unit to another.
- Parameters:
val (float) – The time value to be converted.
input_unit (str) – The unit of the input value. Must be one of “min”, “hour”, “s”.
output_unit (str) – The desired output unit. Must be one of “min”, “hour”, “s”.
- Returns:
The converted time value.
- Return type:
float
Notes
The function first converts the input value to seconds and then to the desired output unit.
- general_functions.helper_functions.create_folder_if_not_exists(folder_path)
Create a folder if it does not already exist.
- Parameters:
folder_path (str) – The path to the folder to be created.
Notes
If the folder already exists, a message is printed indicating so.
- general_functions.helper_functions.progress_bar(iterations, total, time_left)
Display a progress bar in the console.
- Parameters:
iterations (int) – The current iteration.
total (int) – The total number of iterations.
time_left (float) – Estimated time left in seconds.
Notes
The progress bar shows the completion percentage and the estimated time left in minutes.