← All challenges
easysympy/sympy · v1.9

detection of infinite solution request

Try this bug with AI

Fix it in the original repo with an AI agent and get feedback on how you worked.

2 free rounds each week

Round mode
  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to135 XP
Sign up or sign in to start

Read the sample report

From a simulated Django round

You changed code before reproducing the bug.

Run the failing test before the first edit, so you know the failure you are fixing and can tell when it is gone.

Problem statement
python
>>> solve_poly_system((x - 1,), x, y)
Traceback (most recent call last):
...
NotImplementedError:
only zero-dimensional systems supported (finite number of solutions)
>>> solve_poly_system((y - 1,), x, y)  <--- this is not handled correctly
[(1,)]
diff
diff --git a/sympy/solvers/polysys.py b/sympy/solvers/polysys.py
index b9809fd4e9..674322d4eb 100644
--- a/sympy/solvers/polysys.py
+++ b/sympy/solvers/polysys.py
@@ -240,7 +240,7 @@ def _solve_reduced_system(system, gens, entry=False):
 
         univariate = list(filter(_is_univariate, basis))
 
-        if len(univariate) == 1:
+        if len(univariate) == 1 and len(gens) == 1:
             f = univariate.pop()
         else:
             raise NotImplementedError(filldedent('''
diff --git a/sympy/solvers/tests/test_polysys.py b/sympy/solvers/tests/test_polysys.py
index 58419f8762..9e674a6fe6 100644
--- a/sympy/solvers/tests/test_polysys.py
+++ b/sympy/solvers/tests/test_polysys.py
@@ -48,6 +48,10 @@ def test_solve_poly_system():
     raises(NotImplementedError, lambda: solve_poly_system(
         [z, -2*x*y**2 + x + y**2*z, y**2*(-z - 4) + 2]))
     raises(PolynomialError, lambda: solve_poly_system([1/x], x))
+    raises(NotImplementedError, lambda: solve_poly_system(
+        Poly(x - 1, x, y), (x, y)))
+    raises(NotImplementedError, lambda: solve_poly_system(
+        Poly(y - 1, x, y), (x, y)))
 
 
 def test_solve_biquadratic():
The environment starts at commit 2c83657ff1c6 (sympy/sympy 1.9), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.