Skip to content

Commit

Permalink
CouplingMap: fix docstrings (Qiskit#7244)
Browse files Browse the repository at this point in the history
* CouplingMap: fix docstrings

Correct typos in CouplingMap constructors

* CouplingMap: add return type to generators

* Remove duplication from docstrings

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 12, 2021
1 parent 205c7fe commit a603740
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions qiskit/transpiler/coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def reduce(self, mapping):
return CouplingMap(reduced_cmap)

@classmethod
def from_full(cls, num_qubits, bidirectional=True):
def from_full(cls, num_qubits, bidirectional=True) -> "CouplingMap":
"""Return a fully connected coupling map on n qubits."""
cmap = cls(description="full")
if bidirectional:
Expand All @@ -298,31 +298,31 @@ def from_full(cls, num_qubits, bidirectional=True):
return cmap

@classmethod
def from_line(cls, num_qubits, bidirectional=True):
"""Return a fully connected coupling map on n qubits."""
def from_line(cls, num_qubits, bidirectional=True) -> "CouplingMap":
"""Return a coupling map of n qubits connected in a line."""
cmap = cls(description="line")
cmap.graph = rx.generators.directed_path_graph(num_qubits, bidirectional=bidirectional)
return cmap

@classmethod
def from_ring(cls, num_qubits, bidirectional=True):
"""Return a fully connected coupling map on n qubits."""
def from_ring(cls, num_qubits, bidirectional=True) -> "CouplingMap":
"""Return a coupling map of n qubits connected to each of their neighbors in a ring."""
cmap = cls(description="ring")
cmap.graph = rx.generators.directed_cycle_graph(num_qubits, bidirectional=bidirectional)
return cmap

@classmethod
def from_grid(cls, num_rows, num_columns, bidirectional=True):
"""Return qubits connected on a grid of num_rows x num_columns."""
def from_grid(cls, num_rows, num_columns, bidirectional=True) -> "CouplingMap":
"""Return a coupling map of qubits connected on a grid of num_rows x num_columns."""
cmap = cls(description="grid")
cmap.graph = rx.generators.directed_grid_graph(
num_rows, num_columns, bidirectional=bidirectional
)
return cmap

@classmethod
def from_heavy_hex(cls, distance, bidirectional=True):
"""Return a heavy hexagon graph coupling map
def from_heavy_hex(cls, distance, bidirectional=True) -> "CouplingMap":
"""Return a heavy hexagon graph coupling map.
A heavy hexagon graph is described in:
Expand All @@ -345,7 +345,7 @@ def from_heavy_hex(cls, distance, bidirectional=True):
return cmap

@classmethod
def from_heavy_square(cls, distance, bidirectional=True):
def from_heavy_square(cls, distance, bidirectional=True) -> "CouplingMap":
"""Return a heavy square graph coupling map.
A heavy square graph is described in:
Expand All @@ -371,7 +371,7 @@ def from_heavy_square(cls, distance, bidirectional=True):
return cmap

@classmethod
def from_hexagonal_lattice(cls, rows, cols, bidirectional=True):
def from_hexagonal_lattice(cls, rows, cols, bidirectional=True) -> "CouplingMap":
"""Return a hexagonal lattice graph coupling map.
Args:
Expand Down

0 comments on commit a603740

Please sign in to comment.