Skip to content

Commit

Permalink
Add missing typing stubs, so mypy check passes
Browse files Browse the repository at this point in the history
  • Loading branch information
ABorgna committed Mar 29, 2024
1 parent b040742 commit c21ecca
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
77 changes: 77 additions & 0 deletions pybindings/quizx/_quizx.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Type stubs for the Rust bindings

from typing import final

@final
class VecGraph:
def vindex(self) -> int: ...
def neighbor_at(self, v: int, n: int) -> int: ...
def num_vertices(self) -> int: ...
def num_edges(self) -> int: ...
def add_vertex(
self, ty_num: int, qubit: int, row: int, phase: tuple[int, int]
) -> int: ...
def contains_vertex(self, v: int) -> bool: ...
def add_edge(self, e: tuple[int, int], et_num: int) -> None: ...
def add_edge_smart(self, e: tuple[int, int], et_num: int) -> None: ...
def remove_vertex(self, v: int) -> None: ...
def remove_edge(self, e: tuple[int, int]) -> None: ...
def degree(self, v: int) -> int: ...
def connected(self, s: int, t: int) -> bool: ...
def vertex_type(self, v: int) -> int: ...
def set_vertex_type(self, v: int, ty_num: int) -> None: ...
def edge_type(self, e: tuple[int, int]) -> int: ...
def set_edge_type(self, e: tuple[int, int], et_num: int) -> None: ...
def phase(self, v: int) -> tuple[int, int]: ...
def set_phase(self, v: int, phase: tuple[int, int]) -> None: ...
def add_to_phase(self, v: int, phase: tuple[int, int]) -> None: ...
def qubit(self, v: int) -> int: ...
def set_qubit(self, v: int, q: int) -> None: ...
def row(self, v: int) -> int: ...
def set_row(self, v: int, r: int) -> None: ...
def inputs(self) -> list[int]: ...
def num_inputs(self) -> int: ...
def set_inputs(self, inputs: list[int]) -> None: ...
def outputs(self) -> list[int]: ...
def num_outputs(self) -> int: ...
def set_outputs(self, outputs: list[int]) -> None: ...

@final
class Circuit:
@staticmethod
def from_qasm(qasm: str) -> Circuit: ...
@staticmethod
def load(file: str) -> Circuit: ...
def to_qasm(self) -> str: ...
def to_graph(self) -> VecGraph: ...
def num_gates(self) -> int: ...
def stats(self) -> str: ...

@final
class CircuitStats:
def qubits(self) -> int: ...
def total(self) -> int: ...
def oneq(self) -> int: ...
def twoq(self) -> int: ...
def moreq(self) -> int: ...
def cliff(self) -> int: ...
def non_cliff(self) -> int: ...
def to_string(self) -> str: ...

@final
class Decomposer:
@staticmethod
def empty() -> Decomposer: ...
def __init__(self, g: VecGraph) -> None: ...
def graphs(self) -> list[VecGraph]: ...
def apply_optimizations(self, b: bool) -> None: ...
def max_terms(self) -> int: ...
def decomp_top(self) -> None: ...
def decomp_all(self) -> None: ...
def decomp_until_depth(self, depth: int) -> None: ...

def dummy(a: int) -> str: ...
def interior_clifford_simp(g: VecGraph): ...
def clifford_simp(g: VecGraph): ...
def full_simp(g: VecGraph): ...
def extract_circuit(g: VecGraph) -> Circuit: ...
Empty file added pybindings/quizx/py.typed
Empty file.
1 change: 1 addition & 0 deletions pybindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn _quizx(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(extract_circuit, m)?)?;
m.add_class::<VecGraph>()?;
m.add_class::<Circuit>()?;
m.add_class::<CircuitStats>()?;
m.add_class::<Decomposer>()?;
Ok(())
}
Expand Down

0 comments on commit c21ecca

Please sign in to comment.