qubrabench.utils package

Submodules

qubrabench.utils.plotting module

class qubrabench.utils.plotting.BasicPlottingStrategy

Bases: PlottingStrategy, ABC

get_data_group_column_names() list[str]

Generate a data line for each unique value in the specified columns. Useful if the data was generated with different tags based on implementation source, parameter choice etc., that one wants to compare against in a single plot.

Example: [“impl”] - a line will be generated for each unique impl label.

get_plot_group_column_names() list[str]

Generate a plot for each unique tuple of values for the specified columns. Example: [“k”, “n”] - a plot will be generated for each unique tuple value (k, n). Example: [] - generate a single plot with the entire data.

Returns:

List of column names to group by.

class qubrabench.utils.plotting.PlottingStrategy

Bases: ABC

Generic plotting strategy to visualize benchmarking data.

Assumes data is given as a pandas dataframe. See the abstract methods below for configuration options.

color_for_data_group(data_group: str)

data_group is a tuple of values in columns self.get_data_group_column_names()

Returns:

a color for a given key, and generates a new unique color if it does not exist.

colors: dict[str, str] = {}
abstract compute_aggregates(data: DataFrame, *, quantum_factor: float = 1) DataFrame

Compute any additional data columns needed for plotting

Parameters:
  • data – a pandas DataFrame with the input benchmark data

  • quantum_factor – the conversion cost factor for quantum queries (w.r.t. classical queries)

abstract get_column_names_to_plot() dict[str, tuple[str, str]]
Dictionary of columns to display in the plot.

Key: is the column name in the dataframe Value: Column display name, Marker to use in the plot

Example

{“c”: (“Classical”, “o”), “q”: (“Quantum”, “x”)}

abstract get_data_group_column_names() list[str]

Generate a data line for each unique value in the specified columns. Useful if the data was generated with different tags based on implementation source, parameter choice etc., that one wants to compare against in a single plot.

Example: [“impl”] - a line will be generated for each unique impl label.

abstract get_plot_group_column_names() list[str]

Generate a plot for each unique tuple of values for the specified columns. Example: [“k”, “n”] - a plot will be generated for each unique tuple value (k, n). Example: [] - generate a single plot with the entire data.

Returns:

List of column names to group by.

make_plot_label(data_params: list) str

Generate the label for each line from the list of values in columns self.get_data_group_column_names()

make_plot_title(plot_params: list) str

Generate the heading of each plot from the list of values in columns self.get_plot_group_column_names()

plot(data: DataFrame, *, quantum_factor: float = 2, y_lower_lim: float = 1, x_log_scale: bool = True, y_log_scale: bool = True, show_grid: bool = True, display: bool = True)

Plot benchmarking data.

Parameters:
  • data – a pandas DataFrame containing all the benchmark data.

  • quantum_factor – conversion factor for the cost of a quantum query (w.r.t. classical queries).

  • y_lower_lim – lower limit on the Y-axis (useful if the data starts at a large value)

  • x_log_scale – plot X-axis on log-scale

  • y_log_scale – plot Y-axis on log-scale

  • show_grid – show axis grids

  • display – display the plot at the end, defaults to True

Raises:

ValueError – if no columns are given to plot

static serialize_value_tuple(columns: list[str], values: list[str]) str

Serialize a set of column values from a given table row to display.

Parameters:
  • columns – column header names

  • values – column values in the row of interest

abstract x_axis_column() str

Data column to plot along the X-axis

abstract x_axis_label() str

Label to display for the X-axis

abstract y_axis_label() str

Label to display for the Y-axis

Module contents