From 0f49938b3ef227d04672f1da24465792578f5703 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson <oscar.gustafsson@gmail.com> Date: Wed, 10 May 2023 11:44:28 +0200 Subject: [PATCH] Improve content rendering --- b_asic/architecture.py | 9 ++++----- b_asic/mpl_utils.py | 18 ------------------ docs_sphinx/api/index.rst | 1 - docs_sphinx/api/mpl_utils.rst | 7 ------- 4 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 b_asic/mpl_utils.py delete mode 100644 docs_sphinx/api/mpl_utils.rst diff --git a/b_asic/architecture.py b/b_asic/architecture.py index 2d17dd76..cc73a389 100644 --- a/b_asic/architecture.py +++ b/b_asic/architecture.py @@ -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): diff --git a/b_asic/mpl_utils.py b/b_asic/mpl_utils.py deleted file mode 100644 index f0213df8..00000000 --- a/b_asic/mpl_utils.py +++ /dev/null @@ -1,18 +0,0 @@ -""" -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() diff --git a/docs_sphinx/api/index.rst b/docs_sphinx/api/index.rst index e0cf7ef3..484dfd3b 100644 --- a/docs_sphinx/api/index.rst +++ b/docs_sphinx/api/index.rst @@ -8,7 +8,6 @@ API architecture.rst core_operations.rst graph_component.rst - mpl_utils.rst operation.rst port.rst process.rst diff --git a/docs_sphinx/api/mpl_utils.rst b/docs_sphinx/api/mpl_utils.rst deleted file mode 100644 index 2a528cc0..00000000 --- a/docs_sphinx/api/mpl_utils.rst +++ /dev/null @@ -1,7 +0,0 @@ -******************** -``b_asic.mpl_utils`` -******************** - -.. automodule:: b_asic.mpl_utils - :members: - :undoc-members: -- GitLab