bluemira.codes.params ===================== .. py:module:: bluemira.codes.params .. autoapi-nested-parse:: Base classes for external parameter management. Classes ------- .. autoapisummary:: bluemira.codes.params.MappedParameterFrame bluemira.codes.params.ParameterMapping Module Contents --------------- .. py:class:: MappedParameterFrame Bases: :py:obj:`bluemira.base.parameter_frame.ParameterFrame` .. autoapi-inheritance-diagram:: bluemira.codes.params.MappedParameterFrame :parts: 1 :private-bases: Special ``ParameterFrame`` that contains a set of parameter mappings. The mappings are intended to be used to map bluemira parameters to parameters in an external code. See :class:`~bluemira.base.parameter_frame.ParameterFrame` for details on how to declare parameters. .. py:method:: __post_init__() Ensure mappings are as immutable as we can manage .. py:property:: defaults :type: dict :abstractmethod: Default values for the ParameterFrame .. py:method:: from_defaults(data: dict, source: str = 'bluemira codes default') -> MappedParameterFrame :classmethod: Create ParameterFrame with default values for external codes. External codes are likely to have variables that are not changed often therefore in some cases sane defaults are needed. If a default value is not found for a given mapping it is set to NaN :returns: The parameter frame .. py:property:: mappings :type: dict[str, ParameterMapping] :abstractmethod: The mappings associated with these frame's parameters. The keys are names of parameters in this frame, the values are ``ParameterMapping`` objects containing the name of the corresponding parameter in some external code. .. py:method:: update_mappings(new_send_recv: dict[str, dict[Literal['send', 'recv'], bool]]) Update the mappings in this frame with new send/recv values. :param new_send_recv: The new send/recv values for all, or a subset, of the parameter mappings. Keys are parameter names (as defined in this class, not the external code), the values are a dictionary, optionally containing keys 'send' and/or 'recv'. The values for the inner dictionary are a boolean. :raises CodesError: If a parameter name in the input does not match the name of a parameter in this frame. .. py:class:: ParameterMapping Simple class containing information on mapping of a bluemira parameter to one in external software. :param name: name of mapped parameter :param recv: receive data from mapped parameter (to overwrite bluemira parameter) :param send: send data to mapped parameter (from bluemira parameter) .. py:attribute:: name :type: str .. py:attribute:: out_name :type: str | None :value: None .. py:attribute:: send :type: bool :value: True .. py:attribute:: recv :type: bool :value: True .. py:attribute:: unit :type: str | None :value: None .. py:attribute:: _frozen :value: () .. py:method:: __post_init__() Freeze the dataclass .. py:method:: to_dict() -> dict Convert this object to a dictionary with attributes as values. .. py:method:: from_dict(the_dict: dict) -> ParameterMapping :classmethod: Create a ParameterMapping using a dictionary with attributes as values. .. py:method:: __str__() Create a string representation of of this object which is more compact than that provided by the default `__repr__` method. .. py:method:: __setattr__(attr: str, value: bool | str) Protect against additional attributes :param attr: Attribute to set (name can only be set on init) :param value: Value of attribute :raises KeyError: Cannot set attribute :raises ValueError: Attribute must be a boolean