qdesignoptimizer.utils.plotting module

Additional plotting utilities for loading and visualizing optimization results from files.

qdesignoptimizer.utils.plotting.load_data_by_date(folder_parent: str, name_experiment: str, experiment_beginning: str, experiment_end: str) List[str][source]

Load optimization data files within a specified date range and experiment name.

Searches a directory for .npy files matching an experiment name and falling within a specified date range. The function extracts dates from filenames following the convention ‘experiment_name_YYYYMMDD-HHMMSS.npy’.

Parameters:
  • folder_parent – Directory path containing the optimization result files.

  • name_experiment – Experiment name to filter files (e.g., “multi_transmon_chip”).

  • experiment_beginning – Start date in ‘YYYYMMDD-HHMMSS’ format, either as full filename or just the date portion.

  • experiment_end – End date in ‘YYYYMMDD-HHMMSS’ format, either as full filename or just the date portion.

Returns:

List of full file paths for matching optimization result files.

Example

>>> files = load_data_by_date(
...     "results/",
...     "multi_transmon_chip",
...     "20250306-165308",
...     "20250308-120000"
... )
qdesignoptimizer.utils.plotting.plot_optimization_results(files: List[str], plot_variance: bool = True, plot_design_variables: Literal['chronological', 'sorted'] | None = None, opt_target_list: List[OptTarget] | None = None, plot_settings: dict | None = None, save_figures: bool = True) None[source]

Plot optimization results from multiple data files.

Loads optimization data from provided file paths and creates visualizations using the plot_progress function. Handles multiple optimization runs and configures plotting options for parameter visualization.

Parameters:
  • files – List of file paths to optimization result files (.npy format).

  • plot_variance – Whether to show mean and standard deviation across multiple optimization runs (True) or individual lines for each run (False). Defaults to True.

  • plot_design_variables

    How design variables should be plotted against parameters:

    • ”chronological”: Plot in order of iterations

    • ”sorted”: Sort by design variable values

    • None: Don’t plot design variables

    Note that some target parameters may depend on multiple design variables, so these plots may not capture the full physics.

  • opt_target_list – List of optimization targets defining relationships between physical parameters and design variables. Required when plot_design_variables is set.

  • save_figures – Whether to save generated plots to disk. Defaults to True.

Raises:

AssertionError – If loaded optimization results have inconsistent target parameters or different numbers of iterations.

Example

>>> files = load_data_by_date("results/", "transmon", "20250306-165308", "20250308-120000")
>>> targets = get_opt_targets_qb_res_transmission("qubit_1", "resonator_1", "feedline")
>>> plot_optimization_results(
...     files,
...     plot_variance=True,
...     plot_design_variables="sorted",
...     opt_target_list=targets
... )