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

Factorial notation parsing doesn't work #25809

Closed
ghost opened this issue Oct 20, 2023 · 1 comment
Closed

Factorial notation parsing doesn't work #25809

ghost opened this issue Oct 20, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 20, 2023

I have been trying to use the SymPy parsing for factorial notation but it keeps throwing the invalid syntax error when I use the "!" (standard factorial symbol), however, using the factorial() method works, but I would like to be able to use the symbol

I attach my code in case you want to check, I think I imported everything correctly though

from sympy import parse_expr
from sympy.parsing.sympy_parser import standard_transformations,implicit_multiplication_application,convert_xor,factorial_notation


opt =  input("Ingresa la operacion")
transformations = (standard_transformations + (implicit_multiplication_application,convert_xor,factorial_notation))
res = parse_expr(opt, transformations=transformations)
print(res)

The stack trace:

ValueError: Error from parse_expr with transformed code: 'Integer (5 )!'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\tenesiss\Downloads\calc.py", line 8, in <module>
    res = parse_expr(opt, transformations=transformations)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tenesiss\AppData\Local\Programs\Python\Python312\Lib\site-packages\sympy\parsing\sympy_parser.py", line 1087, in parse_expr
    raise e from ValueError(f"Error from parse_expr with transformed code: {code!r}")
  File "C:\Users\tenesiss\AppData\Local\Programs\Python\Python312\Lib\site-packages\sympy\parsing\sympy_parser.py", line 1078, in parse_expr
    rv = eval_expr(code, local_dict, global_dict)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tenesiss\AppData\Local\Programs\Python\Python312\Lib\site-packages\sympy\parsing\sympy_parser.py", line 906, in eval_expr
    expr = eval(
           ^^^^^
  File "<string>", line 1
    Integer (5 )!
                ^
SyntaxError: invalid syntax

I'm using SymPy v1.12

@ghost
Copy link
Author

ghost commented Oct 20, 2023

It was a problem with the version installed by pip, I cloned from the git and worked correctly.

@ghost ghost closed this as completed Oct 20, 2023
This issue was closed.
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

0 participants