From 241e9e33e559f175925af1cc1eac03056f64954e Mon Sep 17 00:00:00 2001 From: Abhishek Patidar <2311abhiptdr@gmail.com> Date: Sat, 17 Dec 2022 13:24:40 +0530 Subject: [PATCH 1/2] fixes # 24395 --- sympy/polys/rings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sympy/polys/rings.py b/sympy/polys/rings.py index be444ac7bf85..58042a9d1758 100644 --- a/sympy/polys/rings.py +++ b/sympy/polys/rings.py @@ -1172,7 +1172,7 @@ def __pow__(self, n): elif len(self) == 1: monom, coeff = list(self.items())[0] p = ring.zero - if coeff == 1: + if coeff == ring.domain.one: p[ring.monomial_pow(monom, n)] = coeff else: p[ring.monomial_pow(monom, n)] = coeff**n From de3daa871de967e1838c6f2b157cacc8b5ca0520 Mon Sep 17 00:00:00 2001 From: Abhishek Patidar <2311abhiptdr@gmail.com> Date: Tue, 20 Dec 2022 23:27:14 +0530 Subject: [PATCH 2/2] Add tests --- sympy/polys/tests/test_ring_series.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sympy/polys/tests/test_ring_series.py b/sympy/polys/tests/test_ring_series.py index 4bb397779a60..0f70c05d3888 100644 --- a/sympy/polys/tests/test_ring_series.py +++ b/sympy/polys/tests/test_ring_series.py @@ -518,6 +518,18 @@ def test_puiseux(): assert r == -x**QQ(9,5) - x**QQ(26,15) - x**QQ(22,15) - x**QQ(6,5)/3 + \ x + x**QQ(2,3) + x**QQ(2,5) +def test_puiseux_algebraic(): # https://github.com/sympy/sympy/issues/24395 + + K = QQ.algebraic_field(sqrt(2)) + sqrt2 = K.from_sympy(sqrt(2)) + x, y = symbols('x, y') + R, xr, yr = ring([x, y], K) + p = (1+sqrt2)*xr**QQ(1,2) + (1-sqrt2)*yr**QQ(2,3) + + assert dict(p) == {(QQ(1,2),QQ(0)):1+sqrt2, (QQ(0),QQ(2,3)):1-sqrt2} + assert p.as_expr() == (1 + sqrt(2))*x**(S(1)/2) + (1 - sqrt(2))*y**(S(2)/3) + + def test1(): R, x = ring('x', QQ) r = rs_sin(x, x, 15)*x**(-5)