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 @@ -672,7 +672,7 @@ def __init__(self, coeffs, domain):
if len(coeffs) == 0:
raise ValueError("Parameter coeffs must have at least 1 element")

if len(coeffs) == 1:
if isinstance(coeffs, list) or len(coeffs) == 1:
self._num_coeffs = tuple(coeffs)
self._den_coeffs = tuple([1])
else:
Expand Down
20 changes: 20 additions & 0 deletions blueprint/src/python/tests/test_polynomial_input_regression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from functions import Interval, RationalFunction2


def test_multi_coefficient_polynomial_input():
function = RationalFunction2([1, 2, 3], Interval(0, 1))
assert function._num_coeffs == (1, 2, 3)
assert function._den_coeffs == (1,)
assert str(function) == "x^2 + 2x + 3 on [0,1)"


def test_rational_pair_input_unchanged():
function = RationalFunction2(([1, 2], [3, 4]), Interval(0, 1))
assert function._num_coeffs == (1, 2)
assert function._den_coeffs == (3, 4)


def test_single_coefficient_input_unchanged():
function = RationalFunction2([2], Interval(0, 1))
assert function._num_coeffs == (2,)
assert function._den_coeffs == (1,)
Loading