Last active
April 30, 2024 17:11
-
-
Save nilreml/7cfa6d1f6d974a74a59073c0d65a9f6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Render markdown cells: | |
from IPython.display import display, Markdown | |
display(Markdown(...)) # e.g. df.to_markdown() | |
Pretty print tensors: | |
import lovely_tensors as lt | |
lt.lovely(...) | |
Rich print: | |
pip install rich | |
import rich.console | |
print = rich.console.Console(force_jupyter=False).print | |
Pretty print XML: | |
from pygments import highlight | |
from pygments.lexers import XmlLexer | |
from pygments.formatters import HtmlFormatter | |
from IPython.display import HTML, display | |
def print_xml(xml:bytes) -> None: | |
formatter = HtmlFormatter(style='gruvbox-dark') | |
display(HTML( | |
'<style type="text/css">{}</style>{}'.format( | |
formatter.get_style_defs(".highlight"), | |
highlight(xml, XmlLexer(), formatter), | |
))) | |
print_xml([BaseXmlModel].to_xml(pretty_print=True)) | |
Requirements: | |
ipykernel | |
ipywidgets | |
pandas | |
tabulate | |
lovely-tensors | |
torch | |
torchvision | |
torchaudio | |
rich | |
pygments | |
types-pygments | |
pydantic | |
pydantic-xml | |
lxml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment