autoray.lazy.draw
=================

.. py:module:: autoray.lazy.draw

.. autoapi-nested-parse::

   Visualizations for ``LazyArray`` computational graphs.



Attributes
----------

.. autoapisummary::

   autoray.lazy.draw.COLORING_SEED
   autoray.lazy.draw.HAS_FA2
   autoray.lazy.draw.HAS_PYGRAPHVIZ
   autoray.lazy.draw.NEUTRAL_STYLE


Functions
---------

.. autoapisummary::

   autoray.lazy.draw.set_coloring_seed
   autoray.lazy.draw.hash_to_nvalues
   autoray.lazy.draw.hash_to_color
   autoray.lazy.draw.rotated_house_shape
   autoray.lazy.draw.count_around
   autoray.lazy.draw.get_default_colors_dict
   autoray.lazy.draw.rotate
   autoray.lazy.draw.span
   autoray.lazy.draw.massage_pos
   autoray.lazy.draw.layout_pygraphviz
   autoray.lazy.draw.get_nice_pos
   autoray.lazy.draw.plot_graph
   autoray.lazy.draw.plot_circuit
   autoray.lazy.draw.default_to_neutral_style
   autoray.lazy.draw.plot_history_size_footprint
   autoray.lazy.draw.plot_history_functions
   autoray.lazy.draw.plot_history_stats


Module Contents
---------------

.. py:data:: COLORING_SEED
   :value: 1


.. py:function:: set_coloring_seed(seed)

   Set the seed for the random color generator.

   :param seed: The seed to use.
   :type seed: int


.. py:function:: hash_to_nvalues(s, nval, seed=None)

.. py:function:: 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``.

   :param s: The string to generate a color for.
   :type s: str
   :param hmin: The minimum hue value.
   :type hmin: float, optional
   :param hmax: The maximum hue value.
   :type hmax: float, optional
   :param smin: The minimum saturation value.
   :type smin: float, optional
   :param smax: The maximum saturation value.
   :type smax: float, optional
   :param vmin: The minimum value value.
   :type vmin: float, optional
   :param vmax: The maximum value value.
   :type vmax: float, optional

   :returns: **color** -- A tuple of floats in the range [0, 1] representing the RGB color.
   :rtype: tuple


.. py:function:: rotated_house_shape(xy, r=0.4)

.. py:function:: count_around(c, layout)

.. py:function:: get_default_colors_dict(colors)

.. py:function:: rotate(xy, theta)

   Return a rotated set of points.


.. py:function:: span(xy)

   Return the vertical span of the points.


.. py:function:: massage_pos(pos, nangles=180, flatten=False)

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


.. py:function:: layout_pygraphviz(G, prog='neato', dim=2, **kwargs)

.. py:data:: HAS_FA2

.. py:data:: HAS_PYGRAPHVIZ

.. py:function:: get_nice_pos(G, *, dim=2, layout='auto', initial_layout='auto', iterations='auto', k=None, use_forceatlas2=False, flatten=False, **layout_opts)

.. py:function:: 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``.


.. py:function:: 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)

.. py:data:: NEUTRAL_STYLE

.. py:function:: default_to_neutral_style(fn)

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


.. py:function:: 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.

   :param log: If not None, display the sizes in base ``log``.
   :type log: None or int, optional
   :param figsize: Size of the figure.
   :type figsize: tuple, optional
   :param color: Color of the line.
   :type color: str, optional
   :param alpha: Alpha of the line.
   :type alpha: float, optional
   :param ax: Axes to plot on, will be created if not provided.
   :type ax: matplotlib.axes.Axes, optional
   :param return_fig: If True, return the figure object, else just show and close it.
   :type return_fig: bool, optional


.. py:function:: 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.


.. py:function:: plot_history_stats(self, *, fn='count', colors=None, rasterize_dpi=300, ax=None, figsize=(2, 2), show_and_close=True)

