qamuy.plot package

Module contents

class qamuy.plot.CostHistoryPlotter

A concrete class for cost history plot.

plot_data(fig, ax, mol_result_and_states)

An abstract method to plot data. Subclasses should define this method.

class qamuy.plot.EnergyHistoryPlotter(reference_method='AUTO')

A concrete class for energy history plot.

plot_data(fig, ax, mol_result_and_states)

An abstract method to plot data. Subclasses should define this method.

class qamuy.plot.HistoryPlotOptions(output, states=None, history_label_template=None, ref_label_template=None)

An object containing options for cost function/energy history plot.

Parameters:
  • output (QamuyChemistryOutput) – Output data of a calculation by Qamuy

  • states (List[int], optional) – Specifies states to be included in the plot. All states are included if omitted.

  • history_label_template (str, optional) –

    A string template used to format labels for history entries. You can specify the following variables using $ notation of Python template strings.

    • $state: Label for the state

    • $solver: Eigensolver

    • $ansatz: Ansatz

    • $depth: Depth of ansatz

    • $optimizer: Optimizer

    • $mapping: Fermion-qubit mapping

  • ref_label_template (str, optional) –

    A string template used to format labels for a reference post-HF method. You can specify the following variables using $ notation of Python template strings.

    • $state: Label for the state

    • $method: Post-HF method

class qamuy.plot.HistoryPlotter

An abstract base class for history plot.

title

Plot title

Type:

str

x_label

Label of X axis

Type:

str

y_label

Label of Y axis

Type:

str

history_label_template

A string template used to format labels for history entries. You can specify the following variables using $ notation of Python template strings.

  • $state: Label for the state

  • $solver: Eigensolver

  • $ansatz: Ansatz

  • $depth: Depth of ansatz

  • $optimizer: Optimizer

  • $mapping: Fermion-qubit mapping

Type:

str

ref_label_template

A string template used to format labels for a reference post-HF method. You can specify the following variables using $ notation of Python template strings.

  • $state: Label for the state

  • $method: Post-HF method

Type:

str

state_label_map

A dict mapping each state index (int) to a label displayed in plot legend. Zero-based state index is used if omitted.

Type:

Dict[int, str]

legend_kwargs

Keyword arguments passed to Axes.legend method of Matplotlib.

Type:

dict

setup_caption_kwargs

Keyword arguments passed to Axes.text method of Matplotlib when drawing a caption describing the caluclation setup.

Type:

dict

history_label(plot_options, state=None)
plot(plot_input, states=None, **fig_kwargs)

Plot a history plot with given input data.

Parameters:
abstract plot_data(fig, ax, mol_result_and_states)

An abstract method to plot data. Subclasses should define this method.

plot_history(fig, ax, history, plot_options, data_index, state=None)
plot_ref_value(fig, ax, value, data_index, state, ref_type, ref_label_template)
ref_label(ref_type, state, ref_label_template=None)
setup_caption_text(plot_options)
qamuy.plot.plot_cost_history(plot_input, *, states=None, history_label_template=None, state_label_map=None, **fig_kwargs)

Plot histories of cost function values evaluated during an optimization process of VQE.

Parameters:
  • plot_input (QamuyChemistryOutput, HistoryPlotOptions or List[HistoryPlotOptions]) – Input data for the plot

  • states (List[int], optional) – Specifies states to be included in the plot. All states are included if omitted.

  • history_label_template (str, optional) –

    A string template used to format labels for history entries. You can specify the following variables using $ notation of Python template strings.

    • $state: Label for the state

    • $solver: Eigensolver

    • $ansatz: Ansatz

    • $depth: Depth of ansatz

    • $optimizer: Optimizer

    • $mapping: Fermion-qubit mapping

  • state_label_map (Dict[int, str], optional) – A dict mapping each state index (int) to a label displayed in plot legend. Zero-based state index is used if omitted.

Returns:

A tuple of Matplotlib’s Figure and Axes.

qamuy.plot.plot_energy_history(plot_input, *, states=None, reference_method='AUTO', history_label_template=None, ref_label_template=None, state_label_map=None, **fig_kwargs)

Plot histories of energy evaluated during an optimization process of VQE.

Parameters:
  • plot_input (QamuyChemistryOutput, HistoryPlotOptions or List[HistoryPlotOptions]) – Input data for the plot

  • states (List[int], optional) – Specifies states to be included in the plot. All states are included if omitted.

  • reference_method (str or PostHFMethod.Type, optional) – Specifies a post-HF method for which energy value is plotted as a reference value. AUTO is used if omitted, which uses the first available post-HF energy is used. Specify None to suppress plotting reference values.

  • history_label_template (str, optional) –

    A string template used to format labels for history entries. You can specify the following variables using $ notation of Python template strings.

    • $state: Label for the state

    • $solver: Eigensolver

    • $ansatz: Ansatz

    • $depth: Depth of ansatz

    • $optimizer: Optimizer

    • $mapping: Fermion-qubit mapping

  • state_label_map (Dict[int, str], optional) – A dict mapping each state index (int) to a label displayed in plot legend. Zero-based state index is used if omitted.

Returns:

A tuple of Matplotlib’s Figure and Axes.