diff --git a/pyquil/external/rpcq.py b/pyquil/external/rpcq.py index 4cda09ef1..714f4f7cb 100644 --- a/pyquil/external/rpcq.py +++ b/pyquil/external/rpcq.py @@ -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): @@ -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: diff --git a/readthedocs.yml b/readthedocs.yml index f5d0120f1..1f02e55d8 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -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: diff --git a/test/unit/test_graph.py b/test/unit/test_graph.py index 837b3d7a1..902420512 100644 --- a/test/unit/test_graph.py +++ b/test/unit/test_graph.py @@ -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