ethos_penalps.utilities.general_functions#
Module Contents#
Classes#
A string class for supporting $-substitutions. |
|
Extensible JSON <https://json.org> encoder for Python data structures. |
Functions#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Attributes#
- ethos_penalps.utilities.general_functions.get_all_rows_with_minimum_index_from_array(input_array: list[list]) numpy.ndarray#
- ethos_penalps.utilities.general_functions.get_all_rows_with_maximum_index_from_array(input_array: list[list]) numpy.ndarray#
- ethos_penalps.utilities.general_functions.format_timedelta(td: datetime.timedelta) str#
- class ethos_penalps.utilities.general_functions.ResultPathGenerator#
- result_time_stamp: str#
- time_stamp_format: str = '%Y_%m_%d__%H_%M_%S'#
- create_path_to_file_relative_to_main_file(file_name: str, subdirectory_name: str, file_extension: str, add_time_stamp_to_filename: bool = True) str#
Creates a path to subdirectory which is located at the level of the __main__ file. Subdirectory is created if it does not exists prior to call.
- Parameters:
file_name (str) – name of the file to be created. Is prepending the full file name with optional timestamp
subdirectory_name (str) – Name of the subdirectory which is created
file_extension (str) – The file extension which is appended to the file name
add_time_stamp_to_filename (bool, optional) – Adds a current timestamp the file name between name and file extension, defaults to True
time_stamp_format (str, optional) – describes the format of the timestamp which is added if add_time_stamp_to_filename is set to True, defaults to “%Y_%m_%d__%H_%M_%S”
- Returns:
returns the path to a file in a subdirectory
- Return type:
str
- create_result_folder_relative_to_main_file(subdirectory_name: str, add_time_stamp_to_filename: bool = True) str#
- create_subdirectory_relative_to_parent(parent_directory_path: str, new_directory_name: str) str#
- ethos_penalps.utilities.general_functions.denormalize(value: numbers.Number, minimum_value: numbers.Number, maximum_value: numbers.Number)#
- ethos_penalps.utilities.general_functions.check_if_date_1_is_before_date_2(date_1: datetime.datetime, date_2: datetime.datetime) bool#
- ethos_penalps.utilities.general_functions.check_if_date_1_is_before_or_at_date_2(date_1: datetime.datetime, date_2: datetime.datetime) bool#
- class ethos_penalps.utilities.general_functions.DeltaTemplate(template)#
Bases:
string.TemplateA string class for supporting $-substitutions.
- delimiter = '%'#
- ethos_penalps.utilities.general_functions.convert_date_time_to_string(td: datetime.timedelta, fmt)#
- ethos_penalps.utilities.general_functions.get_super(x)#
- ethos_penalps.utilities.general_functions.get_sub(x)#
- ethos_penalps.utilities.general_functions.create_subscript_string_matplotlib(base: str, subscripted_text: str)#
- ethos_penalps.utilities.general_functions.get_new_uuid() str#
- ethos_penalps.utilities.general_functions.create_dataclass_from_pandas_series(data: pandas.Series, factory: Any) Any#
- class ethos_penalps.utilities.general_functions.ExtendedEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#
Bases:
json.JSONEncoderExtensible JSON <https://json.org> encoder for Python data structures.
Supports the following objects and types by default:
Python
JSON
dict
object
list, tuple
array
str
string
int, float
number
True
true
False
false
None
null
To extend this to recognize other objects, subclass and implement a
.default()method with another method that returns a serializable object foroif possible, otherwise it should call the superclass implementation (to raiseTypeError).- default(obj)#
Selects an encoder for custom objects
- Parameters:
obj (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- ethos_penalps.utilities.general_functions.a#