utilsΒΆ

Experiment Utilities (qurry.qurrium.experiment.utils)

qurry.qurrium.experiment.utils.create_save_location(save_location: str | Path | None, commons: Commonparams | None = None) Path[source]ΒΆ

Create a save location for the experiment.

Parameters:
  • save_location (Optional[str]) – The save location of the experiment.

  • commons (Optional[Commonparams]) – The common parameters of the experiment. It is used to get the default save location if save_location is None.

Returns:

The save location as a Path object.

Return type:

Path

Raises:

ValueError – If save_location is not a Path or str, or if it is None and commons is also None.

qurry.qurrium.experiment.utils.decide_folder_and_filename(commons: Commonparams, args: ArgumentsPrototype) tuple[str, str][source]ΒΆ

Decide the folder and filename for the experiment.

Parameters:
Returns:

The folder and filename for the experiment.

Return type:

tuple[str, str]

qurry.qurrium.experiment.utils.exp_id_process(exp_id: str | None) str[source]ΒΆ

Check the exp_id is valid or not, if not, then generate a new one.

Parameters:

exp_id (Optional[str]) – The id of the experiment to be checked.

Returns:

The valid exp_id.

Return type:

str

qurry.qurrium.experiment.utils.folder_with_repeat_times(exp_name: str, repeat_times: int) str[source]ΒΆ

Create a folder with repeat times.

Parameters:
  • exp_name (str) – The name of the experiment.

  • repeat_times (int, optional) – The repeat times of the experiment. Defaults to 1.

Returns:

The folder name with repeat times.

Return type:

str

qurry.qurrium.experiment.utils.implementation_check(name_exps: str, args: ArgumentsPrototype, commons: Commonparams) None[source]ΒΆ

Check whether the experiment is implemented correctly.

qurry.qurrium.experiment.utils.make_statesheet(exp_name: str, args: ArgumentsPrototype, commons: Commonparams, outfields: dict[str, str], beforewards: Before, afterwards: After, reports: AnalysesContainer, report_expanded: bool = False, hoshi: bool = False) Hoshi[source]ΒΆ

Show the state of experiment.

Parameters:
  • exp_name (str) – Name of the experiment.

  • args (ArgumentsPrototype) – Arguments of the experiment.

  • commons (Commonparams) – Common parameters of the experiment.

  • outfields (dict[str, str]) – Unused arguments.

  • beforewards (Before) – Beforewards of the experiment.

  • afterwards (After) – Afterwards of the experiment.

  • reports (AnalysesContainer) – Reports of the experiment.

  • report_expanded (bool, optional) – Show more infomation. Defaults to False.

  • hoshi (bool, optional) – Showing name of Hoshi. Defaults to False.

Returns:

Statesheet of experiment.

Return type:

Hoshi

qurry.qurrium.experiment.utils.memory_usage_factor_expect(target: list[tuple[Hashable, QuantumCircuit | str]], circuits: list[QuantumCircuit], commonparams: Commonparams) int[source]ΒΆ

Estimate the memory usage of :cls:`ExperimentPrototype` by the circuits.

The memory usage is estimated by the number of instructions in the circuits and the number of shots. The factor is calculated by the formula:

where target_circuit_instructions_num is the number of instructions in the target circuits, transpiled_circuit_instructions_num is the number of instructions in the circuits which has been transpiled and will be run on the backend, and shots is the number of shots.

The factor is rounded to the nearest integer. The factor is used to estimate the memory usage of the experiment.

Parameters:
  • circuits (list[QuantumCircuit]) – The circuits to be estimated.

  • commonparams (Commonparams) – The common parameters of the experiment.

Returns:

The factor of the memory usage.

Return type:

int

qurry.qurrium.experiment.utils.summonner_check(serial: int | None, summoner_id: str | None, summoner_name: str | None)[source]ΒΆ

Check the summoner information taken from the experiment.

Parameters:
  • serial (Optional[int]) – The serial number of the experiment.

  • summoner_id (Optional[str]) – The ID of the summoner.

  • summoner_name (Optional[str]) – The name of the summoner.

Raises:

QurrySummonerInvalid – If the summoner information is not completed.

Returns:

True if the summoner information is completed, False otherwise.

Return type:

bool