Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
blattm committed Oct 26, 2023
1 parent 8a172ee commit e29ea08
Showing 1 changed file with 5 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,17 @@ class CollapseAddNeg(SimplificationRule):
def apply(self, operation: Operation) -> list[tuple[Expression, Expression]]:
replacement: Optional[Expression] = None
match operation:
case BinaryOperation(
operation=OperationType.plus,
left=e0,
right=UnaryOperation(
operation=OperationType.negate,
operand=e1
)
):
case BinaryOperation(operation=OperationType.plus, left=e0, right=UnaryOperation(operation=OperationType.negate, operand=e1)):
replacement = BinaryOperation(OperationType.minus, [e0, e1], operation.type)

case BinaryOperation(
operation=OperationType.minus,
left=e0,
right=UnaryOperation(
operation=OperationType.negate,
operand=e1
)
):
case BinaryOperation(operation=OperationType.minus, left=e0, right=UnaryOperation(operation=OperationType.negate, operand=e1)):
replacement = BinaryOperation(OperationType.plus, [e0, e1], operation.type)

case BinaryOperation(
operation=OperationType.plus,
left=UnaryOperation(
operation=OperationType.negate,
operand=e0
),
right=e1
):
case BinaryOperation(operation=OperationType.plus, left=UnaryOperation(operation=OperationType.negate, operand=e0), right=e1):
replacement = BinaryOperation(OperationType.minus, [e1, e0], operation.type)

case BinaryOperation(
operation=OperationType.minus,
left=UnaryOperation(
operation=OperationType.negate,
operand=e0
),
right=e1
):
replacement = UnaryOperation(
OperationType.negate,
[BinaryOperation(OperationType.plus, [e0, e1], operation.type)]
)
case BinaryOperation(operation=OperationType.minus, left=UnaryOperation(operation=OperationType.negate, operand=e0), right=e1):
replacement = UnaryOperation(OperationType.negate, [BinaryOperation(OperationType.plus, [e0, e1], operation.type)])

if replacement is None:
return []
Expand Down

0 comments on commit e29ea08

Please sign in to comment.