Skip to content
Snippets Groups Projects
Commit 0f49938b authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Improve content rendering

parent d3ccf421
No related branches found
No related tags found
1 merge request!365Improve content rendering
Pipeline #96923 failed
......@@ -8,7 +8,6 @@ from typing import Dict, Iterable, Iterator, List, Optional, Set, Tuple, Union,
import matplotlib.pyplot as plt
from graphviz import Digraph
from b_asic.mpl_utils import FigureWrapper
from b_asic.port import InputPort, OutputPort
from b_asic.process import MemoryVariable, OperatorProcess, PlainMemoryVariable
from b_asic.resources import ProcessCollection
......@@ -192,16 +191,16 @@ class Resource(HardwareBlock):
return self._assignment is not None
@property
def content(self) -> FigureWrapper:
def content(self) -> plt.Figure:
"""
Return a graphical representation of the content.
This is visible in enriched shells, but the object in itself has no further
meaning.
This is visible in enriched shells, but the object itself has no further
meaning (it is a Matplotlib Figure).
"""
fig, ax = plt.subplots()
self.plot_content(ax)
return FigureWrapper(fig)
return fig
class ProcessingElement(Resource):
......
"""
B-ASIC utilities for Matplotlib integration.
"""
import io
from matplotlib.figure import Figure
class FigureWrapper:
"""Simple wrapper to display a figure inline in enriched shells."""
def __init__(self, figure: Figure):
self._figure = figure
def _repr_svg_(self):
buffer = io.StringIO()
self._figure.savefig(buffer, format="svg")
return buffer.getvalue()
......@@ -8,7 +8,6 @@ API
architecture.rst
core_operations.rst
graph_component.rst
mpl_utils.rst
operation.rst
port.rst
process.rst
......
********************
``b_asic.mpl_utils``
********************
.. automodule:: b_asic.mpl_utils
:members:
:undoc-members:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment