Skip to content

Commit

Permalink
Pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
edyounis committed Jan 19, 2023
1 parent c710bd5 commit e3ceab1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bqskit/exec/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def get_counts(self, shots: int) -> npt.NDArray[np.int64]:
return np.asarray(np.multiply(shots, self.probs), np.int64)

def __str__(self) -> str:
pass
return str(self.probs)
12 changes: 6 additions & 6 deletions bqskit/ir/gates/composedgate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class ComposedGate(Gate):
def is_differentiable(self) -> bool:
"""Check if all sub gates are differentiable."""
if hasattr(self, 'gate'):
return isinstance(self.gate, DifferentiableUnitary) # type: ignore
return isinstance(self.gate, DifferentiableUnitary)
if hasattr(self, 'gates'):
return all(
isinstance(gate, DifferentiableUnitary)
for gate in self.gates # type: ignore
for gate in self.gates
)

raise AttributeError(
Expand All @@ -40,12 +40,12 @@ def is_locally_optimizable(self) -> bool:
"""Check if all sub gates are locally optimizable."""
if hasattr(self, 'gate'):
return isinstance(
self.gate, LocallyOptimizableUnitary, # type: ignore
self.gate, LocallyOptimizableUnitary,
)
if hasattr(self, 'gates'):
return all(
isinstance(gate, LocallyOptimizableUnitary)
for gate in self.gates # type: ignore
for gate in self.gates
)

raise AttributeError(
Expand All @@ -55,9 +55,9 @@ def is_locally_optimizable(self) -> bool:

def __hash__(self) -> int:
if hasattr(self, 'gate'):
return hash((self.name, self.gate)) # type: ignore
return hash((self.name, self.gate))
if hasattr(self, 'gates'):
return hash((self.name, tuple(self.gates))) # type: ignore
return hash((self.name, tuple(self.gates)))
raise RuntimeError(
f"Composed gate '{self.name}' has no attribute 'gate' or 'gates'.",
)
Expand Down
2 changes: 1 addition & 1 deletion bqskit/ir/opt/instantiaters/qfactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def instantiate(
x0: npt.NDArray[np.float64],
) -> npt.NDArray[np.float64]:
"""Instantiate `circuit`, see Instantiater for more info."""
return super().instantiate(circuit, target, x0)
return QFactorInstantiatorNative.instantiate(self, circuit, target, x0)

@staticmethod
def is_capable(circuit: Circuit) -> bool:
Expand Down
24 changes: 12 additions & 12 deletions tests/qis/unitary/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
class TestIsLocallyOptimizable:
def test_normal_inheritance(self) -> None:
class test_class(LocallyOptimizableUnitary):
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix:
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa
pass

def optimize(
def optimize( # type: ignore # noqa
self, env_matrix: npt.NDArray[np.complex128],
) -> list[float]:
pass
Expand All @@ -27,10 +27,10 @@ def optimize(

def test_conditional_inheritance_true(self) -> None:
class test_class(LocallyOptimizableUnitary):
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix:
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa
pass

def optimize(
def optimize( # type: ignore # noqa
self, env_matrix: npt.NDArray[np.complex128],
) -> list[float]:
pass
Expand All @@ -43,10 +43,10 @@ def is_locally_optimizable(self) -> bool:

def test_conditional_inheritance_false(self) -> None:
class test_class(LocallyOptimizableUnitary):
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix:
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa
pass

def optimize(
def optimize( # type: ignore # noqa
self, env_matrix: npt.NDArray[np.complex128],
) -> list[float]:
pass
Expand All @@ -61,10 +61,10 @@ def is_locally_optimizable(self) -> bool:
class TestIsDifferentiable:
def test_normal_inheritance(self) -> None:
class test_class(DifferentiableUnitary):
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix:
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa
pass

def get_grad(
def get_grad( # type: ignore # noqa
self, params: RealVector = [],
) -> npt.NDArray[np.complex128]:
pass
Expand All @@ -74,10 +74,10 @@ def get_grad(

def test_conditional_inheritance_true(self) -> None:
class test_class(DifferentiableUnitary):
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix:
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa
pass

def get_grad(
def get_grad( # type: ignore # noqa
self, params: RealVector = [],
) -> npt.NDArray[np.complex128]:
pass
Expand All @@ -90,10 +90,10 @@ def is_differentiable(self) -> bool:

def test_conditional_inheritance_false(self) -> None:
class test_class(DifferentiableUnitary):
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix:
def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa
pass

def get_grad(
def get_grad( # type: ignore # noqa
self, params: RealVector = [],
) -> npt.NDArray[np.complex128]:
pass
Expand Down

0 comments on commit e3ceab1

Please sign in to comment.