Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surprising error message with Poly('a-a') #25899

Closed
georgesk opened this issue Nov 12, 2023 · 1 comment
Closed

surprising error message with Poly('a-a') #25899

georgesk opened this issue Nov 12, 2023 · 1 comment

Comments

@georgesk
Copy link
Contributor

Hello, I hereby forward a bug report raised by "Kingsley G. Morse Jr." kingsley@loaner.com, which was sent to the Debian bug tracking system (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1052596)

Here is a minimal example to trigger the error message within ipython3's shell:

In [1]: from sympy import Poly

In [2]: Poly('a-a')
---------------------------------------------------------------------------
GeneratorsNeeded                          Traceback (most recent call last)
Cell In[2], line 1
----> 1 Poly('a-a')

File /usr/lib/python3/dist-packages/sympy/polys/polytools.py:182, in Poly.__new__(cls, rep, *gens, **args)
    180     return cls._from_poly(rep, opt)
    181 else:
--> 182     return cls._from_expr(rep, opt)

File /usr/lib/python3/dist-packages/sympy/polys/polytools.py:312, in Poly._from_expr(cls, rep, opt)
    310 """Construct a polynomial from an expression. """
    311 rep, opt = _dict_from_expr(rep, opt)
--> 312 return cls._from_dict(rep, opt)

File /usr/lib/python3/dist-packages/sympy/polys/polytools.py:249, in Poly._from_dict(cls, rep, opt)
    246 gens = opt.gens
    248 if not gens:
--> 249     raise GeneratorsNeeded(
    250         "Cannot initialize from 'dict' without generators")
    252 level = len(gens) - 1
    253 domain = opt.domain

GeneratorsNeeded: Cannot initialize from 'dict' without generators

In [3]: p = Poly('a')

In [4]: p-p
Out[4]: Poly(0, a, domain='ZZ')

Best regards, Georges.

@smichr
Copy link
Member

smichr commented Nov 12, 2023

When 'a-a' is parsed, the result is 0 and the history of how it came to be so is lost. It might be possible to sympify with evaluate false and then let Polys handle that expression.

smichr added a commit to smichr/sympy that referenced this issue Nov 12, 2023
skirpichev added a commit to skirpichev/diofant that referenced this issue Nov 13, 2023
skirpichev added a commit to skirpichev/diofant that referenced this issue Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants