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.

is_implemented: bool = True
n_attributes: int | range | Collection = (1, 2)
__init__(line: list[str], dat_idx: int, **kwargs: str) None

Save lattice structure.

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.

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

Set lattice section number of elements in current lattice.

_current_section_number(instructions: list[Instruction]) int

Get section number of self.

_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.

_abc_impl = <_abc._abc_data object at 0x7fd3cfa4d680>
class LatticeEnd(line: list[str], dat_idx: int, **kwargs: str)

Bases: Command

Define the end of lattice.

is_implemented: bool = True
n_attributes: int | range | Collection = 0
__init__(line: list[str], dat_idx: int, **kwargs: str) None

Call mother __init__ method.

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.

_abc_impl = <_abc._abc_data object at 0x7fd3ce724280>
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…