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

Add SymPy equation rendering support such that the ouput is on parity with Jupyter's rendering when using SymPy. #1412

Open
kamyuen opened this issue May 19, 2024 · 1 comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@kamyuen
Copy link

kamyuen commented May 19, 2024

Description

There is currently no way to render equations properly when using SymPy. In Jupyter notebook one usually just calls init_printing() at the beginning of a notebook to allow all subsequent output to be rendered in mathematical notation.
Importing SymPy in and calling init_printing() has absolutely no effect and equations are simple output as text.
To see the issue just follow the SymPy documentation for setting up this feature https://docs.sympy.org/latest/tutorials/intro-tutorial/printing.html

Suggested solution

Since SymPy has multiple fallbacks on how to render the output, it may be a case of initially capturing the resulting MathJax and rendering using Marimo's md function, just a guess.

Alternative

No response

Additional context

No response

@mscolnick
Copy link
Contributor

In the meantime, you can do this:

from sympy import latex
import marimo as mo

def print_sympy(obj):
    return mo.md(f"""
    \[
    {latex(obj)}
    \]
    """)

Playground: https://marimo.app/l/n2kkic

@mscolnick mscolnick added good first issue Good for newcomers help wanted Extra attention is needed labels May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants