Skip to content

unary2

unary2

unary2 module contain classes wrapping unary operations within macro.

UnaryOperator2

Bases: Expression2

Single binary operation.

Source code in src/pygerber/gerberx3/parser2/macro2/expressions2/unary2.py
class UnaryOperator2(Expression2):
    """Single binary operation."""

    op: Expression2

Negation2

Bases: UnaryOperator2

Unary minus operation.

Source code in src/pygerber/gerberx3/parser2/macro2/expressions2/unary2.py
class Negation2(UnaryOperator2):
    """Unary minus operation."""

    def on_parser2_eval_expression(self, context: Parser2Context) -> Decimal:
        """Reduce expression to numerical value."""
        return -self.op.on_parser2_eval_expression(context)

on_parser2_eval_expression

on_parser2_eval_expression(
    context: Parser2Context,
) -> Decimal

Reduce expression to numerical value.

Source code in src/pygerber/gerberx3/parser2/macro2/expressions2/unary2.py
def on_parser2_eval_expression(self, context: Parser2Context) -> Decimal:
    """Reduce expression to numerical value."""
    return -self.op.on_parser2_eval_expression(context)

Positive2

Bases: UnaryOperator2

Unary plus operation.

Source code in src/pygerber/gerberx3/parser2/macro2/expressions2/unary2.py
class Positive2(UnaryOperator2):
    """Unary plus operation."""

    def on_parser2_eval_expression(self, context: Parser2Context) -> Decimal:
        """Reduce expression to numerical value."""
        return self.op.on_parser2_eval_expression(context)

on_parser2_eval_expression

on_parser2_eval_expression(
    context: Parser2Context,
) -> Decimal

Reduce expression to numerical value.

Source code in src/pygerber/gerberx3/parser2/macro2/expressions2/unary2.py
def on_parser2_eval_expression(self, context: Parser2Context) -> Decimal:
    """Reduce expression to numerical value."""
    return self.op.on_parser2_eval_expression(context)