Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# autoray.lazy.draw

Visualizations for `LazyArray` computational graphs.

## Attributes

`COLORING_SEED` |
`HAS_FA2` |
`HAS_PYGRAPHVIZ` |
`NEUTRAL_STYLE` |

## Functions

`set_coloring_seed`(seed) | Set the seed for the random color generator.
`hash_to_nvalues`(s, nval[, seed]) |
`hash_to_color`(s[, hmin, hmax, smin, smax, vmin, vmax]) | Generate a random color for a string `s`.
`rotated_house_shape`(xy[, r]) |
`count_around`(c, layout) |
`get_default_colors_dict`(colors) |
`rotate`(xy, theta) | Return a rotated set of points.
`span`(xy) | Return the vertical span of the points.
`massage_pos`(pos[, nangles, flatten]) | Rotate a position dict's points to cover a small vertical span
`layout_pygraphviz`(G[, prog, dim]) |
`get_nice_pos`(G, *[, dim, layout, initial_layout, ...]) |
`plot_graph`(self[, variables, dim, layout, ...]) | Plot the computational graph of this `LazyArray`.
`plot_circuit`(self[, color_by, colors, layout, ...]) |
`default_to_neutral_style`(fn) | Wrap a function or method to use the neutral style by default.
`plot_history_size_footprint`(self[, log, figsize, ...]) | Plot the memory footprint throughout this computation.
`plot_history_functions`(self, *[, fn, log, colors, ...]) | Plot the functions used throughout this computation, color coded, as
`plot_history_stats`(self, *[, fn, colors, ...]) |

## Module Contents

autoray.lazy.draw.COLORING_SEED = 1

autoray.lazy.draw.set_coloring_seed(seed)

  Set the seed for the random color generator.

  Parameters:

    seed (int) – The seed to use.

autoray.lazy.draw.hash_to_nvalues(s, nval, seed=None)

autoray.lazy.draw.hash_to_color(s, hmin=0.0, hmax=1.0, smin=0.3, smax=0.8, vmin=0.8, vmax=1.0)

  Generate a random color for a string `s`.

  Parameters:

    - s (str) – The string to generate a color for.

    - hmin (float, optional) – The minimum hue value.

    - hmax (float, optional) – The maximum hue value.

    - smin (float, optional) – The minimum saturation value.

    - smax (float, optional) – The maximum saturation value.

    - vmin (float, optional) – The minimum value value.

    - vmax (float, optional) – The maximum value value.

  Returns:

    color – A tuple of floats in the range [0, 1] representing the RGB color.

  Return type:

    tuple

autoray.lazy.draw.rotated_house_shape(xy, r=0.4)

autoray.lazy.draw.count_around(c, layout)

autoray.lazy.draw.get_default_colors_dict(colors)

autoray.lazy.draw.rotate(xy, theta)

  Return a rotated set of points.

autoray.lazy.draw.span(xy)

  Return the vertical span of the points.

autoray.lazy.draw.massage_pos(pos, nangles=180, flatten=False)

  Rotate a position dict’s points to cover a small vertical span

autoray.lazy.draw.layout_pygraphviz(G, prog='neato', dim=2, **kwargs)

autoray.lazy.draw.HAS_FA2

autoray.lazy.draw.HAS_PYGRAPHVIZ

autoray.lazy.draw.get_nice_pos(G, *, dim=2, layout='auto', initial_layout='auto', iterations='auto', k=None, use_forceatlas2=False, flatten=False, **layout_opts)

autoray.lazy.draw.plot_graph(self, variables=None, dim=2, layout='auto', initial_layout='auto', iterations='auto', k=None, use_forceatlas2=False, color_by='function', colors=None, connectionstyle='arc3,rad=-0.05', arrowsize=6, edge_color=(0.5, 0.5, 0.5), edge_alpha=0.3, var_color=(0, 0.5, 0.25), const_color=(0, 0.5, 1.0), root_color=(1, 0, 0.5), node_shape='s', node_scale=1.0, node_alpha=1.0, show_labels=True, label_color=(0.5, 0.5, 0.5), label_alpha=1.0, font_size=8, label_rotation=45, figsize=None, ax=None, show_and_close=True, **layout_opts)

  Plot the computational graph of this `LazyArray`.

autoray.lazy.draw.plot_circuit(self, color_by='function', colors=None, layout='balanced', linewidth=None, linewidth_scale=1, linealpha=1.0, fontsize=None, fontsize_scale=1, figsize=None, ax=None, show_and_close=True)

autoray.lazy.draw.NEUTRAL_STYLE

autoray.lazy.draw.default_to_neutral_style(fn)

  Wrap a function or method to use the neutral style by default.

autoray.lazy.draw.plot_history_size_footprint(self, log=None, figsize=(8, 2), color='purple', alpha=0.5, rasterize=4096, rasterize_dpi=300, ax=None, show_and_close=True)

  Plot the memory footprint throughout this computation.

  Parameters:

    - log (None or int, optional) – If not None, display the sizes in base `log`.

    - figsize (tuple, optional) – Size of the figure.

    - color (str, optional) – Color of the line.

    - alpha (float, optional) – Alpha of the line.

    - ax (matplotlib.axes.Axes, optional) – Axes to plot on, will be created if not provided.

    - return_fig (bool, optional) – If True, return the figure object, else just show and close it.

autoray.lazy.draw.plot_history_functions(self, *, fn=None, log=None, colors=None, kind='scatter', scatter_size=5, scatter_marker='s', lines_width=5, image_alpha_pow=2 / 3, image_aspect=4, legend=True, legend_ncol=None, legend_bbox_to_anchor=None, legend_loc=None, rasterize=4096, rasterize_dpi=300, ax=None, figsize=(8, 2), show_and_close=True)

  Plot the functions used throughout this computation, color coded, as either a scatter plot or an image, showing the size of the that individual intermediate as well.

autoray.lazy.draw.plot_history_stats(self, *, fn='count', colors=None, rasterize_dpi=300, ax=None, figsize=(2, 2), show_and_close=True)