diff --git a/b_asic/schema.py b/b_asic/schema.py index 523137741d03f812c6ac14b317526b276c099d98..3c1ca16285f7ec913767b8a9880584bd8f21cb94 100644 --- a/b_asic/schema.py +++ b/b_asic/schema.py @@ -10,6 +10,7 @@ from matplotlib.ticker import MaxNLocator import numpy as np from scipy import interpolate import sys +import io from b_asic.signal_flow_graph import SFG from b_asic.graph_component import GraphID @@ -180,7 +181,7 @@ class Schema: self._start_times[output.graph_id] = self._start_times[source_port.operation.graph_id] + source_port.latency_offset self._remove_delays() - def plot_schedule(self) -> None: + def _plot_schedule(self): def _draw_arrow2(start, end): if end[0] < start[0]: # Wrap around plt.plot([start[0], self._schedule_time], [start[1], start[1]]) @@ -223,7 +224,6 @@ class Schema: ypos = 0.5 ytickpositions = [] yticklabels = [] - plt.figure() plt.grid(zorder=0.5) ypositions = dict() for op_id, op_start_time in self._start_times.items(): @@ -263,4 +263,15 @@ class Schema: plt.gca().xaxis.set_major_locator(MaxNLocator(integer=True)) plt.plot([0, 0], [0, ypos], linestyle='--', color='black') plt.plot([self._schedule_time, self._schedule_time], [0, ypos], linestyle='--', color='black') + + def plot_schedule(self) -> None: + plt.figure() + self._plot_schedule() plt.show() + + def _repr_svg_(self): + self._plot_schedule() + f = io.StringIO() + plt.savefig(f, format='svg') + + return f.getvalue()