Skip to content

Commit

Permalink
Revert "Fix errors after stub typing PR (#994)"
Browse files Browse the repository at this point in the history
This reverts commit ca98542.
  • Loading branch information
cqc-alec committed Sep 2, 2023
1 parent 75af8b3 commit d1cb5c4
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 30 deletions.
12 changes: 2 additions & 10 deletions pytket/binders/circuit/Circuit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,25 +895,17 @@ void def_circuit(py::class_<Circuit, std::shared_ptr<Circuit>> &pyCircuit) {
// set of tuples (source node, target node, source port, target
// port, edge type)
std::set<
std::tuple<unsigned, unsigned, unsigned, unsigned, std::string>>
std::tuple<unsigned, unsigned, unsigned, unsigned, EdgeType>>
edge_data;
BGL_FORALL_EDGES(e, circ.dag, DAG) {
Vertex v_so = circ.source(e);
Vertex v_ta = circ.target(e);
unsigned v_s = im[v_so];
unsigned v_t = im[v_ta];
EdgeType edge_type = circ.dag[e].type;
// This transformation is necessary due to a bug encountered
// with pybind11 on mac0S 11 only, that causes the python sided
// Enum class to take nonsensical values
std::string edge_type_str =
(edge_type == EdgeType::Quantum) ? "Quantum"
: (edge_type == EdgeType::Boolean) ? "Boolean"
: (edge_type == EdgeType::Classical) ? "Classical"
: "WASM";
edge_data.insert(
{v_s, v_t, circ.get_source_port(e), circ.get_target_port(e),
edge_type_str});
edge_type});
}

return std::make_tuple(
Expand Down
2 changes: 1 addition & 1 deletion pytket/pytket/_tket/circuit.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ class Circuit:
def __rshift__(self, arg0: Circuit) -> Circuit: ...
def __setstate__(self, arg0: tuple) -> None: ...
@property
def _dag_data(self) -> Tuple[set[int],set[int],set[int],set[int],set[int],set[int],Dict[int,str],Dict[int,str],Dict[int,str],set[Tuple[int,int,int,int,str]]]: ...
def _dag_data(self) -> Tuple[set[int],set[int],set[int],set[int],set[int],set[int],Dict[int,str],Dict[int,str],Dict[int,str],set[Tuple[int,int,int,int,EdgeType]]]: ...
@property
def bit_readout(self) -> Dict[pytket._tket.unit_id.Bit,int]: ...
@property
Expand Down
13 changes: 6 additions & 7 deletions pytket/pytket/utils/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import networkx as nx # type: ignore
import graphviz as gv # type: ignore

from pytket._tket.circuit import EdgeType
from pytket.circuit import Circuit


Expand Down Expand Up @@ -60,9 +61,7 @@ def __init__(self, c: Circuit):
self.Gnx: Optional[nx.MultiDiGraph] = None
self.G: Optional[gv.Digraph] = None
self.Gqc: Optional[gv.Graph] = None
self.edge_data: dict[tuple[int, int], list[tuple[int, int, str]]] = defaultdict(
list
)
self.edge_data = defaultdict(list)
self.port_counts: dict = defaultdict(int)
for src_node, tgt_node, src_port, tgt_port, edge_type in edge_data:
self.edge_data[(src_node, tgt_node)].append((src_port, tgt_port, edge_type))
Expand Down Expand Up @@ -224,10 +223,10 @@ def get_DAG(self) -> gv.Digraph:
for i in range(n_ports):
c.node(name=str((node, i)), xlabel=str(i), **port_node_attr)
edge_colors = {
"Quantum": q_color,
"Boolean": b_color,
"Classical": c_color,
"WASM": w_color,
EdgeType.Quantum: q_color,
EdgeType.Boolean: b_color,
EdgeType.Classical: c_color,
EdgeType.WASM: w_color,
}
edge_attr = {
"weight": "2",
Expand Down
Empty file added pytket/tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion pytket/tests/assertion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)

from pytket.pauli import PauliStabiliser, Pauli
from simulator import TketSimShotBackend # type: ignore
from .simulator import TketSimShotBackend


def test_assertion_init() -> None:
Expand Down
4 changes: 2 additions & 2 deletions pytket/tests/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from pytket.backends.backend_exceptions import InvalidResultType, CircuitNotRunError
from pytket.backends.status import CircuitStatus, StatusEnum

from strategies import outcomearrays, backendresults # type: ignore
from simulator import TketSimShotBackend, TketSimBackend # type: ignore
from .strategies import outcomearrays, backendresults
from .simulator import TketSimShotBackend, TketSimBackend


def test_resulthandle() -> None:
Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/backendinfo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pytket.architecture import SquareGrid, RingArch, FullyConnected
from pytket.circuit import OpType, Node

import strategies as st # type: ignore
import tests.strategies as st


def test_nodes() -> None:
Expand Down
4 changes: 2 additions & 2 deletions pytket/tests/circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
import pytest # type: ignore

from hypothesis import given, settings
import strategies as st # type: ignore
from useful_typedefs import ParamType # type: ignore
import tests.strategies as st
from tests.useful_typedefs import ParamType

curr_file_path = Path(__file__).resolve().parent

Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/classical_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

from pytket.passes import DecomposeClassicalExp, FlattenRegisters

from strategies import reg_name_regex, binary_digits, uint32 # type: ignore
from .strategies import reg_name_regex, binary_digits, uint32

curr_file_path = Path(__file__).resolve().parent

Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/passes_serialisation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
MultiGateReorderRoutingMethod,
BoxDecompositionRoutingMethod,
)
from useful_typedefs import ParamType # type: ignore
from tests.useful_typedefs import ParamType


def standard_pass_dict(content: Dict[str, Any]) -> Dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/predicates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
from sympy import Symbol
from typing import Dict, Any, List, cast

from useful_typedefs import ParamType as Param # type: ignore
from tests.useful_typedefs import ParamType as Param


circ2 = Circuit(1)
Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/qubitpaulioperator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pytket.pauli import Pauli, QubitPauliString, pauli_string_mult
from pytket.circuit import Qubit

import strategies as st # type: ignore
import tests.strategies as st


def test_QubitPauliOperator_addition() -> None:
Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/transform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import json
import pytest

from useful_typedefs import ParamType # type: ignore
from .useful_typedefs import ParamType


def get_test_circuit() -> Circuit:
Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import types
from sympy import symbols # type: ignore
from typing import Any, Callable, Tuple, Dict, List
from simulator import TketSimShotBackend, TketSimBackend # type: ignore
from .simulator import TketSimShotBackend, TketSimBackend


def test_append_measurements() -> None:
Expand Down

0 comments on commit d1cb5c4

Please sign in to comment.