cosapp.recorders.recorder¶
Base class for recording data.
Functions
|
Returns True if argument is either an iterator, a cosapp object, or a collection thereof; False otherwise. |
|
Returns True if obj is either a port, a system or a driver; False otherwise. |
|
Filter function for dictionary items, to exclude entries that match any_forbidden_object. |
Classes
|
Abstract base class for recorders. |
|
- class cosapp.recorders.recorder.BaseRecorder(includes: str | List[str] = '*', excludes: str | List[str] | None = None, numerical_only=False, section='', precision=9, hold=False, raw_output=False)[source]¶
Bases:
ABC
Abstract 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 = ('Section', 'Status', 'Error code', 'Reference')¶
- collected_data() List[Any] [source]¶
Collects and returns recorded data from watched object as a list.
- property data: DataFrame¶
DataFrame containing the results. Deprecated property; use export_data() instead.
- Type:
pandas.DataFrame
- property excludes: List[str]¶
Variables matching these patterns will be excluded.
- Type:
str or list of str
- classmethod extend(recorder, includes: str | List[str] = [], excludes: str | List[str] = []) 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: bool¶
Append the new data or not.
- Type:
bool
- property includes: List[str]¶
Variables matching these patterns will be included.
- Type:
str or list of str
- paused: bool = False¶
- property precision: int¶
Precision digits when writing floating point number.
- Type:
int
- record_state(time_ref: 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: str¶
Current section name.
- Type:
str
- class cosapp.recorders.recorder.SpecialColumns(section, status, code, reference)[source]¶
Bases:
NamedTuple
- code: str¶
Alias for field number 2
- reference: str¶
Alias for field number 3
- section: str¶
Alias for field number 0
- status: str¶
Alias for field number 1
- cosapp.recorders.recorder.any_forbidden_object(collection: Any) bool [source]¶
Returns True if argument is either an iterator, a cosapp object, or a collection thereof; False otherwise.