Skip to content

Commit

Permalink
chore: fix lint from inadequate typing
Browse files Browse the repository at this point in the history
  • Loading branch information
justindujardin committed Feb 5, 2024
1 parent f1b5bc2 commit ecd8232
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions mathy_core/rules/multiplicative_inverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ def apply_to(self, node: MathExpression) -> ExpressionChangeRule:
assert tree_type is not None, "call can_apply_to before applying a rule"
change.save_parent() # connect result to node.parent

# Handle the division based on the tree type
if tree_type == _OP_DIVISION_EXPRESSION:
result = MultiplyExpression(
node.left.clone(),
DivideExpression(ConstantExpression(1), node.right.clone()),
)
assert node.left is not None, "Division must have a left child"
assert node.right is not None, "Division must have a right child"

elif tree_type == _OP_DIVISION_NEGATIVE_DENOMINATOR:
if tree_type == _OP_DIVISION_NEGATIVE_DENOMINATOR:
# For division by a negative denominator, negate the numerator and use the positive reciprocal
assert isinstance(
node.right, NegateExpression
), "Right child must be a NegateExpression"
child = node.right.get_child()
assert child is not None, "NegateExpression must have a child"
result = MultiplyExpression(
node.left.clone(),
DivideExpression(
ConstantExpression(-1), node.right.get_child().clone()
),
DivideExpression(ConstantExpression(-1), child.clone()),
)

# Handle the division based on the tree type
else:
raise NotImplementedError(
"Unsupported tree configuration for MultiplicativeInverseRule"
result = MultiplyExpression(
node.left.clone(),
DivideExpression(ConstantExpression(1), node.right.clone()),
)

result.set_changed() # mark this node as changed for visualization
Expand Down

0 comments on commit ecd8232

Please sign in to comment.