From a310b1647b1801b4bb8dee2a156ea89f4e6cfec2 Mon Sep 17 00:00:00 2001 From: Simon Bjurek <simbj106@student.liu.se> Date: Thu, 20 Feb 2025 15:54:16 +0100 Subject: [PATCH] fixes from mr comments --- b_asic/architecture.py | 4 ++-- b_asic/scheduler.py | 16 ++++++---------- test/integration/test_sfg_to_architecture.py | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/b_asic/architecture.py b/b_asic/architecture.py index 4ea6d873..6e10d0f6 100644 --- a/b_asic/architecture.py +++ b/b_asic/architecture.py @@ -399,8 +399,8 @@ class ProcessingElement(Resource): if not isinstance(process_collection, ProcessCollection): raise TypeError( - "Argument process_collection is of wrong type" - " when creating ProcessingElement" + "Argument process_collection must be ProcessCollection, " + f"not {type(process_collection)}" ) if not all( diff --git a/b_asic/scheduler.py b/b_asic/scheduler.py index cdcc6d81..bf9a2474 100644 --- a/b_asic/scheduler.py +++ b/b_asic/scheduler.py @@ -69,15 +69,11 @@ class ListScheduler(Scheduler, ABC): else: self._max_resources = {} - self._max_concurrent_reads = ( - max_concurrent_reads if max_concurrent_reads else sys.maxsize - ) - self._max_concurrent_writes = ( - max_concurrent_writes if max_concurrent_writes else sys.maxsize - ) + self._max_concurrent_reads = max_concurrent_reads or sys.maxsize + self._max_concurrent_writes = max_concurrent_writes or sys.maxsize - self._input_times = input_times if input_times else {} - self._output_delta_times = output_delta_times if output_delta_times else {} + self._input_times = input_times or {} + self._output_delta_times = output_delta_times or {} def apply_scheduling(self, schedule: "Schedule") -> None: """Applies the scheduling algorithm on the given Schedule. @@ -92,9 +88,9 @@ class ListScheduler(Scheduler, ABC): used_resources_ready_times = {} remaining_resources = self._max_resources.copy() if Input.type_name() not in remaining_resources: - remaining_resources |= {Input.type_name(): 1} + remaining_resources[Input.type_name()] = 1 if Output.type_name() not in remaining_resources: - remaining_resources |= {Output.type_name(): 1} + remaining_resources[Output.type_name()] = 1 sorted_operations = self._get_sorted_operations(schedule) diff --git a/test/integration/test_sfg_to_architecture.py b/test/integration/test_sfg_to_architecture.py index 3f8c810e..c07e9766 100644 --- a/test/integration/test_sfg_to_architecture.py +++ b/test/integration/test_sfg_to_architecture.py @@ -48,7 +48,7 @@ def test_pe_constrained_schedule(): mads = mads.split_on_execution_time() with pytest.raises( TypeError, - match="Argument process_collection is of wrong type when creating ProcessingElement", + match="Argument process_collection must be ProcessCollection, not <class 'list'>", ): ProcessingElement(mads, entity_name="mad") -- GitLab