From a4332b0e68b32ecd780bbb37d6fcadfda65f429a Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson <oscar.gustafsson@gmail.com> Date: Mon, 3 Apr 2023 18:53:33 +0200 Subject: [PATCH] Some typing fixes --- b_asic/_preferences.py | 8 ++++---- b_asic/save_load_structure.py | 2 +- b_asic/schedule.py | 15 +++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/b_asic/_preferences.py b/b_asic/_preferences.py index 53857f98..c9bb219c 100644 --- a/b_asic/_preferences.py +++ b/b_asic/_preferences.py @@ -2,10 +2,10 @@ LATENCY_COLOR = (0, 185, 231) EXECUTION_TIME_COLOR = (255, 100, 66, 200) SIGNAL_COLOR = (0, 0, 0) -SIGNAL_LINEWIDTH = 1.0 +SIGNAL_LINEWIDTH: float = 1.0 -OPERATION_GAP = 0.5 +OPERATION_GAP: float = 0.5 -SCHEDULE_OFFSET = 0.2 +SCHEDULE_OFFSET: float = 0.2 -SPLINE_OFFSET = 0.2 +SPLINE_OFFSET: float = 0.2 diff --git a/b_asic/save_load_structure.py b/b_asic/save_load_structure.py index 74d53131..2a65db0a 100644 --- a/b_asic/save_load_structure.py +++ b/b_asic/save_load_structure.py @@ -16,7 +16,7 @@ from b_asic.signal_flow_graph import SFG def sfg_to_python( - sfg: SFG, counter: int = 0, suffix: Optional[str] = None, schedule=False + sfg: SFG, counter: int = 0, suffix: Optional[str] = None, schedule: bool = False ) -> str: """ Given an SFG structure try to serialize it for saving to a file. diff --git a/b_asic/schedule.py b/b_asic/schedule.py index b07d41d5..6d25eac3 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -7,7 +7,7 @@ Contains the schedule class for scheduling operations in an SFG. import io import sys from collections import defaultdict -from typing import Dict, List, Optional, Tuple, cast +from typing import Dict, List, Optional, Sequence, Tuple, cast import matplotlib.pyplot as plt import numpy as np @@ -720,8 +720,8 @@ class Schedule: line_cache = [] def _draw_arrow( - start: List[float], end: List[float], name: str = "", laps: int = 0 - ): + start: Sequence[float], end: Sequence[float], name: str = "", laps: int = 0 + ) -> None: """Draw an arrow from *start* to *end*.""" if end[0] < start[0] or laps > 0: # Wrap around if start not in line_cache: @@ -802,7 +802,14 @@ class Schedule: ) ax.add_patch(path_patch) - def _draw_offset_arrow(start, end, start_offset, end_offset, name="", laps=0): + def _draw_offset_arrow( + start: Sequence[float], + end: Sequence[float], + start_offset: Sequence[float], + end_offset: Sequence[float], + name: str = "", + laps: int = 0, + ) -> None: """Draw an arrow from *start* to *end*, but with an offset.""" _draw_arrow( [start[0] + start_offset[0], start[1] + start_offset[1]], -- GitLab