mbdlyb.functional.operating_mode ================================ .. py:module:: mbdlyb.functional.operating_mode Classes ------- .. autoapisummary:: mbdlyb.functional.operating_mode.OpmLogic mbdlyb.functional.operating_mode.OpmLogicAnd mbdlyb.functional.operating_mode.OpmLogicOr mbdlyb.functional.operating_mode.OpmSet mbdlyb.functional.operating_mode.OpmVariable Module Contents --------------- .. py:class:: OpmLogic(opm_vars: Optional[list[OpmVariable]] = None) .. py:method:: add(opm_logic: OpmLogic) -> OpmLogic Append a non-empty logic expression as an operand. :param opm_logic: Expression to add. :type opm_logic: OpmLogic :returns: This expression, for method chaining. :rtype: OpmLogic .. py:method:: create(modes: list[str], opm_set: Optional[OpmSet] = None) -> OpmLogicOr :classmethod: Create an OR expression from operating mode names. :param modes: Names of operating modes to include. :type modes: list[str] :param opm_set: Set to associate with each variable. Defaults to None. :type opm_set: Optional[OpmSet] :returns: OR expression containing the requested variables. :rtype: OpmLogicOr .. py:method:: eval(active_modes: list[str]) -> bool Evaluate this expression against the active operating modes. :param active_modes: Names of the currently active modes. :type active_modes: list[str] :returns: Result of applying this expression's logical operation. :rtype: bool .. py:method:: from_copy(other) -> OpmLogic :classmethod: Create a shallow copy of another operating mode logic expression. :param other: Logic expression whose operands are copied. :returns: New expression of the same class with the same operands. :rtype: OpmLogic .. py:method:: unwrap() -> OpmVariable | OpmLogic Remove a redundant expression wrapper when there is one operand. :returns: The sole operand, or this expression if it has zero or multiple operands. :rtype: OpmVariable | OpmLogic .. py:attribute:: logic_function .. py:property:: sets :type: set[OpmSet] Return the non-None sets associated with variables in this expression. :returns: Distinct associated operating mode sets. :rtype: set[OpmSet] .. py:attribute:: var_separator :type: str :value: ', ' .. py:property:: variables :type: list[OpmVariable] Return all variables nested in this expression. :returns: Variables in operand order, including nested expressions. :rtype: list[OpmVariable] .. py:class:: OpmLogicAnd(opm_vars: Optional[list[OpmVariable]] = None) Bases: :py:obj:`OpmLogic` .. py:attribute:: logic_function .. py:attribute:: var_separator :type: str :value: ' & ' .. py:class:: OpmLogicOr(opm_vars: Optional[list[OpmVariable]] = None) Bases: :py:obj:`OpmLogic` .. py:attribute:: logic_function .. py:attribute:: var_separator :type: str :value: ' | ' .. py:class:: OpmSet(variables: Optional[list[str | OpmVariable]] = None) Set of mutually exclusive operating mode variables. An OpmSet represents a group of operating mode variables that are mutually exclusive with each other. Only one variable from the set can be active at any given time. :ivar _variables: List of variables in this set. :vartype _variables: list[OpmVariable] .. py:method:: add_variables(opm_vars: list[str | OpmVariable]) Add variables to this set and associate each variable with it. :param opm_vars: Variable names or variables to add. :type opm_vars: list[str | OpmVariable] :returns: None .. py:method:: contains_variable(var: OpmVariable) -> bool Check whether a variable belongs to this set. :param var: Variable to check. :type var: OpmVariable :returns: Whether the variable is in this set. :rtype: bool .. py:property:: variable_names :type: list[str] Return the names of variables in this set, sorted alphabetically. :returns: Names of the variables. :rtype: list[str] .. py:class:: OpmVariable(name, opm_set: Optional[OpmSet] = None) .. py:method:: eval(active_modes: list[str]) -> bool Evaluate whether this variable is active in the supplied mode selection. A variable evaluates to false when another variable in its set is active; if none from the set are selected, it evaluates to true. :param active_modes: Names of the currently active modes. :type active_modes: list[str] :returns: Whether this variable evaluates as active. :rtype: bool .. py:method:: set_opmset(opm_set: OpmSet) -> None Associate this variable with an operating mode set. :param opm_set: Set to associate with this variable. :type opm_set: OpmSet :returns: None .. py:property:: name :type: str Return this variable's name. :returns: The variable name. :rtype: str .. py:property:: opmset :type: Optional[OpmSet] Return the set associated with this variable, if any. :returns: The associated set, or None if it has not been set. :rtype: Optional[OpmSet]