Skip to content

Commit

Permalink
Merge pull request #31 from hashberg-io/update-deps
Browse files Browse the repository at this point in the history
Update deps
  • Loading branch information
sg495 authored Apr 3, 2024
2 parents 1ab888b + 6e4343a commit 6798e19
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 67 deletions.
3 changes: 1 addition & 2 deletions pauliopt/pauli/clifford_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def __init__(self, c_type):
self.c_type = c_type

@abstractmethod
def propagate_pauli(self, gadget: PauliGadget):
...
def propagate_pauli(self, gadget: PauliGadget): ...


class SingleQubitGate(CliffordGate, ABC):
Expand Down
12 changes: 4 additions & 8 deletions pauliopt/phase/cx_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,10 @@ def from_parity_matrix(
return CXCircuit(topology, layers, output_mapping=permutation)

@overload
def __getitem__(self, layer_idx: int) -> CXCircuitLayer:
...
def __getitem__(self, layer_idx: int) -> CXCircuitLayer: ...

@overload
def __getitem__(self, layer_idx: slice) -> Sequence[CXCircuitLayer]:
...
def __getitem__(self, layer_idx: slice) -> Sequence[CXCircuitLayer]: ...

def __getitem__(self, layer_idx):
return self._layers[layer_idx]
Expand Down Expand Up @@ -892,12 +890,10 @@ def draw(
)

@overload
def __getitem__(self, layer_idx: int) -> CXCircuitLayerView:
...
def __getitem__(self, layer_idx: int) -> CXCircuitLayerView: ...

@overload
def __getitem__(self, layer_idx: slice) -> Sequence[CXCircuitLayerView]:
...
def __getitem__(self, layer_idx: slice) -> Sequence[CXCircuitLayerView]: ...

def __getitem__(self, layer_idx):
return CXCircuitLayerView(self._circuit[layer_idx])
Expand Down
3 changes: 1 addition & 2 deletions pauliopt/phase/optimized_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class AnnealingCostLogger(Protocol):
Protocol for logger of initial/final cost in annealing.
"""

def __call__(self, cx_count: int, num_iters: int):
...
def __call__(self, cx_count: int, num_iters: int): ...


@runtime_checkable
Expand Down
30 changes: 11 additions & 19 deletions pauliopt/phase/phase_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,8 +1224,7 @@ def to_svg(
vscale: float = 1.0,
scale: float = 1.0,
svg_code_only: Literal[True],
) -> str:
...
) -> str: ...

@overload
def to_svg(
Expand All @@ -1237,8 +1236,7 @@ def to_svg(
vscale: float = 1.0,
scale: float = 1.0,
svg_code_only: Literal[False] = False,
) -> Any:
...
) -> Any: ...

def to_svg(
self,
Expand Down Expand Up @@ -1293,8 +1291,7 @@ def _to_svg(
vscale: float = 1.0,
scale: float = 1.0,
svg_code_only: Literal[True],
) -> str:
...
) -> str: ...

@overload
def _to_svg(
Expand All @@ -1306,8 +1303,7 @@ def _to_svg(
vscale: float = 1.0,
scale: float = 1.0,
svg_code_only: Literal[False] = False,
) -> Any:
...
) -> Any: ...

def _to_svg(
self,
Expand Down Expand Up @@ -1619,9 +1615,9 @@ def simplified(self) -> "PhaseCircuit":
angles_fuse[qubits] = angle
if angles_fuse[qubits].is_pi:
# This is a pi gadget, further simplification to be performed
angles_fuse[
qubits
] = Angle.zero # Remove gadget from this group
angles_fuse[qubits] = (
Angle.zero
) # Remove gadget from this group
pi_gadget = True
elif angle.is_pi:
# We didn't manage to commute the gadget, but it is a pi gadget
Expand Down Expand Up @@ -1704,12 +1700,10 @@ def _reindex(self, idx: int) -> int:
raise IndexError(f"Invalid gadget index {idx}")

@overload
def __getitem__(self, idx: int) -> PhaseGadget:
...
def __getitem__(self, idx: int) -> PhaseGadget: ...

@overload
def __getitem__(self, idx: slice) -> "PhaseCircuit":
...
def __getitem__(self, idx: slice) -> "PhaseCircuit": ...

def __getitem__(self, idx: Union[int, slice]) -> Union[PhaseGadget, "PhaseCircuit"]:
if isinstance(idx, int):
Expand Down Expand Up @@ -2102,8 +2096,7 @@ def to_svg(
vscale: float = 1.0,
scale: float = 1.0,
svg_code_only: Literal[True],
) -> str:
...
) -> str: ...

@overload
def to_svg(
Expand All @@ -2115,8 +2108,7 @@ def to_svg(
vscale: float = 1.0,
scale: float = 1.0,
svg_code_only: Literal[False] = False,
) -> Any:
...
) -> Any: ...

def to_svg(
self,
Expand Down
6 changes: 2 additions & 4 deletions pauliopt/qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ def __len__(self) -> int:
return len(self._statements)

@overload
def __getitem__(self, idx: int) -> "QASM.Statement":
...
def __getitem__(self, idx: int) -> "QASM.Statement": ...

@overload
def __getitem__(self, idx: slice) -> Sequence["QASM.Statement"]:
...
def __getitem__(self, idx: slice) -> Sequence["QASM.Statement"]: ...

def __getitem__(self, idx: Union[int, slice]):
return self._statements[idx]
Expand Down
45 changes: 15 additions & 30 deletions pauliopt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,13 @@ def __truediv__(self, other: int) -> "AngleExpr":
return NotImplemented

@abstractmethod
def __hash__(self) -> int:
...
def __hash__(self) -> int: ...

@abstractmethod
def __str__(self) -> str:
...
def __str__(self) -> str: ...

@abstractmethod
def __repr__(self) -> str:
...
def __repr__(self) -> str: ...

@property
@abstractmethod
Expand All @@ -110,8 +107,7 @@ def repr_latex(self) -> str:

@property
@abstractmethod
def to_qiskit(self) -> Any:
...
def to_qiskit(self) -> Any: ...

@property
def is_zero(self) -> bool:
Expand All @@ -133,8 +129,7 @@ def _repr_latex_(self) -> str:
return "$%s$" % self.repr_latex

@abstractmethod
def __eq__(self, other: Any) -> bool:
...
def __eq__(self, other: Any) -> bool: ...


class Angle(AngleExpr):
Expand Down Expand Up @@ -218,38 +213,32 @@ def __neg__(self) -> "Angle":
return Angle(-self._value)

@overload
def __add__(self, other: "Angle") -> "Angle":
...
def __add__(self, other: "Angle") -> "Angle": ...

@overload
def __add__(self, other: "AngleExpr") -> "AngleExpr":
...
def __add__(self, other: "AngleExpr") -> "AngleExpr": ...

def __add__(self, other: "AngleExpr") -> "AngleExpr":
if isinstance(other, Angle):
return Angle(self._value + other._value)
return super().__add__(other)

@overload
def __sub__(self, other: "Angle") -> "Angle":
...
def __sub__(self, other: "Angle") -> "Angle": ...

@overload
def __sub__(self, other: "AngleExpr") -> "AngleExpr":
...
def __sub__(self, other: "AngleExpr") -> "AngleExpr": ...

def __sub__(self, other: "AngleExpr") -> "AngleExpr":
if isinstance(other, Angle):
return Angle(self._value - other._value)
return super().__sub__(other)

@overload
def __mod__(self, other: "Angle") -> "Angle":
...
def __mod__(self, other: "Angle") -> "Angle": ...

@overload
def __mod__(self, other: "AngleExpr") -> "AngleExpr":
...
def __mod__(self, other: "AngleExpr") -> "AngleExpr": ...

def __mod__(self, other: "AngleExpr") -> "AngleExpr":
if isinstance(other, Angle):
Expand Down Expand Up @@ -339,8 +328,7 @@ def random(
size: Literal[1] = 1,
rng_seed: Optional[int] = None,
nonzero: bool = False,
) -> "Angle":
...
) -> "Angle": ...

@overload
@staticmethod
Expand All @@ -350,8 +338,7 @@ def random(
size: int = 1,
rng_seed: Optional[int] = None,
nonzero: bool = False,
) -> Union["Angle", Tuple["Angle", ...]]:
...
) -> Union["Angle", Tuple["Angle", ...]]: ...

@staticmethod
def random(
Expand Down Expand Up @@ -852,8 +839,7 @@ class TempSchedule(Protocol):
(passed as a keyword argument).
"""

def __call__(self, it: int, num_iters: int) -> float:
...
def __call__(self, it: int, num_iters: int) -> float: ...


@runtime_checkable
Expand All @@ -865,8 +851,7 @@ class TempScheduleProvider(Protocol):

def __call__(
self, t_init: Union[int, float], t_final: Union[int, float]
) -> TempSchedule:
...
) -> TempSchedule: ...


def linear_temp_schedule(
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pytket-qiskit==0.34.0
qiskit==0.39.0
galois==0.3.7
parameterized==0.9.0
notebook==7.0.6
black==23.12.1
notebook==7.0.7
black==24.3.0

0 comments on commit 6798e19

Please sign in to comment.