QPUPlot#

Module: exa.core.plotting.qpu_plot

class QPUPlot(chip_label, qb_colormap=None, tc_colormap=None, cr_colormap=None, observations=None, aux_colormap=None, save_directory=None, resolution=300, figure_format='png', split_dut_field=None, chip_layout=None)#

Bases: object

Help creating a plot for a given QPU that shows observation data.

Initialize QPUPlot.

Parameters:
  • chip_label (str) – The DUT label of the chip, used to find the respective chip design record.

  • qb_colormap (ListedColormap | None) – If provided, color the qubits in the topology plot based on their data value, otherwise qubits are uncolored.

  • tc_colormap (ListedColormap | None) – If provided, color the couplers in the topology plot based on their data value, otherwise couplers are uncolored.

  • cr_colormap (ListedColormap | None) – If provided, color the computational resonators in the topology plot based on their data value, otherwise computational resonators are uncolored.

  • aux_colormap (ListedColormap | None) – Auxiliary colormap that is used by CDF plot.

  • observations (Sequence[ObservationDefinition] | None) – An optional list of observations passed on initialization, to be used in the plot. More observations can be added via add_observations or add_observations_from_database methods.

  • save_directory (Path | None) – Where to save the figure.

  • resolution (int) – If figures are saved, rasterize with the given value in dpi.

  • figure_format (str) – All figures will be saved in this format, for example, png, jpg, pdf, svg.

  • split_dut_field (Callable[[str], tuple[str, str]] | None) – How to extract component and parameter names from the DUT field. Default assumes that {dut_field}=={component_name}.{parameter_name}.

  • chip_layout (ChipLayout | None) – Providing a chip layout is required if the metro data is not available in the chip design record.

Attributes

chad

The chip architecture definition (CHAD).

chip_label

The chip label, same as the DUT label.

figs

List of figures rather than list of dictionary of figures for compliance.

observations

The plain list of observations.

Methods

add_observations

Add the given observations to our observations list.

add_observations_from_database

Add observations from database, filtering based on the provided criteria.

add_observations_from_stash

Get observations from an existing stash, independently of their origin.

convert_fidelity_and_error

Converts fidelities to errors and errors to fidelities.

draw_all

Draw all the plots for all the data we have.

draw_bar_chart

Draw bar chart plots for the latest observations of a given type.

draw_cdf

Draw a cumulative histogram plot for all the observations of the given obs_types.

draw_histogram

Plot a histogram for observation.

draw_time_series

Draw a time series plot for multiple DUT fields.

draw_topology

Draw the topology plots for all the observations.

set_aux_colormap

Set the auxiliary colormap.

set_colormaps

Set the colormaps to the given ones.

set_cr_colormap

Set the computational resonator colormap to the given one.

set_qb_colormap

Set the qubit colormap to the given one.

set_save_directory

Set the directory to which we save resulting figures to.

set_tc_colormap

Set the coupler colormap to the given one.

summarize

Print out a summary of the data stored within the QPUPlot object.

property chip_label: str#

The chip label, same as the DUT label.

property chad: CHAD#

The chip architecture definition (CHAD).

property figs: list[Figure]#

List of figures rather than list of dictionary of figures for compliance.

property observations: list[ObservationData | LocalObservation]#

The plain list of observations.

add_observations(observations)#

Add the given observations to our observations list.

It’s up to the caller of the method to decide where these observations came from.

Parameters:

observations (ObservationDefinition | Sequence[ObservationDefinition]) – This will be added to the QPUPlot’s observations list.

Return type:

None

add_observations_from_database(*, latest=True, all_tags=True, dut_fields=None, obs_params=None, run_id=None, tags=None, min_date=None, max_date=None)#

Add observations from database, filtering based on the provided criteria.

Parameters:
  • latest (bool) – Add only the latest observation for each DUT field. Otherwise add all observations for the given filters.

  • all_tags (bool) – Add the observations that satisfy all tags. Otherwise add observations that contain at least one tag if specified in tags.

  • dut_fields (list[str] | None) – The IDs of the type of observation in the database, e.g., component_name.parameter_name.

  • obs_params (list[Parameter] | None) – Add the observations with this parameter for each of the components on the chip if they have it.

  • run_id (UUID | None) – Add only the observations from the specified run ID.

  • tags (list[str] | None) – Tags to filter the observations. If this is the only argument, the latest observations for these tags are returned.

  • min_date (date | str | None) – Exclude observations with earlier created_timestamp. If defined as a string, it should be in ISO-8601 date format. Dates are not aware of timezones. Requires max_date to be set.

  • max_date (date | str | None) – Only include observations with earlier created_timestamp. If defined as a string, it should be in ISO-8601 date format. Dates are not aware of timezones. Requires min_date to be set.

Return type:

None

add_observations_from_stash(stash, components=None, observations=None, tags=None)#

