Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blueprint/src/python/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ def __add__(self, other):
return self.add(other)

def __sub__(self, other):
return self.sub(other)
return self.subtract(other)

def __mul__(self, other):
return self.mul(other)
Expand Down
1 change: 1 addition & 0 deletions blueprint/src/python/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import test_rationalfunction
import test_rational_roots_regression
import test_rational_subtraction

print("All RationalFunction test cases passed.")

Expand Down
17 changes: 17 additions & 0 deletions blueprint/src/python/tests/test_rational_subtraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from fractions import Fraction

from functions import RationalFunction


def test_subtraction_operator():
f = RationalFunction([1, 1], [1, 2])
g = RationalFunction([2, 1], [1, 3])
for other in (g, 2, Fraction(1, 3)):
result = f - other
for x in (Fraction(0), Fraction(1), Fraction(3, 2)):
expected = f.at(x) - (other.at(x) if isinstance(other, RationalFunction) else other)
assert result.at(x) == expected
assert (f - f).at(Fraction(1)) == 0


test_subtraction_operator()
Loading