diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2ddbba5a328499d317226a002c3a110fb66e12fb..3fc8f67f786627e8619e0fd5e42f32f9241fd31c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: mixed-line-ending exclude_types: [svg] @@ -14,17 +14,17 @@ repos: - id: check-toml - repo: https://github.com/crate-ci/typos - rev: v1.22.9 + rev: v1.29.9 hooks: - id: typos - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 25.1.0 hooks: - id: black - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 6.0.0 hooks: - id: isort name: isort (python) @@ -36,17 +36,17 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit # Ruff version. - rev: "v0.5.0" + rev: "v0.9.7" hooks: - id: ruff - repo: https://github.com/adamchainz/blacken-docs - rev: 1.18.0 + rev: 1.19.1 hooks: - id: blacken-docs - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 + rev: v3.19.1 hooks: - id: pyupgrade args: [--py38-plus] diff --git a/b_asic/schedule.py b/b_asic/schedule.py index 6e231c2c7971c961f5bfdd70e9b65ebe38bb81c7..1d72ce0b1ee2d3f7889c29f1fd418122f118431c 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -575,7 +575,7 @@ class Schedule: if change_in_latency > (self.forward_slack(op.graph_id)): passed = False raise ValueError( - f"Error: Can't increase latency for all components. Try increassing forward slack time by rescheduling. " + f"Error: Can't increase latency for all components. Try increasing forward slack time by rescheduling. " f"Error in: {op.graph_id}" ) break @@ -894,6 +894,12 @@ class Schedule: self._y_locations[graph_id] = y_location return operation_gap + y_location * (operation_height + operation_gap) + def sort_y_locations_on_start_times(self): + for i, graph_id in enumerate( + sorted(self._start_times, key=self._start_times.get) + ): + self.set_y_location(graph_id, i) + def _plot_schedule(self, ax: Axes, operation_gap: float = OPERATION_GAP) -> None: """Draw the schedule.""" line_cache = [] diff --git a/b_asic/scheduler.py b/b_asic/scheduler.py index fc5125575c9d777ffa354f12b32d0c061bb934c5..311c0634a01af55a394eb92649d262327c68871f 100644 --- a/b_asic/scheduler.py +++ b/b_asic/scheduler.py @@ -120,6 +120,8 @@ class ASAPScheduler(Scheduler): self._handle_outputs(schedule, non_schedulable_ops) schedule.remove_delays() + schedule.sort_y_locations_on_start_times() + class ALAPScheduler(Scheduler): """Scheduler that implements the as-late-as-possible (ALAP) algorithm.""" @@ -151,6 +153,8 @@ class ALAPScheduler(Scheduler): if not isinstance(outport.operation, Delay): schedule.move_operation_alap(outport.operation.graph_id) + schedule.sort_y_locations_on_start_times() + class ListScheduler(Scheduler, ABC): def __init__( @@ -314,6 +318,8 @@ class ListScheduler(Scheduler, ABC): schedule.start_times[dc_op.graph_id] = 0 schedule.move_operation_alap(dc_op.graph_id) + schedule.sort_y_locations_on_start_times() + def _get_next_op_id( self, ready_ops_priority_table: list[tuple["GraphID", int, ...]] ) -> "GraphID": diff --git a/b_asic/scheduler_gui/scheduler_item.py b/b_asic/scheduler_gui/scheduler_item.py index dcd4b993722a1cd37a5453583f5d6cfa01084f8e..80e09ac6d3f9d696e62e9f2124b26435ba3e9042 100644 --- a/b_asic/scheduler_gui/scheduler_item.py +++ b/b_asic/scheduler_gui/scheduler_item.py @@ -313,9 +313,8 @@ class SchedulerItem(SchedulerEvent, QGraphicsItemGroup): # PySide2 / PyQt5 def _redraw_from_start(self) -> None: self.schedule._reset_y_locations() - for graph_id in dict( - sorted(self.schedule.start_times.items(), key=lambda item: item[1]) - ): + self.schedule.sort_y_locations_on_start_times() + for graph_id in self.schedule.start_times.keys(): self._set_position(graph_id) self._redraw_all_lines() self._update_axes()