Skip to content
Snippets Groups Projects

Fix documentation formatting

Merged Oscar Gustafsson requested to merge docfixes into master
4 files
+ 76
56
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 72
55
@@ -34,9 +34,9 @@ def draw_exclusion_graph_coloring(
color_dict: Dict[Process, int],
ax: Optional[Axes] = None,
color_list: Optional[Union[List[str], List[Tuple[float, float, float]]]] = None,
):
) -> None:
"""
Use matplotlib.pyplot and networkx to draw a colored exclusion graph from the memory assignment
Draw a colored exclusion graph from the memory assignment.
.. code-block:: python
@@ -51,12 +51,19 @@ 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`.
color_dict : dict
A dict where keys are :class:`~b_asic.process.Process` objects and 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]]]]
A Matplotlib :class:`~matplotlib.axes.Axes` object to draw the exclusion graph.
color_list : iterable of color, optional
A list of colors in Matplotlib format.
Returns
-------
None
"""
COLOR_LIST = [
'#aa0000',
@@ -126,7 +133,7 @@ class ProcessCollection:
Parameters
----------
process : Process
The process object to be added to the collection
The process object to be added to the collection.
"""
self._collection.add(process)
@@ -141,13 +148,14 @@ class ProcessCollection:
show_markers: bool = True,
):
"""
Use matplotlib.pyplot to generate a process variable lifetime chart from this process collection.
Plot a process variable lifetime chart.
Parameters
----------
ax : :class:`matplotlib.axes.Axes`, optional
Matplotlib Axes object to draw this lifetime chart onto. If not provided (i.e., set to None),
this method will return a new axes object on return.
Matplotlib :class:`~matplotlib.axes.Axes` object to draw this lifetime chart
onto. If not provided (i.e., set to None), this method will return a new
Axes object.
show_name : bool, default: True
Show name of all processes in the lifetime chart.
bar_color : color, optional
@@ -176,7 +184,8 @@ class ProcessCollection:
PAD_L, PAD_R = 0.05, 0.05
max_execution_time = max(process.execution_time for process in self._collection)
if max_execution_time > self._schedule_time:
# Schedule time needs to be greater than or equal to the maximum process lifetime
# Schedule time needs to be greater than or equal to the maximum process
# lifetime
raise KeyError(
f'Error: Schedule time: {self._schedule_time} < Max execution'
f' time: {max_execution_time}'
@@ -247,16 +256,19 @@ class ProcessCollection:
total_ports: Optional[int] = None,
) -> nx.Graph:
"""
Create an exclusion graph from a ProcessCollection based on a number of read/write ports
Create an exclusion graph based on a number of read/write ports.
Parameters
----------
read_ports : int
The number of read ports used when splitting process collection based on memory variable access.
The number of read ports used when splitting process collection based on
memory variable access.
write_ports : int
The number of write ports used when splitting process collection based on memory variable access.
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.
The total number of ports used when splitting process collection based on
memory variable access.
Returns
-------
@@ -348,29 +360,28 @@ class ProcessCollection:
return exclusion_graph
def split_execution_time(
self, heuristic: str = "graph_color", coloring_strategy: str = "DSATUR"
self,
heuristic: str = "graph_color",
coloring_strategy: str = "saturation_largest_first",
) -> Set["ProcessCollection"]:
"""
Split a ProcessCollection based on overlapping execution time.
Parameters
----------
heuristic : str, default: 'graph_color'
heuristic : {'graph_color', 'left_edge'}, default: 'graph_color'
The heuristic used when splitting based on execution times.
One of: 'graph_color', 'left_edge'.
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.
coloring_strategy : str, default: 'saturation_largest_first'
Node ordering strategy passed to :func:`networkx.coloring.greedy_color`.
This parameter is only considered if *heuristic* is set to 'graph_color'.
One of
* `'largest_first'`
* `'random_sequential'`
* `'smallest_last'`
* `'independent_set'`
* `'connected_sequential_bfs'`
* `'connected_sequential_dfs'`
* `'connected_sequential'` (alias for the previous strategy)
* `'saturation_largest_first'`
* `'DSATUR'` (alias for the saturation_largest_first strategy)
* 'largest_first'
* 'random_sequential'
* 'smallest_last'
* 'independent_set'
* 'connected_sequential_bfs'
* 'connected_sequential_dfs' or 'connected_sequential'
* 'saturation_largest_first' or 'DSATUR'
Returns
-------
@@ -402,14 +413,17 @@ class ProcessCollection:
heuristic : str, default: "graph_color"
The heuristic used when splitting this ProcessCollection.
Valid options are:
* "graph_color"
* "..."
* "graph_color"
* "..."
read_ports : int, optional
The number of read ports used when splitting process collection based on memory variable access.
The number of read ports used when splitting process collection based on
memory variable access.
write_ports : int, optional
The number of write ports used when splitting process collection based on memory variable access.
The number of write ports used when splitting process collection based on
memory variable access.
total_ports : int, optional
The total number of ports used when splitting process collection based on memory variable access.
The total number of ports used when splitting process collection based on
memory variable access.
Returns
-------
@@ -436,29 +450,30 @@ class ProcessCollection:
read_ports: int,
write_ports: int,
total_ports: int,
coloring_strategy: str = "DSATUR",
coloring_strategy: str = "saturation_largest_first",
) -> Set["ProcessCollection"]:
"""
Parameters
----------
read_ports : int
The number of read ports used when splitting process collection based on memory variable access.
The number of read ports used when splitting process collection based on
memory variable access.
write_ports : int
The number of write ports used when splitting process collection based on memory variable access.
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'
Node ordering strategy passed to nx.coloring.greedy_color()
The total number of ports used when splitting process collection based on
memory variable access.
coloring_strategy : str, default: 'saturation_largest_first'
Node ordering strategy passed to :func:`networkx.coloring.greedy_color`
One of
* `'largest_first'`
* `'random_sequential'`
* `'smallest_last'`
* `'independent_set'`
* `'connected_sequential_bfs'`
* `'connected_sequential_dfs'`
* `'connected_sequential'` (alias for the previous strategy)
* `'saturation_largest_first'`
* `'DSATUR'` (alias for the saturation_largest_first strategy)
* 'largest_first'
* 'random_sequential'
* 'smallest_last'
* 'independent_set'
* 'connected_sequential_bfs'
* 'connected_sequential_dfs' or 'connected_sequential'
* 'saturation_largest_first' or 'DSATUR'
"""
# Create new exclusion graph. Nodes are Processes
exclusion_graph = self.create_exclusion_graph_from_ports(
@@ -475,11 +490,13 @@ class ProcessCollection:
) -> Set["ProcessCollection"]:
"""
Split :class:`Process` objects into a set of :class:`ProcessesCollection` objects based on a provided graph coloring.
Resulting :class:`ProcessCollection` will have the same schedule time and cyclic propoery as self.
Resulting :class:`ProcessCollection` will have the same schedule time and cyclic
property as self.
Parameters
----------
coloring : Dict[Process, int]
coloring : dict
Process->int (color) mappings
Returns
@@ -496,8 +513,8 @@ class ProcessCollection:
def _repr_svg_(self) -> str:
"""
Generate an SVG_ of the resource collection. This is automatically displayed in e.g.
Jupyter Qt console.
Generate an SVG_ of the resource collection. This is automatically displayed in
e.g. Jupyter Qt console.
"""
fig, ax = plt.subplots()
self.draw_lifetime_chart(ax, show_markers=False)
Loading