Skip to content

Context

pd2af.building.context

The shared state of the two build passes.

BuilderContext is a plain dataclass of slots: :func:pd2af.core._build_map creates one, the model pass fills the model and the pass-1 scratch slots, and the layout pass reads them back to build the layout and the layout-model mapping. It lives in its own module so both language builders can name it in their annotations without importing the orchestrator that imports them.

Classes:

Name Description
BuilderContext

The slots the model pass fills and the layout pass reads back.

BuilderContext dataclass

BuilderContext(input_map: object, layout_mode: LayoutMode | None, clingo_id_to_model_element: dict, mode: TransformationMode, influence_pairing: InfluencePairingMode = CROSS, keep_species: bool = False, drop_compartments: bool = False, model: object = None, layout: object = None, layout_model_mapping: object = None, activity_emissions: list = list(), input_model_element_to_canonical_model_element: dict = dict(), compartment_emissions: list = list(), cache: dict = dict(), default_compartment: object = None, subunit_to_top_level: dict = None, activity_atoms: list = list(), influence_atoms: list = list(), key_to_activity: dict = dict(), operator_atoms: list = list(), operator_input_atoms: list = list(), key_to_operator: dict = dict(), operator_emissions: list = list(), model_element_to_layout_elements: dict = dict(), object_to_builder: dict = dict(), synthetic_index: int = 0, input_compartment_to_af_compartment: dict = dict(), af_compartment_to_input_compartment: dict = dict())

The slots the model pass fills and the layout pass reads back.

Parameters:

Name Type Description Default
input_map object
required
layout_mode LayoutMode | None
required
clingo_id_to_model_element dict
required
mode TransformationMode
required
influence_pairing InfluencePairingMode
<InfluencePairingMode.CROSS: 'cross'>
keep_species bool
False
drop_compartments bool
False
model object
None
layout object
None
layout_model_mapping object
None
activity_emissions list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
input_model_element_to_canonical_model_element dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
compartment_emissions list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
cache dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
default_compartment object
None
subunit_to_top_level dict
None
activity_atoms list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
influence_atoms list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
key_to_activity dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
operator_atoms list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
operator_input_atoms list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
key_to_operator dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
operator_emissions list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
model_element_to_layout_elements dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
object_to_builder dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
synthetic_index int
0
input_compartment_to_af_compartment dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
af_compartment_to_input_compartment dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>