Skip to content

Commit 80a21e7

Browse files
authored
Merge pull request numpy#25956 from eendebakpt/polynomial_tests2
Draft: [BUG] Fix Polynomial representation tests
2 parents b3bbdc9 + baa4bc5 commit 80a21e7

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

numpy/polynomial/tests/test_printing.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def use_unicode(self):
2323
"11.0·x¹¹")),
2424
))
2525
def test_polynomial_str(self, inp, tgt):
26-
res = str(poly.Polynomial(inp))
26+
p = poly.Polynomial(inp)
27+
res = str(p)
2728
assert_equal(res, tgt)
2829

2930
@pytest.mark.parametrize(('inp', 'tgt'), (
@@ -82,6 +83,14 @@ def test_laguerre_str(self, inp, tgt):
8283
res = str(poly.Laguerre(inp))
8384
assert_equal(res, tgt)
8485

86+
def test_polynomial_str_domains(self):
87+
res = str(poly.Polynomial([0, 1]))
88+
tgt = '0.0 + 1.0·x'
89+
assert_equal(res, tgt)
90+
91+
res = str(poly.Polynomial([0, 1], domain=[1, 2]))
92+
tgt = '0.0 + 1.0·(-3.0 + 2.0x)'
93+
assert_equal(res, tgt)
8594

8695
class TestStrAscii:
8796

@@ -160,6 +169,14 @@ def test_laguerre_str(self, inp, tgt):
160169
res = str(poly.Laguerre(inp))
161170
assert_equal(res, tgt)
162171

172+
def test_polynomial_str_domains(self):
173+
res = str(poly.Polynomial([0, 1]))
174+
tgt = '0.0 + 1.0 x'
175+
assert_equal(res, tgt)
176+
177+
res = str(poly.Polynomial([0, 1], domain=[1, 2]))
178+
tgt = '0.0 + 1.0 (-3.0 + 2.0x)'
179+
assert_equal(res, tgt)
163180

164181
class TestLinebreaking:
165182

@@ -323,17 +340,6 @@ def test_symbol(poly, tgt):
323340
assert_equal(f"{p:unicode}", tgt)
324341

325342

326-
class TestStr:
327-
def test_polynomial_str(self):
328-
res = str(poly.Polynomial([0, 1]))
329-
tgt = '0.0 + 1.0 x'
330-
assert_equal(res, tgt)
331-
332-
res = str(poly.Polynomial([0, 1], domain=[0, 2]))
333-
tgt = '0.0 + 1.0 (-1.0 + x)'
334-
assert_equal(res, tgt)
335-
336-
337343
class TestRepr:
338344
def test_polynomial_repr(self):
339345
res = repr(poly.Polynomial([0, 1]))

0 commit comments

Comments
 (0)