Skip to content

Commit

Permalink
Don't assume parameter vector names are unique
Browse files Browse the repository at this point in the history
 #Fix conflicts
  • Loading branch information
ElePT committed Jan 23, 2025
1 parent 400f22d commit 0de998b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions qiskit/qpy/binary_io/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,9 @@ def _read_parameter_vec(file_obj, vectors):
)
param_uuid = uuid.UUID(bytes=data.uuid)
name = file_obj.read(data.vector_name_size).decode(common.ENCODE)
if name not in vectors:
vectors[name] = (ParameterVector(name, data.vector_size), set())

# if name not in vectors:
vectors[name] = (ParameterVector(name, data.vector_size), set())
vector = vectors[name][0]
if vector[data.index].uuid != param_uuid:
vectors[name][1].add(data.index)
Expand Down
9 changes: 9 additions & 0 deletions test/qpy_compat/test_qpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,14 @@ def generate_clifford_circuits():
return [qc]


def generate_blueprint_circuits():
"""Test qpy with blueprint circuits."""
from qiskit.circuit.library import PauliFeatureMap

qc = PauliFeatureMap(feature_dimension=5, reps=1)
return [qc]


def generate_annotated_circuits():
"""Test qpy circuits with annotated operations."""
from qiskit.circuit import AnnotatedOperation, ControlModifier, InverseModifier, PowerModifier
Expand Down Expand Up @@ -829,6 +837,7 @@ def generate_circuits(version_parts):
"string_parameters.qpy": [generate_string_parameters()],
"register_edge_cases.qpy": generate_register_edge_cases(),
"parameterized.qpy": [generate_parameterized_circuit()],
"blueprint.qpy": [generate_blueprint_circuits()],
}
if version_parts is None:
return output_circuits
Expand Down

0 comments on commit 0de998b

Please sign in to comment.