picometer.instructions

Picometer routine file in a yaml file that contains a list of settings and instructions to be sequentially executed by the parser. In accordance with the yaml format, the file can comprise several “yaml files” / “picometer routines” seperated by ” —“. However, these “files”/”routines” are ultimately concatenated and converted into a list of instructions.

Attributes

logger

Classes

Instruction

An individual atomic instruction to be processed by the processor

Routine

A queue of subsequent `Instruction`s to be executed by the processor.

ProcessorProtocol

Base class for protocol classes.

BaseInstructionHandlerType

Metaclass that automatically registers new handlers in REGISTRY

BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

LoadInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

SelectInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

RecenterInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

GroupInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

CentroidInstructionHandler

Handlers that handle model states independently and exhausts selection

LineInstructionHandler

Handlers that handle model states independently and exhausts selection

PlaneInstructionsHandler

Handlers that handle model states independently and exhausts selection

CoordinatesInstructionHandler

Handlers that handle model states independently and exhausts selection

DisplacementInstructionHandler

Handlers that handle model states independently and exhausts selection

DistanceInstructionHandler

Handlers that handle model states independently and exhausts selection

AngleInstructionHandler

Handlers that handle model states independently and exhausts selection

DihedralInstructionHandler

Handlers that handle model states independently and exhausts selection

WriteInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

ClearInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

SetInstructionHandler

Base InstructionHandler class to be used for managing all instructions.

Module Contents

picometer.instructions.logger
class picometer.instructions.Instruction(raw_instruction: dict | str = None, /, **kwargs)[source]

An individual atomic instruction to be processed by the processor

keyword: str
raw_kwargs: str | dict[str, Any]
__eq__(other)[source]
__repr__() str[source]
property handler: type
property kwargs: dict[str, Any]
as_dict() dict[str:Union[str, dict]][source]
class picometer.instructions.Routine[source]

Bases: collections.deque[Instruction]

A queue of subsequent `Instruction`s to be executed by the processor. It can be created either in a single step from an input file, or by iteratively right-appending individual instructions.

classmethod concatenate(routines: list[Routine])[source]
classmethod from_dict(dict_: dict) Routine[source]
classmethod from_string(text: str) Routine[source]
classmethod from_yaml(path: str | pathlib.Path) Routine[source]
as_dict() dict[str, list[dict]][source]
to_yaml(path: str | pathlib.Path) None[source]
class picometer.instructions.ProcessorProtocol[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
evaluation_table: pandas.DataFrame
history: Routine
model_states: picometer.models.ModelStates
selection: list[picometer.atom.Locator]
settings: dict[str, Any]
class picometer.instructions.BaseInstructionHandlerType[source]

Bases: type

Metaclass that automatically registers new handlers in REGISTRY

REGISTRY
class picometer.instructions.BaseInstructionHandler(processor: ProcessorProtocol)[source]

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name: str = None
kwargs: dict[str:type] = None
abstract handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

processor
clear_selection()[source]
clear_selection_after_use() None[source]
class picometer.instructions.SerialInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Handlers that handle model states independently and exhausts selection

handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

abstract handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

_collect_shapes(ms: picometer.models.ModelState) list[picometer.shapes.ExplicitShape][source]
class picometer.instructions.LoadInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name = 'load'
kwargs
handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

_load_model_state(cif_path, block_name)[source]
class picometer.instructions.SelectInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name = 'select'
kwargs
handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

class picometer.instructions.RecenterInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name = 'recenter'
kwargs
handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

class picometer.instructions.GroupInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name = 'group'
kwargs
handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

class picometer.instructions.CentroidInstructionHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'centroid'
kwargs
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.LineInstructionHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'line'
kwargs
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.PlaneInstructionsHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'plane'
kwargs
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.CoordinatesInstructionHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'coordinates'
kwargs = None
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.DisplacementInstructionHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'displacement'
kwargs = None
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.DistanceInstructionHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'distance'
kwargs
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.AngleInstructionHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'angle'
kwargs
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.DihedralInstructionHandler(processor: ProcessorProtocol)[source]

Bases: SerialInstructionHandler

Handlers that handle model states independently and exhausts selection

name = 'dihedral'
kwargs
handle_one(instruction: Instruction, ms_key: str, ms: picometer.models.ModelState) None[source]

Abstract function to handle a process a single model state

class picometer.instructions.WriteInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name = 'write'
kwargs
handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

class picometer.instructions.ClearInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name = 'clear'
kwargs
handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction

class picometer.instructions.SetInstructionHandler(processor: ProcessorProtocol)[source]

Bases: BaseInstructionHandler

Base InstructionHandler class to be used for managing all instructions. Must define the following attributes and methods: - name: if given, auto-registers handler in the REGISTRY - kwargs: if given, auto-converts string arguments into dict - handle(): the method called be processor to handle instruction

name = 'set'
kwargs = None
handle(instruction: Instruction) None[source]

Alter the state of the processor according to the instruction