pyprobe.utils#
A collection of utility functions for PyProBE.
Functions
A decorator that wraps pydantic ValidationError to raise a custom exception. |
|
|
A decorator to mark a function or property as deprecated. |
|
Flatten a list of lists into a single list. |
|
Set PyProBE's logging level to send to stderr. |
Classes
|
Protocol defining required PyBaMM Solution interface. |
Exceptions
Custom exception for PyProBE validation errors. |
- flatten_list(lst)#
Flatten a list of lists into a single list.
- Parameters:
lst (list) – The list of lists to flatten.
- Returns:
The flattened list.
- Return type:
list
- class PyBaMMSolution(*args, **kwargs)#
Bases:
ProtocolProtocol defining required PyBaMM Solution interface.
- get_data_dict(variables=None, short_names=None, cycles_and_steps=True)#
Get solution data as dictionary.
- Parameters:
variables (list[str] | None)
short_names (dict[str, str] | None)
cycles_and_steps (bool)
- Return type:
dict[str, Any]
- exception PyProBEValidationError#
Bases:
ExceptionCustom exception for PyProBE validation errors.
- catch_pydantic_validation(func)#
A decorator that wraps pydantic ValidationError to raise a custom exception.
- Parameters:
func (Any)
- Return type:
Any
- deprecated(*, reason, version, plain_reason=None)#
A decorator to mark a function or property as deprecated.
- Parameters:
reason (str) – The reason for deprecation, using RST formatting for docs.
version (str) – The version in which the function was deprecated.
plain_reason (str, optional) – The plain text reason for deprecation. Defaults to None.
- Return type:
Any
- set_log_level(level='ERROR')#
Set PyProBE’s logging level to send to stderr.
- Parameters:
level (Literal['TRACE', 'DEBUG', 'INFO', 'SUCCESS', 'WARNING', 'ERROR', 'CRITICAL']) – The logging level to display. Options are: - TRACE: Show all messages, including trace messages. - DEBUG: Show all debugging information. - INFO: Show detailed information. - SUCCESS: Show success messages. - WARNING: Show warning messages. - ERROR: Show error messages (default). - CRITICAL: Show critical error messages only.
- Return type:
None
Example:
import pyprobe pyprobe.set_log_level("INFO") # Show more detailed logs pyprobe.set_log_level("DEBUG") # Show all debugging information pyprobe.set_log_level("ERROR") # Default - show only errors