Skip to content

Commit

Permalink
fix: CompilerISA.dict() now uses the correct default field names: qub…
Browse files Browse the repository at this point in the history
…its and edges (#1746)

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

* ci: update poetry rtd config

* with doesn't work

* new poetry is borked
  • Loading branch information
MarquessV authored Feb 27, 2024
1 parent eb206fd commit 65240a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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

0 comments on commit 65240a0

Please sign in to comment.