Skip to content

Commit 7e6bc39

Browse files
⬆️🐍 Lock file maintenance (#386)
This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/munich-quantum-toolkit/predictor). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xNi4wIiwidXBkYXRlZEluVmVyIjoiNDAuNDguNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIiwicHl0aG9uIl19--> --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Patrick Hopf <81010725+flowerthrower@users.noreply.github.com> Co-authored-by: flowerthrower <flowerthrower@users.noreply.github.com>
1 parent 8fa2f5a commit 7e6bc39

4 files changed

Lines changed: 168 additions & 152 deletions

File tree

src/mqt/predictor/reward.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from __future__ import annotations
1212

1313
import logging
14-
from typing import TYPE_CHECKING, Literal, cast
14+
from typing import TYPE_CHECKING, Literal
1515

1616
import numpy as np
1717
from joblib import load
@@ -37,7 +37,7 @@
3737
def crit_depth(qc: QuantumCircuit, precision: int = 10) -> float:
3838
"""Calculates the critical depth of a given quantum circuit."""
3939
supermarq_features = calc_supermarq_features(qc)
40-
return cast("float", np.round(1 - supermarq_features.critical_depth, precision))
40+
return float(np.round(1 - supermarq_features.critical_depth, precision).item())
4141

4242

4343
def expected_fidelity(qc: QuantumCircuit, device: Device, precision: int = 10) -> float:
@@ -71,7 +71,7 @@ def expected_fidelity(qc: QuantumCircuit, device: Device, precision: int = 10) -
7171

7272
res *= specific_fidelity
7373

74-
return cast("float", np.round(res, precision))
74+
return float(np.round(res, precision).item())
7575

7676

7777
def calc_qubit_index(qargs: list[Qubit], qregs: list[QuantumRegister], index: int) -> int:
@@ -178,7 +178,7 @@ def estimated_success_probability(qc: QuantumCircuit, device: Device, precision:
178178
second_qubit_idx = calc_qubit_index(qargs, qc.qregs, 1)
179179
res *= device.get_two_qubit_gate_fidelity(gate_type, first_qubit_idx, second_qubit_idx)
180180

181-
return cast("float", np.round(res, precision))
181+
return float(np.round(res, precision).item())
182182

183183

184184
def esp_data_available(device: Device) -> bool:
@@ -260,4 +260,4 @@ def estimated_hellinger_distance(
260260
feature_vector = calc_device_specific_features(qc, device)
261261

262262
res = model.predict([feature_vector])
263-
return cast("float", np.round(res, precision))
263+
return float(np.round(res, precision).item())

tests/device_selection/test_predictor_ml.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,23 @@ def test_train_random_forest_classifier_and_predict(predictor: ml.Predictor, sou
123123

124124
def test_remove_files(source_path: Path, target_path: Path) -> None:
125125
"""Remove files created during testing."""
126-
for file in source_path.iterdir():
127-
if file.suffix == ".qasm":
128-
file.unlink()
129-
for file in target_path.iterdir():
130-
if file.suffix == ".qasm":
131-
file.unlink()
132-
source_path.rmdir()
133-
target_path.rmdir()
134-
135-
for file in (ml.helper.get_path_training_data() / "training_data_aggregated").iterdir():
136-
if file.suffix == ".npy":
137-
file.unlink()
126+
if source_path.exists():
127+
for file in source_path.iterdir():
128+
if file.suffix == ".qasm":
129+
file.unlink()
130+
source_path.rmdir()
131+
132+
if target_path.exists():
133+
for file in target_path.iterdir():
134+
if file.suffix == ".qasm":
135+
file.unlink()
136+
target_path.rmdir()
137+
138+
data_path = ml.helper.get_path_training_data() / "training_data_aggregated"
139+
if data_path.exists():
140+
for file in data_path.iterdir():
141+
if file.suffix == ".npy":
142+
file.unlink()
138143

139144

140145
def test_predict_device_for_figure_of_merit_no_suitable_device() -> None:

tests/hellinger_distance/test_estimated_hellinger_distance.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,29 @@ def test_train_and_qcompile_with_hellinger_model(source_path: Path, target_path:
175175

176176
def test_remove_files(source_path: Path, target_path: Path) -> None:
177177
"""Remove files created during testing."""
178-
for file in source_path.iterdir():
179-
if file.suffix == ".qasm":
180-
file.unlink()
181-
for file in target_path.iterdir():
182-
if file.suffix == ".qasm":
183-
file.unlink()
184-
source_path.rmdir()
185-
target_path.rmdir()
186-
187-
for file in (ml.helper.get_path_training_data() / "training_data_aggregated").iterdir():
188-
if file.suffix == ".npy":
189-
file.unlink()
190-
191-
for file in (ml.helper.get_path_training_data() / "trained_model").iterdir():
192-
if file.suffix == ".joblib":
193-
file.unlink()
178+
if source_path.exists():
179+
for file in source_path.iterdir():
180+
if file.suffix == ".qasm":
181+
file.unlink()
182+
source_path.rmdir()
183+
184+
if target_path.exists():
185+
for file in target_path.iterdir():
186+
if file.suffix == ".qasm":
187+
file.unlink()
188+
target_path.rmdir()
189+
190+
data_path = ml.helper.get_path_training_data() / "training_data_aggregated"
191+
if data_path.exists():
192+
for file in data_path.iterdir():
193+
if file.suffix == ".npy":
194+
file.unlink()
195+
196+
model_path = ml.helper.get_path_training_data() / "trained_model"
197+
if model_path.exists():
198+
for file in model_path.iterdir():
199+
if file.suffix == ".joblib":
200+
file.unlink()
194201

195202

196203
def test_predict_device_for_estimated_hellinger_distance_no_device_provided() -> None:

0 commit comments

Comments
 (0)