Skip to content

operators

operators #

Boolean and numeric operators bound onto Procedure.

Each is a shorthand for constructing the matching operator node (BoolNot, BoolAnd, NumberLessThan, …) exactly as building it by hand would. They are imported into the Procedure class body, so the node imports are lazy.

__and__(self, other) #

a & b — a BoolAnd node.

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/operators.py
def __and__(
    self: Procedure[Bool],
    other: Procedure[Bool],
) -> Procedure[Bool]:
    """``a & b`` — a ``BoolAnd`` node."""
    from capturegraph.procedures.nodes.process.operators.boolean import BoolAnd

    return BoolAnd(
        left=self,
        right=other,
    )

__ge__(self, other) #

a >= bBoolNot(NumberLessThan(a, b)).

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/operators.py
def __ge__(
    self: Procedure[Number],
    other: Procedure[Number],
) -> Procedure[Bool]:
    """``a >= b`` — ``BoolNot(NumberLessThan(a, b))``."""
    return ~(self < other)

__gt__(self, other) #

a > bNumberLessThan with the operands swapped.

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/operators.py
def __gt__(
    self: Procedure[Number],
    other: Procedure[Number],
) -> Procedure[Bool]:
    """``a > b`` — ``NumberLessThan`` with the operands swapped."""
    return other < self

__invert__(self) #

~a — a BoolNot node.

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/operators.py
def __invert__(self: Procedure[Bool]) -> Procedure[Bool]:
    """``~a`` — a ``BoolNot`` node."""
    from capturegraph.procedures.nodes.process.operators.boolean import BoolNot

    return BoolNot(value=self)

__le__(self, other) #

a <= bBoolNot(NumberLessThan(b, a)).

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/operators.py
def __le__(
    self: Procedure[Number],
    other: Procedure[Number],
) -> Procedure[Bool]:
    """``a <= b`` — ``BoolNot(NumberLessThan(b, a))``."""
    return ~(other < self)

__lt__(self, other) #

a < b — a NumberLessThan node.

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/operators.py
def __lt__(
    self: Procedure[Number],
    other: Procedure[Number],
) -> Procedure[Bool]:
    """``a < b`` — a ``NumberLessThan`` node."""
    from capturegraph.procedures.nodes.process.operators.number import (
        NumberLessThan,
    )

    return NumberLessThan(
        left=self,
        right=other,
    )

__or__(self, other) #

a | b — a BoolOr node.

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/operators.py
def __or__(
    self: Procedure[Bool],
    other: Procedure[Bool],
) -> Procedure[Bool]:
    """``a | b`` — a ``BoolOr`` node."""
    from capturegraph.procedures.nodes.process.operators.boolean import BoolOr

    return BoolOr(
        left=self,
        right=other,
    )