From e3ceab1d4a6e915849a430fa2d5fd0c393e238bc Mon Sep 17 00:00:00 2001 From: Ed Younis Date: Thu, 19 Jan 2023 16:30:56 -0500 Subject: [PATCH] Pre-commit --- bqskit/exec/results.py | 2 +- bqskit/ir/gates/composedgate.py | 12 ++++++------ bqskit/ir/opt/instantiaters/qfactor.py | 2 +- tests/qis/unitary/test_meta.py | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bqskit/exec/results.py b/bqskit/exec/results.py index e64a33384..d8951fa72 100644 --- a/bqskit/exec/results.py +++ b/bqskit/exec/results.py @@ -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) diff --git a/bqskit/ir/gates/composedgate.py b/bqskit/ir/gates/composedgate.py index f1a1c42f6..0892858ab 100644 --- a/bqskit/ir/gates/composedgate.py +++ b/bqskit/ir/gates/composedgate.py @@ -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( @@ -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( @@ -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'.", ) diff --git a/bqskit/ir/opt/instantiaters/qfactor.py b/bqskit/ir/opt/instantiaters/qfactor.py index 78d0513e1..f769ea6e0 100644 --- a/bqskit/ir/opt/instantiaters/qfactor.py +++ b/bqskit/ir/opt/instantiaters/qfactor.py @@ -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: diff --git a/tests/qis/unitary/test_meta.py b/tests/qis/unitary/test_meta.py index bd47e96e8..26e192f4c 100644 --- a/tests/qis/unitary/test_meta.py +++ b/tests/qis/unitary/test_meta.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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