Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- sys.path.append('/home/vagrant/.local/lib/python3.4/site-packages')
- from sympy import *
- from sympy.printing.mathml import mathml
- print(mathml(sympify("y=4*x**3+3*x**2+2*x+1"),printer='presentation'))
- print(mathml(sympify("y=a*x**3+b*x**2+c*x+d"),printer='presentation'))
- $ python test001.py
- Traceback (most recent call last):
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/core/sympify.py", line 368, in sympify
- expr = parse_expr(a, local_dict=locals, transformations=transformations, evaluate=evaluate)
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/parsing/sympy_parser.py", line 965, in parse_expr
- return eval_expr(code, local_dict, global_dict)
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/parsing/sympy_parser.py", line 878, in eval_expr
- code, global_dict, local_dict) # take local objects in preference
- File "<string>", line 1
- Symbol ('y' )=Integer (4 )*Symbol ('x' )**Integer (3 )+Integer (3 )*Symbol ('x' )**Integer (2 )+Integer (2 )*Symbol ('x' )+Integer (1 )
- ^
- SyntaxError: invalid syntax
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "test001.py", line 6, in <module>
- print(mathml(sympify("y=4*x**3+3*x**2+2*x+1"),printer='presentation'))
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/core/sympify.py", line 370, in sympify
- raise SympifyError('could not parse %r' % a, exc)
- sympy.core.sympify.SympifyError: Sympify of expression 'could not parse 'y=4*x**3+3*x**2+2*x+1'' failed, because of exception being raised:
- SyntaxError: invalid syntax (<string>, line 1)
- Error in sys.excepthook:
- Traceback (most recent call last):
- File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
- from apport.fileutils import likely_packaged, get_recent_crashes
- File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
- from apport.report import Report
- File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
- import apport.fileutils
- File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
- from apport.packaging_impl import impl as packaging
- File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
- import apt
- File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
- import apt_pkg
- ModuleNotFoundError: No module named 'apt_pkg'
- Original exception was:
- Traceback (most recent call last):
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/core/sympify.py", line 368, in sympify
- expr = parse_expr(a, local_dict=locals, transformations=transformations, evaluate=evaluate)
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/parsing/sympy_parser.py", line 965, in parse_expr
- return eval_expr(code, local_dict, global_dict)
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/parsing/sympy_parser.py", line 878, in eval_expr
- code, global_dict, local_dict) # take local objects in preference
- File "<string>", line 1
- Symbol ('y' )=Integer (4 )*Symbol ('x' )**Integer (3 )+Integer (3 )*Symbol ('x' )**Integer (2 )+Integer (2 )*Symbol ('x' )+Integer (1 )
- ^
- SyntaxError: invalid syntax
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "test001.py", line 6, in <module>
- print(mathml(sympify("y=4*x**3+3*x**2+2*x+1"),printer='presentation'))
- File "/home/vagrant/.local/lib/python3.4/site-packages/sympy/core/sympify.py", line 370, in sympify
- raise SympifyError('could not parse %r' % a, exc)
- sympy.core.sympify.SympifyError: Sympify of expression 'could not parse 'y=4*x**3+3*x**2+2*x+1'' failed, because of exception being raised:
- SyntaxError: invalid syntax (<string>, line 1)
- <mi>y</mi><mo>=</mo><mn>4</mn><mo>⁡<!--FUNCTION APPLICATION--></mo><msup><mi>x</mi><mn>3</mn></msup><mo>+</mo><mn>3</mn><mo>⁡<!--FUNCTION APPLICATION--></mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>2</mn><mo>⁡<!--FUNCTION APPLICATION--></mo><mi>x</mi><mo>+</mo><mn>1</mn>
- <mi>y</mi><mo>=</mo><mi>a</mi><mo>⁡<!--FUNCTION APPLICATION--></mo><msup><mi>x</mi><mn>3</mn></msup><mo>+</mo><mi>b</mi><mo>⁡<!--FUNCTION APPLICATION--></mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mi>c</mi><mo>⁡<!--FUNCTION APPLICATION--></mo><mi>x</mi><mo>+</mo><mi>d</mi>
- Symbol ('y' )=Integer (4 )*Symbol ('x' )**Integer (3 )+Integer (3 )*Symbol ('x' )**Integer (2 )+Integer (2 )*Symbol ('x' )+Integer (1 )
- ^
- SyntaxError: invalid syntax
- map(sym.sympify, "y=4*x**3+3*x**2+2*x+1".split('='))
- >>> sym.Eq(*map(sym.sympify, "y=4*x**3+3*x**2+2*x+1".split('=')))
- Eq(y, 4*x**3 + 3*x**2 + 2*x + 1)
- import sys
- # sys.path.append('/home/vagrant/.local/lib/python3.4/site-packages')
- import sympy as sym
- from sympy.printing.mathml import mathml
- print(mathml(sym.Eq(*map(sym.sympify, "y=4*x**3+3*x**2+2*x+1".split('='))),printer='presentation'))
- print(mathml(sym.Eq(*map(sym.sympify, "y=a*x**3+b*x**2+c*x+d".split('='))),printer='presentation'))
- <mrow><mi>y</mi><mo>=</mo><mrow><mrow><mn>4</mn><mo>⁢</mo><msup><mi>x</mi><mn>3</mn></msup></mrow><mo>+</mo><mrow><mn>3</mn><mo>⁢</mo><msup><mi>x</mi><mn>2</mn></msup></mrow><mo>+</mo><mrow><mn>2</mn><mo>⁢</mo><mi>x</mi></mrow><mo>+</mo><mn>1</mn></mrow></mrow>
- <mrow><mi>y</mi><mo>=</mo><mrow><mrow><mi>a</mi><mo>⁢</mo><msup><mi>x</mi><mn>3</mn></msup></mrow><mo>+</mo><mrow><mi>b</mi><mo>⁢</mo><msup><mi>x</mi><mn>2</mn></msup></mrow><mo>+</mo><mrow><mi>c</mi><mo>⁢</mo><mi>x</mi></mrow><mo>+</mo><mi>d</mi></mrow></mrow>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement