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