core.commands.lattice module

Define LATTICE and LATTICE_END instructions.

class Lattice(line: list[str], dat_idx: int, **kwargs: str)

Bases: Command

Used to get the number of elements per lattice.

__init__(line: list[str], dat_idx: int, **kwargs: str) None

Save lattice structure.

_abc_impl = <_abc._abc_data object>
_current_lattice_number(instructions: list[Instruction], index: int) int

Get lattice number of current object.

We look for Element in instructions in reversed order, starting from self. We take the first non negative lattice index that we find, and return it + 1. If we do not find anything, this is because no Element had a defined lattice number before.

This approach allows for Element without a lattice number, as for examples drifts between a LatticeEnd and a Lattice.

_current_section_number(instructions: list[Instruction]) int

Get section number of self.

apply(instructions: list[Instruction], **kwargs: float) list[Instruction]

Set lattice section number of elements in current lattice.

is_implemented: bool = True
n_attributes: int | range | Collection = (1, 2)
set_influenced_elements(instructions: list[Instruction], **kwargs: float) None

Determine the index of the elements concerned by apply().

Here, this is all the elements between this command and the next LATTICE or LATTICE_END instruction.

class LatticeEnd(line: list[str], dat_idx: int, **kwargs: str)

Bases: Command

Define the end of lattice.

__init__(line: list[str], dat_idx: int, **kwargs: str) None

Call mother __init__ method.

_abc_impl = <_abc._abc_data object>
apply(instructions: list[Instruction], **kwargs: float) list[Instruction]

Reset the lattice index of every influenced element.

Todo

As for now, the effect of this command will be overriden by the _force_a_lattice_for_every_element. See how I should handle this…

is_implemented: bool = True
n_attributes: int | range | Collection = 0
set_influenced_elements(instructions: list[Instruction], **kwargs: float) None

Determine the index of the elements concerned by apply().

Here, this is all the elements that are between this command and the next LATTICE instruction.