Get observations from an existing stash, independently of their origin.

Parameters:
  • stash (ObservationStash) – ObservationStash to load from.

  • components (list[str] | None) – List of components to load observations for. Defaults to None.

  • observations (list[str] | None) – List of observations to load. Defaults to None.

  • tags (list[str] | None) – List of tags to load. Defaults to None.

Return type:

None

draw_all(save_directory=None, **kwargs)#

Draw all the plots for all the data we have.

Supported plots:
  • topology plot

  • cumulative histogram (CDF)

Parameters:
  • save_directory (Path | str | None) – The path to store the figures.

  • **kwargs – kwargs for topology and CDF plot methods.

Return type:

None

draw_topology(save_directory=None, include_comp_names=True, close_fig=False, **kwargs)#

Draw the topology plots for all the observations.

Parameters:
  • save_directory (Path | str | None) – If provided, the resulting plots are saved to that directory.

  • include_comp_names (bool) – If True, include labels for component names.

  • close_fig (bool) – If True, closes plt figures.

  • **kwargs – kwargs for topology plot methods.

Returns:

The topology plot for each observation parameter.

Return type:

dict[str, Figure]

draw_cdf(observation_types=None, save_directory=None, figsize=(6.0, 4.0), **kwargs)#

Draw a cumulative histogram plot for all the observations of the given obs_types.

The observations for each obs_type will be drawn on its own line, but in the same plot with the rest. The obs_types of the same unit will be plotted on the same plot, otherwise they will be drawn on different plots.

Parameters:
  • observation_types (list[str] | set[str] | None) – The types of observations to plot from observations gathered in QPUPlot.

  • save_directory (Path | str | None) – If provided, the resulting plot is saved to that directory.

  • figsize (tuple[float, float]) – Width, height in inches.

  • **kwargs – kwargs for plot multi cdf method.

Returns:

The CDF plot for each unit.

Return type:

dict[str, Figure]

draw_bar_chart(save_directory=None, **kwargs)#

Draw bar chart plots for the latest observations of a given type.

If one_per_dut_field = True, all observations (not only the latest) are plotted in a box plot.

Parameters:
  • save_directory (Path | str | None) – If provided, the resulting plots are saved to that directory.

  • **kwargs – kwargs for plot bar chart method.

Returns:

The bar chart for each observation parameter.

Return type:

dict[str, Figure]

draw_time_series(dut_fields, save_directory=None, **kwargs)#

Draw a time series plot for multiple DUT fields.

Parameters:
  • dut_fields (list[str]) – The fields for the time series.

  • save_directory (Path | str | None) – If provided, the resulting plots are saved to that directory.

  • **kwargs – kwargs for plot time series method.

Returns:

The time series plot.

Return type:

Figure

draw_histogram(save_directory=None, obs_types=None, **kwargs)#

Plot a histogram for observation.

Parameters:
  • save_directory (Path | str | None) – If directory is provided, figures are saved to the directory

  • obs_types (list[str] | None) – Similarly to CDF plot, histogram will only be provided for these (different histograms).

  • **kwargs – kwargs for plot histogram method.

Returns:

The histogram for each observation parameter.

Return type:

dict[str, Figure]

summarize()#

Print out a summary of the data stored within the QPUPlot object.

Return type:

None

set_save_directory(save_directory=None)#

Set the directory to which we save resulting figures to.

Leaving this blank will clear the save_directory.

Parameters:

save_directory (Path | None)

Return type:

None

set_colormaps(qb_colormap=<matplotlib.colors.ListedColormap object>, tc_colormap=<matplotlib.colors.ListedColormap object>, cr_colormap=<matplotlib.colors.ListedColormap object>, aux_colormap=<matplotlib.colors.ListedColormap object>)#

Set the colormaps to the given ones. Default is IQM colormap for both qubits and couplers.

Return type:

None

set_qb_colormap(colormap=<matplotlib.colors.ListedColormap object>)#

Set the qubit colormap to the given one. Default is IQM colormap.

Return type:

None

set_tc_colormap(colormap=<matplotlib.colors.ListedColormap object>)#

Set the coupler colormap to the given one. Default is IQM colormap.

Return type:

None

set_cr_colormap(colormap=<matplotlib.colors.ListedColormap object>)#

Set the computational resonator colormap to the given one. Default is IQM colormap.

Return type:

None

set_aux_colormap(colormap=<matplotlib.colors.ListedColormap object>)#

Set the auxiliary colormap. Default is IQM colormap.

Return type:

None

convert_fidelity_and_error()#

Converts fidelities to errors and errors to fidelities.

Note that in order to convert, we create new local observations with the correct parameters and delete the old ones, so this function is not perfectly reversible.

Return type:

None

Inheritance

Inheritance diagram of exa.core.plotting.qpu_plot.QPUPlot