rizer.misc.utils#
Library useful functions to retrieve data.
Attributes#
Classes#
Deal with optional packages. |
Functions#
|
Return the full path of the rizer folder. |
|
Return the absolute path to the data folder, or file inside. |
|
List all mechanisms in the data directory. |
Module Contents#
- rizer.misc.utils.ROOT_FOLDER_PATH#
- rizer.misc.utils.get_root() pathlib.Path#
Return the full path of the rizer folder.
Used not to worry about the project architecture.
- Returns:
the abspath to root folder (should end with ‘rizer’)
- Return type:
Path
Examples
>>> from rizer.misc.utils import get_root >>> path = get_root() / "data"
- rizer.misc.utils.get_path_to_data(*paths: str, force_return: bool = False) pathlib.Path#
Return the absolute path to the data folder, or file inside.
- Parameters:
*paths (
str) – You can add a path to precise the folder inside.force_return (
bool, optional) – If True, return path even if does not exists, by default False.
- Returns:
The abspath to the data (or file).
- Return type:
Path
Examples
>>> from rizer.misc.utils import get_path_to_data >>> path = get_path_to_data() >>> path = get_path_to_data( ... "experiments", "Thor4_T176", "run143_capacity_discharge.csv" ... )
- Raises:
FileNotFoundError – If the file or folder is not found.
- rizer.misc.utils.list_all_mechanisms(excluded_mechanism_dirs: list[str] | None) list[pathlib.Path]#
List all mechanisms in the data directory.
- Parameters:
excluded_mechanism_dirs (
list[str] | None) – List of directories to exclude from the search. If None, no directories are excluded.- Returns:
List of all mechanisms found in the data directory.
- Return type:
list[Path]
- class rizer.misc.utils.NotInstalled(name: str, info: str = '')#
Deal with optional packages.
Will raise an error only if the package is used (but not if imported only).
- Parameters:
name (
str) – The name of the package to install.info (
str, optional) – Information about the package, by default “”
Examples
>>> some_function = NotInstalled("you should install C drivers") >>> a = some_function # No error. >>> a() # Will raise the NotInstalled error and display the message.