Array#

The following table lists all array operations. Operations are indicated with respect to the syntax given in the Scade One documentation.

Array operations#

Operation

Class

^ (Repetition)

ArrayRepetition

@ (Concatenation)

See Binary expressions and N-ary expressions

[_] (Array constructor)

ArrayConstructor

.[i] (Projection)

ArrayProjection

.[_] default _ (Projection with default)

ProjectionWithDefault

flatten

See Other Array Operations

reverse

See Other Array Operations

_[i..j] (Slice)

Slice

transpose

See Other Array Operations

_ with[_] (Functional update)

See Functional update

pack

See Other Array Operations

../../../_images/array_operations.svg

Array operations#

class ansys.scadeone.core.swan.ArrayRepetition(expr: Expression, size: Expression)#

Bases: Expression

Array expression: expr ^ 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#

Expression.

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 size: Expression#

Array size.

class ansys.scadeone.core.swan.ArrayConstructor(group: Group)#

Bases: Expression

Array construction expression: [ 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 group: Group#

Group items as a Group.

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.ArrayProjection(expr: Expression, index: Expression)#

Bases: Expression

Static projection: expr [index], where index is a static expression.

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#

Expression.

property index: Expression#

Index expression.

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.Slice(expr: Expression, start: Expression, end: Expression)#

Bases: Expression

Slice expression: expr [ expr .. 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 end: Expression#

End of slice expression.

property expr: Expression#

Expression.

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 start: Expression#

Start of slice expression.

class ansys.scadeone.core.swan.ProjectionWithDefault(expr: Expression, indices: List[LabelOrIndex], default: Expression)#

Bases: Expression

Dynamic projection: (expr . {{ label_or_index }}+ 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 default: Expression#

Default value.

property expr: Expression#

Expression.

property indices: List[LabelOrIndex]#

List of indices.

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.

Other array operations#

Arrays support the flatten, reverse, pack, and transpose operations.

Operations are implemented by the PrefixPrimitive with an enumeration to select the proper operation.

transpose is associated with the Transpose (derives from PrefixPrimitive) to handle the operation parameters.

class ansys.scadeone.core.swan.PrefixPrimitive(kind: PrefixPrimitiveKind, sizes: List[Expression])#

Bases: OperatorBase

Call to primitive operator: operator ::= prefix_primitive [[sizes]] with prefix_primitive: flatten, pack, reverse, operators.

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 kind: PrefixPrimitiveKind#

Primitive 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 owner: Self#

Owner of current Swan construct.

property sizes: List[Expression]#

Size parameters of call.

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

Bases: Enum

Prefix primitive kind: reverse, transpose, pack, and flatten.

Flatten = 1#

flatten array operation.

Pack = 2#

pack array operation.

Reverse = 3#

reverse array operation.

Transpose = 4#

transpose array operation.

class ansys.scadeone.core.swan.Transpose(params: List[int] | str, sizes: List[Expression])#

Bases: PrefixPrimitive

Transpose operator.

Parameters are a list of integer, but could be a single string if the indices are syntactically incorrect.

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 kind: PrefixPrimitiveKind#

Primitive 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 owner: Self#

Owner of current Swan construct.

property params: List[str]#

Transpose indices a list of str.

property sizes: List[Expression]#

Size parameters of call.