From fda2653506e15dc3f1e3745e99febf68a528e965 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson <oscar.gustafsson@gmail.com> Date: Sat, 25 Feb 2023 18:36:27 +0100 Subject: [PATCH] Run velin to fix some doc-string issues --- b_asic/GUI/arrow.py | 19 ++++--------- b_asic/GUI/main_window.py | 1 - b_asic/operation.py | 22 +++++++-------- b_asic/port.py | 3 +- b_asic/research/interleaver.py | 8 ++---- b_asic/resources.py | 13 ++++----- b_asic/save_load_structure.py | 6 ++-- b_asic/schedule.py | 39 +++++++++++--------------- b_asic/scheduler_gui/logger.py | 15 +++++----- b_asic/scheduler_gui/operation_item.py | 2 +- b_asic/scheduler_gui/scheduler_item.py | 4 +-- b_asic/sfg_generators.py | 18 +++--------- b_asic/signal.py | 6 ++-- b_asic/signal_flow_graph.py | 27 ++++++------------ 14 files changed, 69 insertions(+), 114 deletions(-) diff --git a/b_asic/GUI/arrow.py b/b_asic/GUI/arrow.py index 8ead6587..9fbfd538 100644 --- a/b_asic/GUI/arrow.py +++ b/b_asic/GUI/arrow.py @@ -12,13 +12,12 @@ class Arrow(QGraphicsPathItem): def __init__(self, source, destination, window, signal=None, parent=None): """ Parameters - ========== - - source : + ---------- + source Source operation. - destination : + destination Destination operation. - window : + window Window containing signal flow graph. signal : Signal, optional Let arrow represent *signal*. @@ -64,9 +63,7 @@ class Arrow(QGraphicsPathItem): " with name:" f" {self._window.opToSFG[operation].name}." ) - del self._window.sfg_dict[ - self._window.opToSFG[operation].name - ] + del self._window.sfg_dict[self._window.opToSFG[operation].name] self._window.opToSFG = { op: self._window.opToSFG[op] for op in self._window.opToSFG @@ -97,11 +94,7 @@ class Arrow(QGraphicsPathItem): + self.destination.x() + (0 if not destination_flipped else PORTWIDTH) ) - y1 = ( - self.destination.operation.y() - + self.destination.y() - + PORTHEIGHT / 2 - ) + y1 = self.destination.operation.y() + self.destination.y() + PORTHEIGHT / 2 xmid = (x0 + x1) / 2 ymid = (y0 + y1) / 2 both_flipped = source_flipped and destination_flipped diff --git a/b_asic/GUI/main_window.py b/b_asic/GUI/main_window.py index 464fd986..1f97c2c9 100644 --- a/b_asic/GUI/main_window.py +++ b/b_asic/GUI/main_window.py @@ -487,7 +487,6 @@ class MainWindow(QMainWindow): is_flipped: bool = False, ) -> None: """ - Parameters ---------- op : Operation diff --git a/b_asic/operation.py b/b_asic/operation.py index bba050c6..67a95e83 100644 --- a/b_asic/operation.py +++ b/b_asic/operation.py @@ -218,9 +218,8 @@ class Operation(GraphComponent, SignalSourceProvider): The *prefix* parameter will be used as a prefix for the key string when looking for delays. - See also - ======== - + See Also + -------- current_outputs, evaluate_output, evaluate_outputs """ raise NotImplementedError @@ -262,9 +261,8 @@ class Operation(GraphComponent, SignalSourceProvider): place. If set to False, input values will be used directly without any bit truncation. - See also - ======== - + See Also + -------- evaluate_outputs, current_output, current_outputs """ raise NotImplementedError @@ -276,8 +274,8 @@ class Operation(GraphComponent, SignalSourceProvider): """ Get all current outputs of this operation, if available. - See also - ======== + See Also + -------- current_output """ raise NotImplementedError @@ -415,8 +413,8 @@ class Operation(GraphComponent, SignalSourceProvider): These maps to the polygons and are corresponding to a start time of 0 and height 1. - See also - ======== + See Also + -------- get_output_coordinates """ raise NotImplementedError @@ -430,8 +428,8 @@ class Operation(GraphComponent, SignalSourceProvider): These maps to the polygons and are corresponding to a start time of 0 and height 1. - See also - ======== + See Also + -------- get_input_coordinates """ diff --git a/b_asic/port.py b/b_asic/port.py index ef692473..f334122f 100644 --- a/b_asic/port.py +++ b/b_asic/port.py @@ -81,8 +81,7 @@ class Port(ABC): entered signal from the port as well. Parameters - ========== - + ---------- signal : Signal Signal to remove. """ diff --git a/b_asic/research/interleaver.py b/b_asic/research/interleaver.py index b64a79b9..ae879318 100644 --- a/b_asic/research/interleaver.py +++ b/b_asic/research/interleaver.py @@ -41,7 +41,7 @@ def generate_random_interleaver( Returns ------- - ProcessCollection + ProcessCollection """ inputorder = list(range(size)) @@ -52,9 +52,7 @@ def generate_random_interleaver( ) return ProcessCollection( { - PlainMemoryVariable( - inputorder[i], 0, {0: outputorder[i] - inputorder[i]} - ) + PlainMemoryVariable(inputorder[i], 0, {0: outputorder[i] - inputorder[i]}) for i in range(len(inputorder)) }, len(inputorder), @@ -89,7 +87,7 @@ def generate_matrix_transposer( Returns ------- - ProcessCollection + ProcessCollection """ if width is None: width = height diff --git a/b_asic/resources.py b/b_asic/resources.py index f87b0a16..feedc9c4 100644 --- a/b_asic/resources.py +++ b/b_asic/resources.py @@ -51,14 +51,11 @@ def draw_exclusion_graph_coloring( ---------- exclusion_graph : nx.Graph A nx.Graph exclusion graph object that is to be drawn. - color_dict : dictionary A color dictionary where keys are Process objects and where values are integers representing colors. These dictionaries are automatically generated by :func:`networkx.algorithms.coloring.greedy_color`. - ax : :class:`matplotlib.axes.Axes`, optional A Matplotlib Axes object to draw the exclusion graph - color_list : Optional[Union[List[str], List[Tuple[float,float,float]]]] """ COLOR_LIST = [ @@ -166,7 +163,7 @@ class ProcessCollection: Returns ------- - ax: Associated Matplotlib Axes (or array of Axes) object + ax: Associated Matplotlib Axes (or array of Axes) object """ # Set up the Axes object @@ -324,8 +321,8 @@ class ProcessCollection: Returns ------- - An nx.Graph exclusion graph where nodes are processes and arcs - between two processes indicated overlap in time + An nx.Graph exclusion graph where nodes are processes and arcs + between two processes indicated overlap in time """ exclusion_graph = nx.Graph() exclusion_graph.add_nodes_from(self._collection) @@ -361,7 +358,7 @@ class ProcessCollection: heuristic : str, default: 'graph_color' The heuristic used when splitting based on execution times. One of: 'graph_color', 'left_edge'. - coloring_strategy: str, default: 'DSATUR' + coloring_strategy : str, default: 'DSATUR' Node ordering strategy passed to nx.coloring.greedy_color() if the heuristic is set to 'graph_color'. This parameter is only considered if heuristic is set to graph_color. One of @@ -450,7 +447,7 @@ class ProcessCollection: The number of write ports used when splitting process collection based on memory variable access. total_ports : int The total number of ports used when splitting process collection based on memory variable access. - coloring_strategy: str, default: 'DSATUR' + coloring_strategy : str, default: 'DSATUR' Node ordering strategy passed to nx.coloring.greedy_color() One of * `'largest_first'` diff --git a/b_asic/save_load_structure.py b/b_asic/save_load_structure.py index 1c8a70b5..a6bdf27a 100644 --- a/b_asic/save_load_structure.py +++ b/b_asic/save_load_structure.py @@ -22,7 +22,7 @@ def sfg_to_python( Given an SFG structure try to serialize it for saving to a file. Parameters - ========== + ---------- sfg : SFG The SFG to serialize. counter : int, default: 0 @@ -145,7 +145,7 @@ def python_to_sfg(path: str) -> Tuple[SFG, Dict[str, Tuple[int, int]]]: Given a serialized file, try to deserialize it and load it to the library. Parameters - ========== + ---------- path : str Path to file to read and deserialize. """ @@ -166,7 +166,7 @@ def schedule_to_python(schedule: Schedule) -> str: Given a schedule structure try to serialize it for saving to a file. Parameters - ========== + ---------- schedule : Schedule The schedule to serialize. """ diff --git a/b_asic/schedule.py b/b_asic/schedule.py index 971c885a..8390942e 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -147,10 +147,10 @@ class Schedule: Returns ------- - The number of time steps the operation with *graph_id* can ba moved - forward in time. + The number of time steps the operation with *graph_id* can ba moved + forward in time. - See also + See Also -------- backward_slack slacks @@ -197,13 +197,12 @@ class Schedule: Returns ------- - The number of time steps the operation with *graph_id* can ba moved + The number of time steps the operation with *graph_id* can ba moved backward in time. - .. note:: The backward slack is positive, but a call to :func:`move_operation` - should be negative to move the operation backward. + should be negative to move the operation backward. - See also + See Also -------- forward_slack slacks @@ -249,12 +248,11 @@ class Schedule: Returns ------- - A tuple as ``(backward_slack, forward_slack)``. - + A tuple as ``(backward_slack, forward_slack)``. .. note:: The backward slack is positive, but a call to :func:`move_operation` - should be negative to move the operation backward. + should be negative to move the operation backward. - See also + See Also -------- backward_slack forward_slack @@ -277,7 +275,7 @@ class Schedule: time : int The new schedule time. If it is too short, a ValueError will be raised. - See also + See Also -------- get_max_time """ @@ -321,8 +319,7 @@ class Schedule: Increase time resolution for a schedule. Parameters - ========== - + ---------- factor : int The time resolution increment. """ @@ -369,13 +366,12 @@ class Schedule: Decrease time resolution for a schedule. Parameters - ========== - + ---------- factor : int The time resolution decrement. - See also - ======== + See Also + -------- get_possible_time_resolution_decrements """ possible_values = self.get_possible_time_resolution_decrements() @@ -403,7 +399,7 @@ class Schedule: graph_id : GraphID The GraphID of the operation to move. new_y : int - The new y-position of the operation. + The new y-position of the operation. insert : bool, optional If True, all operations on that y-position will be moved one position. The default is False. @@ -450,13 +446,12 @@ class Schedule: """ Set the y-position of the Operation with GraphID *graph_id* to *y_location*. - Parameters ---------- graph_id : GraphID The GraphID of the operation to move. y_location : int - The new y-position of the operation. + The new y-position of the operation. """ self._y_locations[graph_id] = y_location @@ -936,7 +931,7 @@ class Schedule: Returns ------- - The Matplotlib Figure. + The Matplotlib Figure. """ fig, ax = plt.subplots() self._plot_schedule(ax, operation_gap=operation_gap) diff --git a/b_asic/scheduler_gui/logger.py b/b_asic/scheduler_gui/logger.py index b0038589..d8bd4a52 100644 --- a/b_asic/scheduler_gui/logger.py +++ b/b_asic/scheduler_gui/logger.py @@ -62,16 +62,15 @@ def getLogger(filename: str = "scheduler-gui.log", loglevel: str = "INFO") -> Lo object. Parameters - ========== - - filename : str optional - Output filename. Defaults to 'scheduler-gui.log'. - loglevel : str, optional - The minimum level that the logger will log. Defaults to 'INFO'. + ---------- + filename : str optional + Output filename. Defaults to 'scheduler-gui.log'. + loglevel : str, optional + The minimum level that the logger will log. Defaults to 'INFO'. Returns - ======= - Logger : 'logging.Logger' object. + ------- + Logger : 'logging.Logger' object. """ # logger = logging.getLogger(name) diff --git a/b_asic/scheduler_gui/operation_item.py b/b_asic/scheduler_gui/operation_item.py index e6881b7a..67898a18 100644 --- a/b_asic/scheduler_gui/operation_item.py +++ b/b_asic/scheduler_gui/operation_item.py @@ -155,7 +155,7 @@ class OperationItem(QGraphicsItemGroup): Returns ------- - The location as a QPointF. + The location as a QPointF. """ return self.mapToParent(self._ports[key]["pos"]) diff --git a/b_asic/scheduler_gui/scheduler_item.py b/b_asic/scheduler_gui/scheduler_item.py index 055857c6..29afe418 100644 --- a/b_asic/scheduler_gui/scheduler_item.py +++ b/b_asic/scheduler_gui/scheduler_item.py @@ -90,11 +90,9 @@ class SchedulerItem(SchedulerEvent, QGraphicsItemGroup): # PySide2 / PyQt5 position is valid, False otherwise. Parameters - ========== - + ---------- item : OperationItem The component. - pos : float The x-position to check. """ diff --git a/b_asic/sfg_generators.py b/b_asic/sfg_generators.py index 7428e22a..0e0d7929 100644 --- a/b_asic/sfg_generators.py +++ b/b_asic/sfg_generators.py @@ -140,27 +140,22 @@ def direct_form_fir( ---------- coefficients : 1D-array Coefficients to use for the FIR filter section - input_op : Input, optional The Input to connect the SFG to. If not provided, one will be generated. - output : Output, optional The Output to connect the SFG to. If not provided, one will be generated. - name : Name, optional The name of the SFG. If None, "Direct-form FIR filter". - mult_properties : dictionary, optional Properties passed to :class:`~b_asic.core_operations.ConstantMultiplication`. - add_properties : dictionary, optional Properties passed to :class:`~b_asic.core_operations.Addition`. Returns ------- - Signal flow graph + Signal flow graph - See also + See Also -------- transposed_direct_form_fir """ @@ -221,27 +216,22 @@ def transposed_direct_form_fir( ---------- coefficients : 1D-array Coefficients to use for the FIR filter section - input_op : Input, optional The Input to connect the SFG to. If not provided, one will be generated. - output : Output, optional The Output to connect the SFG to. If not provided, one will be generated. - name : Name, optional The name of the SFG. If None, "Transposed direct-form FIR filter". - mult_properties : dictionary, optional Properties passed to :class:`~b_asic.core_operations.ConstantMultiplication`. - add_properties : dictionary, optional Properties passed to :class:`~b_asic.core_operations.Addition`. Returns ------- - Signal flow graph + Signal flow graph - See also + See Also -------- direct_form_fir """ diff --git a/b_asic/signal.py b/b_asic/signal.py index b7128f45..6e25543d 100644 --- a/b_asic/signal.py +++ b/b_asic/signal.py @@ -86,8 +86,7 @@ class Signal(AbstractGraphComponent): already been connected. Parameters - ========== - + ---------- source : OutputPort, Signal, or Operation OutputPort, Signal, or Operation to connect as source to the signal. If Signal, it will connect to the source of the signal, so later on @@ -121,8 +120,7 @@ class Signal(AbstractGraphComponent): been connected. Parameters - ========== - + ---------- destination : InputPort, Signal, or Operation InputPort, Signal, or Operation to connect as destination to the signal. If Signal, it will connect to the destination of the signal, so later on diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py index 782baa69..988673cd 100644 --- a/b_asic/signal_flow_graph.py +++ b/b_asic/signal_flow_graph.py @@ -472,8 +472,8 @@ class SFG(AbstractOperation): Returns ------- - A list of inputs that are required to compute the output with the given - *output_index*. + A list of inputs that are required to compute the output with the given + *output_index*. """ if output_index < 0 or output_index >= self.output_count: raise IndexError( @@ -538,7 +538,7 @@ class SFG(AbstractOperation): Returns an empty sequence if no components were found. Parameters - ========== + ---------- type_name : TypeName The TypeName of the desired components. """ @@ -555,8 +555,7 @@ class SFG(AbstractOperation): Returns None if the component was not found. Parameters - ========== - + ---------- graph_id : GraphID Graph ID of the desired component. """ @@ -568,8 +567,7 @@ class SFG(AbstractOperation): Returns an empty sequence if no components were found. Parameters - ========== - + ---------- name : Name Name of the desired component(s) """ @@ -584,8 +582,7 @@ class SFG(AbstractOperation): from a simulation. Parameters - ========== - + ---------- name : Name Name of the desired component(s) output_index : int, default: 0 @@ -603,8 +600,7 @@ class SFG(AbstractOperation): Then return a new deepcopy of the sfg with the replaced component. Parameters - ========== - + ---------- component : Operation The new component(s), e.g. Multiplication graph_id : GraphID @@ -644,8 +640,7 @@ class SFG(AbstractOperation): Then return a new deepcopy of the sfg with the inserted component. Parameters - ========== - + ---------- component : Operation The new component, e.g. Multiplication. output_comp_id : GraphID @@ -689,8 +684,7 @@ class SFG(AbstractOperation): then returns None and does nothing. Parameters - ========== - + ---------- operation_id : GraphID The GraphID of the operation to remove. @@ -1311,7 +1305,6 @@ class SFG(AbstractOperation): ---------- show_id : Boolean, optional If True, the graph_id:s of signals are shown. The default is False. - engine : string, optional Graphviz layout engine to be used, see https://graphviz.org/documentation/. Most common are "dot" and "neato". Default is None leading to dot. @@ -1367,10 +1360,8 @@ class SFG(AbstractOperation): https://www.graphviz.org/doc/info/output.html Most common are "pdf", "eps", "png", and "svg". Default is None which leads to PDF. - show_id : Boolean, optional If True, the graph_id:s of signals are shown. The default is False. - engine : string, optional Graphviz layout engine to be used, see https://graphviz.org/documentation/. Most common are "dot" and "neato". Default is None leading to dot. -- GitLab