From 0ae6af3604c6a981fcdb4ee0700c17ceae921026 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson <oscar.gustafsson@gmail.com> Date: Fri, 24 Feb 2023 18:00:45 +0100 Subject: [PATCH] Unify plot/show --- b_asic/resources.py | 2 +- b_asic/schedule.py | 6 +++--- examples/secondorderdirectformiir.py | 6 ++---- examples/threepointwinograddft.py | 8 ++------ test/test_resources.py | 4 ++-- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/b_asic/resources.py b/b_asic/resources.py index a9d5fbf2..f87b0a16 100644 --- a/b_asic/resources.py +++ b/b_asic/resources.py @@ -133,7 +133,7 @@ class ProcessCollection: """ self._collection.add(process) - def draw_lifetime_chart( + def plot( self, ax: Optional[Axes] = None, show_name: bool = True, diff --git a/b_asic/schedule.py b/b_asic/schedule.py index cff3a166..971c885a 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -898,7 +898,7 @@ class Schedule: """Reset all the y-locations in the schedule to None""" self._y_locations = defaultdict(lambda: None) - def plot_in_axes(self, ax: Axes, operation_gap: Optional[float] = None) -> None: + def plot(self, ax: Axes, operation_gap: Optional[float] = None) -> None: """ Plot the schedule in a :class:`matplotlib.axes.Axes` or subclass. @@ -912,9 +912,9 @@ class Schedule: """ self._plot_schedule(ax, operation_gap=operation_gap) - def plot(self, operation_gap: Optional[float] = None) -> None: + def show(self, operation_gap: Optional[float] = None) -> None: """ - Plot the schedule. Will display based on the current Matplotlib backend. + Show the schedule. Will display based on the current Matplotlib backend. Parameters ---------- diff --git a/examples/secondorderdirectformiir.py b/examples/secondorderdirectformiir.py index f6aefffe..e78a48f3 100644 --- a/examples/secondorderdirectformiir.py +++ b/examples/secondorderdirectformiir.py @@ -27,9 +27,7 @@ a0 = ConstantMultiplication(0.7, add1, "A0") add4 = Addition(a0, add3, "ADD4") out1 = Output(add4, "OUT1") -sfg = SFG( - inputs=[in1], outputs=[out1], name="Second-order direct form IIR filter" -) +sfg = SFG(inputs=[in1], outputs=[out1], name="Second-order direct form IIR filter") # %% # Set latencies and execution times @@ -42,4 +40,4 @@ sfg.set_execution_time_of_type(Addition.type_name(), 1) # Create schedule schedule = Schedule(sfg, cyclic=True) -schedule.plot() +schedule.show() diff --git a/examples/threepointwinograddft.py b/examples/threepointwinograddft.py index 36a332f0..17ec5c42 100644 --- a/examples/threepointwinograddft.py +++ b/examples/threepointwinograddft.py @@ -6,11 +6,7 @@ Three-point Winograd DFT from math import cos, pi, sin -from b_asic.core_operations import ( - Addition, - ConstantMultiplication, - Subtraction, -) +from b_asic.core_operations import Addition, ConstantMultiplication, Subtraction from b_asic.schedule import Schedule from b_asic.signal_flow_graph import SFG from b_asic.special_operations import Input, Output @@ -53,6 +49,6 @@ sfg.set_execution_time_of_type(Subtraction.type_name(), 1) # %% # Generate schedule schedule = Schedule(sfg, cyclic=True) -schedule.plot() +schedule.show() pc = schedule.get_memory_variables() diff --git a/test/test_resources.py b/test/test_resources.py index ea0b0d00..5d00ccf2 100644 --- a/test/test_resources.py +++ b/test/test_resources.py @@ -14,13 +14,13 @@ class TestProcessCollectionPlainMemoryVariable: @pytest.mark.mpl_image_compare(style='mpl20') def test_draw_process_collection(self, simple_collection): fig, ax = plt.subplots() - simple_collection.draw_lifetime_chart(ax=ax, show_markers=False) + simple_collection.plot(ax=ax, show_markers=False) return fig @pytest.mark.mpl_image_compare(style='mpl20') def test_draw_matrix_transposer_4(self): fig, ax = plt.subplots() - generate_matrix_transposer(4).draw_lifetime_chart(ax=ax) + generate_matrix_transposer(4).plot(ax=ax) return fig def test_split_memory_variable(self, simple_collection: ProcessCollection): -- GitLab