Skip to content

Commit

Permalink
adapt to new qiskit version.
Browse files Browse the repository at this point in the history
  • Loading branch information
pehamTom committed Nov 7, 2023
1 parent 91ecd04 commit cd4e37d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
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:',
'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

0 comments on commit cd4e37d

Please sign in to comment.