Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt to new qiskit version. #327

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ log_cli_level = "INFO"
xfail_strict = true
filterwarnings = [
"error",
'ignore:.*`product` is deprecated.*:DeprecationWarning:qiskit:',
'ignore:.*qiskit.__qiskit_version__.*:DeprecationWarning:qiskit:',
'ignore:.*encountered in det.*:RuntimeWarning:numpy.linalg:',
burgholzer marked this conversation as resolved.
Show resolved Hide resolved
'ignore:.*qiskit.utils.algorithm_globals.QiskitAlgorithmGlobals*:DeprecationWarning:qiskit',
'ignore:.*Building a flow controller with keyword arguments is going to be deprecated*:PendingDeprecationWarning:qiskit',
]

[tool.coverage]
Expand Down
15 changes: 8 additions & 7 deletions src/mqt/qcec/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def check_instantiated_random(
for p in params:
param_map[p] = rng.random() * 2 * np.pi

circ1_inst = circ1.bind_parameters(param_map)
circ2_inst = circ2.bind_parameters(param_map)
circ1_inst = circ1.assign_parameters(param_map)
circ2_inst = circ2.assign_parameters(param_map)

return check_instantiated(circ1_inst, circ2_inst, configuration)

Expand Down Expand Up @@ -156,14 +156,15 @@ def instantiate_params(
mat_pinv = np.linalg.pinv(mat)
x = np.dot(mat_pinv, b)
param_map = {param: x[i] for i, param in enumerate(parameters)}
qc1_bound = qc1.bind_parameters(param_map)
qc2_bound = qc2.bind_parameters(param_map)
qc1_bound = qc1.assign_parameters(param_map)
qc2_bound = qc2.assign_parameters(param_map)

def round_zero_params(qc: QuantumCircuit) -> QuantumCircuit:
for instr in qc.data:
params = instr[0].params
instr[0].params = [float(x) for x in params]
instr[0].params = [0 if np.abs(x) < tol else x for x in instr[0].params]
if not hasattr(instr[0], "mutable") or instr[0].mutable:
params = instr[0].params
instr[0].params = [float(x) for x in params]
instr[0].params = [0 if np.abs(x) < tol else x for x in instr[0].params]
return qc

qc1_bound = round_zero_params(qc1_bound)
Expand Down