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

fix: CompilerISA.dict() now uses the correct default field names: qubits and edges #1746

Merged
merged 4 commits into from
Feb 27, 2024
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
12 changes: 6 additions & 6 deletions pyquil/external/rpcq.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ class CompilerISA:
qubits: Dict[str, Qubit] = field(default_factory=dict)
edges: Dict[str, Edge] = field(default_factory=dict)

def _dict(self) -> Dict[str, JsonValue]:
def _dict(self, by_alias=False) -> Dict[str, JsonValue]:
return {
"1Q": {k: q._dict() for k, q in self.qubits.items()},
"2Q": {k: e._dict() for k, e in self.edges.items()},
"1Q" if by_alias else "qubits": {k: q._dict() for k, q in self.qubits.items()},
"2Q" if by_alias else "edges": {k: e._dict() for k, e in self.edges.items()},
}

@deprecated(
version="4.6.2",
reason="No longer requires serialization of RPCQ objects and is dropping Pydantic as a dependency.", # noqa: E501
)
def dict(self):
return self._dict()
def dict(self, by_alias=False):
return self._dict(by_alias=by_alias)

@classmethod
def _parse_obj(cls, dictionary: Dict):
Expand Down Expand Up @@ -288,7 +288,7 @@ def get_edge(quantum_processor: CompilerISA, qubit1: int, qubit2: int) -> Option


def compiler_isa_to_target_quantum_processor(compiler_isa: CompilerISA) -> TargetQuantumProcessor:
return TargetQuantumProcessor(isa=compiler_isa._dict(), specs={})
return TargetQuantumProcessor(isa=compiler_isa.dict(by_alias=True), specs={})


class Supported1QGate:
Expand Down
2 changes: 1 addition & 1 deletion readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
- pip install 'poetry==1.6.1'
# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_isa_from_graph_order():
# representation will have it as (16,15)
fc = nx.from_edgelist([(16, 17), (15, 16)])
isa = graph_to_compiler_isa(fc)
isad = isa.dict()
isad = isa.dict(by_alias=True)
for k in isad["2Q"]:
q1, q2 = k.split("-")
assert q1 < q2
Expand Down
Loading