porereax.utils¶
Module providing utility functions for the PoreReax package.
This module includes functions for saving and loading Python objects using pickle, loading YAML configuration files, and common mathematical operations such as the minimum-image convention.
Functions
|
Retrieve the data for a specific identifier from a data file. |
|
Retrieve the list of identifiers from a data file. |
|
Load a Python object from a file using pickle. |
|
Load a YAML file and return its contents as a dictionary. |
|
Apply the minimal image convention to a vector given the simulation box dimensions. |
|
Calculate the midpoint between two vectors considering the minimal image convention. |
|
Read a YAML file containing pore system properties and extract relevant depending on the pore shape. |
|
Save a Python object to a file using pickle. |
Classes
|
Decorator that fills %(name)s placeholders in a docstring. |
- porereax.utils.save_object(obj, filename)[source]¶
Save a Python object to a file using pickle.
- Parameters:
obj (any) – The Python object to be saved.
filename (str) – The path to the file where the object will be saved.
- porereax.utils.load_object(file_path)[source]¶
Load a Python object from a file using pickle.
- Parameters:
file_path (str) – The path to the file from which the object will be loaded.
- Returns:
The loaded Python object.
- Return type:
any
- porereax.utils.load_yaml(file_path)[source]¶
Load a YAML file and return its contents as a dictionary.
- porereax.utils.min_image_convention(vec, box)[source]¶
Apply the minimal image convention to a vector given the simulation box dimensions.
- porereax.utils.min_image_midpoint(vec1, vec2, box)[source]¶
Calculate the midpoint between two vectors considering the minimal image convention.
- porereax.utils.get_identifiers(link_data)[source]¶
Retrieve the list of identifiers from a data file.
- porereax.utils.get_data(link_data, identifier)[source]¶
Retrieve the data for a specific identifier from a data file.
- porereax.utils.read_pore_yml(file_path)[source]¶
Read a YAML file containing pore system properties and extract relevant depending on the pore shape.
- class porereax.utils.Substitution(**kwargs)[source]¶
Bases:
objectDecorator that fills %(name)s placeholders in a docstring.
Use this to inject a shared block (e.g. a common Parameters section) into multiple docstrings without retyping it. Unlike plain %-formatting, only whole-line %(name)s placeholders are replaced, so an unrelated bare ‘%’ elsewhere in the docstring is left untouched. Each line of the replacement text is reindented to match the placeholder’s own indentation, so it splices cleanly into an indented class docstring.