Skip to content

Data

PortedObjectData(*, metadata, object_data)

Bases: dict

A dictionary holding the information defining a PortedObject instance.

PARAMETER DESCRIPTION
metadata

dictionary storing ported object identifiers including "name" and "type"

TYPE: dict

object_data

dictionary to be passed to ported object constructor

TYPE: dict

Source code in psymple/build/ported_objects.py
def __init__(self, *, metadata: dict, object_data: dict):
    """
    Create a PortedObjectData instance.

    Args:
        metadata: dictionary storing ported object identifiers including `"name"`
            and `"type"`
        object_data: dictionary to be passed to ported object constructor
    """
    self._check_metadata(metadata)
    self._check_object_data(object_data)
    super().__init__(metadata=metadata, object_data=object_data)

to_ported_object(parsing_locals={})

Builds a PortedObject instance from self. The type of PortedObject is read from self.type and must be one of "fpo", "vpo" or "cpo".

PARAMETER DESCRIPTION
parsing_locals

a dictionary mapping strings to sympy objects.

TYPE: dict DEFAULT: {}

RETURNS DESCRIPTION
PortedObject

An instance of (or subclass of) PortedObject formed by passing parsing_locals and **self.object_data to the constructor indicated by self.type.

TYPE: PortedObject

Source code in psymple/build/ported_objects.py
def to_ported_object(self, parsing_locals: dict = {}) -> PortedObject:
    """
    Builds a [`PortedObject`][psymple.build.abstract.PortedObject] instance from self.
    The type of `PortedObject` is read from `self.type` and must be one of `"fpo"`, `"vpo"` or `"cpo"`.

    Args:
        parsing_locals: a dictionary mapping strings to `sympy` objects.

    Returns:
        PortedObject: An instance of (or subclass of) `PortedObject` formed by
            passing `parsing_locals` and `**self.object_data` to the constructor indicated by
            `self.type`.
    """
    PORTED_OBJECT_TYPES = {
        "fpo": FunctionalPortedObject,
        "vpo": VariablePortedObject,
        "cpo": CompositePortedObject,
    }
    name = self.name
    type = self.type
    data = self.data
    ported_object = PORTED_OBJECT_TYPES[type]
    return ported_object(name=name, parsing_locals=parsing_locals, **data)