Coverage for muutils/nbutils/print_tex.py: 0%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-04-04 03:33 -0600

1"""quickly print a sympy expression in latex""" 

2 

3import sympy as sp # type: ignore 

4from IPython.display import Math, display # type: ignore 

5 

6 

7def print_tex( 

8 expr: sp.Expr, 

9 name: str | None = None, 

10 plain: bool = False, 

11 rendered: bool = True, 

12): 

13 """function for easily rendering a sympy expression in latex""" 

14 out: str = sp.latex(expr) 

15 if name is not None: 

16 out = f"{name} = {out}" 

17 

18 if plain: 

19 print(out) 

20 if rendered: 

21 display(Math(out))