lisa.analysis.base.AnalysisHelpers#

class lisa.analysis.base.AnalysisHelpers[source]#

Bases: Loggable, ABC

Helper methods class for Analysis modules.

Properties

name

Name of the analysis class.

logger inherited

Convenience short-hand for self.get_logger().

Methods

get_default_plot_path()

Return the default path to use to save plots for the analysis.

get_plot_methods()

plot_method()

Plot function decorator.

save_plot()

Save a holoviews element or matplotlib.figure.Figure as an image file.

get_logger() inherited

Provides a logging.Logger named after cls.

log_locals() inherited

Debugging aid: log the local variables of the calling function.

Properties#

abstract property AnalysisHelpers.name[source]#

Name of the analysis class.

property AnalysisHelpers.logger#

Inherited property, see lisa.utils.Loggable.logger

Convenience short-hand for self.get_logger().

Methods#

AnalysisHelpers.get_default_plot_path(img_format, plot_name, default_dir='.')[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.get_default_plot_path()

Return the default path to use to save plots for the analysis.

Parameters:
  • img_format (str) – Format of the image to save.

  • plot_name (str) – Middle-name of the plot

  • default_dir (str) – Default folder to store plots into.

classmethod AnalysisHelpers.get_plot_methods(*args, **kwargs)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.get_plot_methods()

classmethod AnalysisHelpers.plot_method(f)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.plot_method()

Plot function decorator.

It provides among other things:

  • automatic plot setup

  • HTML and reStructuredText output.

  • workarounds some holoviews issues

  • integration in other tools

AnalysisHelpers.save_plot(figure, filepath=None, img_format=None, backend=None)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.save_plot()

Save a holoviews element or matplotlib.figure.Figure as an image file.

Parameters:
  • figure (matplotlib.figure.Figure or holoviews.core.Element) – Figure to save to a file.

  • filepath (str or None) – Path to the file to save the plot. If None, a default path will be used.

  • img_format (str or None) – Format of the image. If None, it is guessed from the filepath.

  • backend (str or None) – Holoviews backend to use. If left to None, the current backend enabled with hv.extension() will be used.

classmethod AnalysisHelpers.get_logger(suffix=None)#

Inherited method, see lisa.utils.Loggable.get_logger()

Provides a logging.Logger named after cls.

classmethod AnalysisHelpers.log_locals(var_names=None, level='debug')#

Inherited method, see lisa.utils.Loggable.log_locals()

Debugging aid: log the local variables of the calling function.

classmethod AnalysisHelpers.cycle_colors(axis, nr_cycles=1)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.cycle_colors()

Cycle the axis color cycle nr_cycles forward

Parameters:
  • axis (matplotlib.axes.Axes) – The axis to manipulate

  • nr_cycles (int) – The number of colors to cycle through.

Note

This is an absolute cycle, as in, it will always start from the first color defined in the color cycle.

Deprecated since version 2.0.

cycle_colors() is deprecated and will be removed in version 4.0: Made irrelevant by the use of holoviews

AnalysisHelpers.do_plot(plotter, axis=None, **kwargs)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.do_plot()

Simple helper for consistent behavior across methods.

Deprecated since version 2.0.

do_plot() is deprecated and will be removed in version 4.0: Made irrelevant by the use of holoviews

classmethod AnalysisHelpers.get_next_color(axis)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.get_next_color()

Get the next color that will be used to draw lines on the axis

Parameters:

axis (matplotlib.axes.Axes) – The axis

Warning

This will consume the color from the cycler, which means it will change which color is to be used next.

Deprecated since version 2.0.

get_next_color() is deprecated and will be removed in version 4.0: Made irrelevant by the use of holoviews

classmethod AnalysisHelpers.set_axis_cycler(axis, *cyclers)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.set_axis_cycler()

Context manager to set cyclers on an axis (and the default cycler as well), and then restore the default cycler.

Note

The given cyclers are merged with the original cycler. The given cyclers will override any key of the original cycler, and the number of values will be adjusted to the maximum size between all of them. This way of merging allows decoupling the length of all keys.

Deprecated since version 2.0.

set_axis_cycler() is deprecated and will be removed in version 4.0: Made irrelevant by the use of holoviews

classmethod AnalysisHelpers.set_axis_rc_params(axis, rc_params)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.set_axis_rc_params()

Context manager to set matplotlib.rcParams while plotting, and then restore the default parameters.

Deprecated since version 2.0.

set_axis_rc_params() is deprecated and will be removed in version 4.0: Made irrelevant by the use of holoviews

classmethod AnalysisHelpers.setup_plot(width=16, height=4, ncols=1, nrows=1, interactive=None, link_dataframes=None, cursor_delta=None, **kwargs)[source]#

Called on Trace instances as trace.ana.<property object at 0x7fbf15476ed0>.setup_plot()

Common helper for setting up a matplotlib plot

Parameters:
  • width (int or float) – Width of the plot (inches)

  • height (int or float) – Height of each subplot (inches)

  • ncols (int) – Number of plots on a single row

  • nrows (int) – Number of plots in a single column

  • link_dataframes (list(pandas.DataFrame) or None) – Link the provided dataframes to the axes using lisa.notebook.axis_link_dataframes()

  • cursor_delta (bool or None) – Add two vertical lines set with left and right clicks, and show the time delta between them in a widget.

  • interactive (bool) – If True, use the pyplot API of matplotlib, which integrates well with notebooks. However, it can lead to memory leaks in scripts generating lots of plots, in which case it is better to use the non-interactive API. Defaults to True when running under IPython or Jupyter notebook, False` otherwise.

Keywords arguments:

Extra arguments to pass to matplotlib.figure.Figure.subplots

Returns:

tuple(matplotlib.figure.Figure, matplotlib.axes.Axes (or an array of, if nrows > 1))

Deprecated since version 2.0.

setup_plot() is deprecated and will be removed in version 4.0: Made irrelevant by the use of holoviews