Operator instance#

An OperatorInstance object is an Expression object representing an operator instance call, the called operator being represented by an instance of the top-level class OperatorBase

../../../_images/instance.svg

Operator instance class diagram#

Higher-order operations (operations using an operator as parameter) are represented by instances of the OperatorExpression class.

../../../_images/instance_ho.svg

Operator higher-order class diagram#

class ansys.scadeone.core.swan.OperatorBase(sizes: List[Expression])#

Bases: SwanItem, ABC

Base class for: operator ::= prefix_op [[sizes]].

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str(op_str: str) str#

Returns op_str [<<sizes>>].

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property sizes: List[Expression]#

Size parameters of call.

Operator instance application#

class ansys.scadeone.core.swan.OperatorInstance(operator: OperatorBase, params: Group, luid: Luid | None = None)#

Bases: Expression

Operator instance call:

expr := operator_instance ( group )

operator_instance ::= operator [[ luid ]]

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property luid: Luid | None#

Optional luid.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property operator: OperatorBase#

Called operator.

property owner: Self#

Owner of current Swan construct.

property params: Group#

Call parameters.

Named operator instance#

class ansys.scadeone.core.swan.PathIdOpCall(path_id: PathIdentifier, sizes: List[Expression], pragmas: List[Pragma])#

Bases: OperatorBase, PragmaBase

Call to user-defined operator: operator ::= path_id [[sizes]].

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str(op_str: str) str#

Returns op_str [<<sizes>>].

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property path_id: PathIdentifier#

Operator path.

property pragmas: List[Pragma]#

List of pragmas.

property sizes: List[Expression]#

Size parameters of call.

Anonymous operator instance#

class ansys.scadeone.core.swan.AnonymousOperatorWithExpression(is_node: bool, params: List[Identifier], sections: List[ScopeSection], expr: Expression)#

Bases: OperatorExpression

Anonymous operator expression: ((node|function)) id {{ , id }} scope_sections => expr.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property expr: Expression#

Anonymous operator body.

property is_node#

True when anonymous operator is a node, else a function.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property params: List[Identifier]#

Anonymous operator parameters list.

property sections: List[ScopeSection]#

Scope sections list.

class ansys.scadeone.core.swan.AnonymousOperatorWithDataDefinition(is_node: bool, inputs: List[VarDecl], outputs: List[VarDecl], data_def: Equation | Scope)#

Bases: OperatorExpression

Anonymous operator expression: ((node|function)) params returns params data_def.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property data_def: Equation | Scope#

Anonymous operator data definition, either an equation or a scope.

property inputs: List[VarDecl]#

Anonymous operator input list.

property is_node#

True when anonymous operator is a node, else a function.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property outputs: List[VarDecl]#

Anonymous operator output list.

property owner: Self#

Owner of current Swan construct.

Higher-order operator instance#

Higher-order operators#

Higher-order

Application

map, fold, mapfold, mapi foldi, mapfoldi

array iterators

activate operator expression every

conditional activation

restart operator expression every

conditional restart

Iterator#

class ansys.scadeone.core.swan.Iterator(kind: IteratorKind, operator: OperatorBase)#

Bases: OperatorExpression

Iterators: map, fold, mapfold, mapi, foldi, mapfoldi.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property kind: IteratorKind#

Iterator kind.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property operator: OperatorBase#

Iterated operator.

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.IteratorKind(value)#

Bases: Enum

Iterators kind: map, fold, mapfold, mapi, foldi, mapfoldi.

Fold = 2#

fold iterator.

Foldi = 5#

foldi iterator.

Map = 1#

map iterator.

Mapfold = 3#

mapfold iterator.

Mapfoldi = 6#

mapfoldi iterator.

Mapi = 4#

mapi iterator.

Activate#

class ansys.scadeone.core.swan.ActivateEvery(operator: OperatorBase, condition: Expression, is_last: bool, expr: Expression)#

Bases: OperatorExpression

Higher-order activate expression: activate operator every expr (( last**| **default )) expr.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property condition: Expression#

Activation condition.

property expr: Expression#

Activation default/last expression.

property is_last: bool#

Returns true when last is set, false when default is set.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property operator: OperatorBase#

Operator under activation.

property owner: Self#

Owner of current Swan construct.

Restart#

class ansys.scadeone.core.swan.Restart(operator: OperatorBase, condition: Expression)#

Bases: OperatorExpression

Higher-order restart expression: restart operator every expr.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property condition: Expression#

Activation condition.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property operator: OperatorBase#

Operator under activation.

property owner: Self#

Owner of current Swan construct.

Partial operator instance#

class ansys.scadeone.core.swan.Partial(operator: OperatorBase, partial_group: List[OptGroupItem])#

Bases: OperatorExpression

Partial operator expression: operator partial_group.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property operator: OperatorBase#

Called operator.

property owner: Self#

Owner of current Swan construct.

property partial_group: List[OptGroupItem]#

Returns the partial group items.

class ansys.scadeone.core.swan.OptGroupItem(item: GroupItem | None = None)#

Bases: SwanItem

Optional group item: opt_group_item ::= _ | group_item.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property is_underscore: bool#

True when group item is ‘_’.

property item: GroupItem | None#

Returns the group item, either a GroupItem or None.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

N-ary operator instance#

N-ary operator instances are implemented as specific expressions. See N-ary expressions section.

Operator Expressions#

class ansys.scadeone.core.swan.OperatorExpression#

Bases: SwanItem, ABC

Base class for op_expr.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.PrefixOperatorExpression(op_expr: OperatorExpression, sizes: List[Expression])#

Bases: OperatorBase

Call to op_expr: operator ::= (op_expr) [[sizes]].

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str(op_str: str) str#

Returns op_str [<<sizes>>].

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property op_expr: OperatorExpression#

Operator expression.

property owner: Self#

Owner of current Swan construct.

property sizes: List[Expression]#

Size parameters of call.

This class is used when an operator expression is syntactically incorrect and was protected by the serialization process.

class ansys.scadeone.core.swan.ProtectedOpExpr(data: str, markup: str)#

Bases: OperatorExpression, ProtectedItem

Protected operator expression, i.e., saved as string if syntactically incorrect.

get_full_path() str#

Full path of Swan construct.

has_markup(markup: str) bool#

Check if protected data has the specified markup.

Parameters:
markupstr

String markup.

Returns:
result: bool

True when instance markup is same as parameter.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property data: str#

Protected data between markups.

Returns:
str

Protected data.

property is_protected#

Tell if item is syntactically protected and provided as a string.

property markup: str#

Protection markup.

Returns:
str

Markup string.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.