cosapp.recorders.recorder¶
Base class for recording data.
Classes
|
Abstract base class for recorders. |
|
-
class
cosapp.recorders.recorder.BaseRecorder(includes: Union[str, List[str]] = '*', excludes: Optional[Union[str, List[str]]] = None, numerical_only=False, section='', precision=9, hold=False, raw_output=False)[source]¶ Bases:
abc.ABCAbstract base class for recorders.
Matching pattern are case sensitive and support the following special patterns:
Pattern
Meaning
*
matches everything
?
matches any single character
[seq]
matches any character in seq
[!seq]
matches any character not in seq
Excluding pattern are shadowing includes one; e.g. if includes=’*port_in.*’ and `excludes=’*.Pt’, for a port having variables named Tt and Pt, only Tt will be recorded.
- Parameters
includes (str or list of str, optional) – Variables matching these patterns will be included; default ‘*’ (i.e. all variables).
excludes (str or list of str or None, optional) – Variables matching these patterns will be excluded; default None (i.e. nothing is excluded).
numerical_only (bool, optional) – Keep only numerical variables (i.e. number or numerical vector); default False.
section (str, optional) – Current section name; default ‘’.
precision (int, optional) – Precision digits when writing floating point number; default 9 (i.e. 10 figures will be written).
hold (bool, optional) – Append the new data or not; default False.
raw_output (bool, optional) – Raw output; default False.
Signals –
------- –
state_recorded (Signal(time_ref: Union[float, str], status: str, error_code: str)) – Signal emitted after record_state execution
cleared (Signal()) – Signal emitted after clear execution
-
SPECIALS= SpecialColumns(section='Section', status='Status', code='Error code', reference='Reference')¶
-
collected_data() → List[Any][source]¶ Collects and returns recorded data from watched object as a list.
-
property
data¶ DataFrame containing the results. Deprecated property; use export_data() instead.
- Type
pandas.DataFrame
-
property
excludes¶ Variables matching these patterns will be excluded.
- Type
str or list of str
-
abstract
export_data() → pandas.core.frame.DataFrame[source]¶ Export recorded results into a pandas.DataFrame object.
-
classmethod
extend(recorder, includes: Union[str, List[str]] = [], excludes: Union[str, List[str]] = []) → cosapp.recorders.recorder.BaseRecorder[source]¶ Factory returning a new recorder, with similar attributes as recorder, but extended includes and excludes fields.
- Parameters
includes (str, list of str, or None, optional) – Variables patterns extending recorder inclusion patterns; default [] (i.e. no change).
excludes (str, list of str, or None, optional) – Variables patterns extending recorder exclusion patterns; default [] (i.e. no change).
-
field_names() → List[str][source]¶ Returns list of requested variables and expressions.
- Returns
List[str] – Variable names matching the includes/excludes patterns of the user in the watched object.
.. note:: – Inward and outward variables will appear without the prefix inwards. or outwards..
-
abstract
formatted_data() → List[Any][source]¶ Returns collected data from watched object as a formatted list.
-
property
hold¶ Append the new data or not.
- Type
bool
-
property
includes¶ Variables matching these patterns will be included.
- Type
str or list of str
-
paused: bool = False¶
-
property
precision¶ Precision digits when writing floating point number.
- Type
int
-
record_state(time_ref: Union[float, str], status='', error_code='0') → None[source]¶ Record the watched object at the provided status.
- Parameters
time_ref (float or str) – Current simulation time (float) or point reference (str)
status (str, optional) – Status of the simulation; default ‘’.
error_code (str, optional) – Error code; default ‘0’.
-
restore(index: int)[source]¶ Restore the watch object state from the recorded data.
- Parameters
index (int) – Index of the record as iloc in the Pandas DataFrame
-
property
section¶ Current section name.
- Type
str