From da05b45ba70620886d0d98ebf1bb3508a666b342 Mon Sep 17 00:00:00 2001 From: Anurudh Peduri Date: Tue, 20 Aug 2024 14:17:22 -0700 Subject: [PATCH] move _HasEps --- qualtran/bloqs/basic_gates/rotation.py | 9 +-------- qualtran/resource_counting/t_counts_from_sigma.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/qualtran/bloqs/basic_gates/rotation.py b/qualtran/bloqs/basic_gates/rotation.py index 44901a0b7f..a724ef2d36 100644 --- a/qualtran/bloqs/basic_gates/rotation.py +++ b/qualtran/bloqs/basic_gates/rotation.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from functools import cached_property -from typing import Optional, Protocol, runtime_checkable, Tuple, Union +from typing import Optional, Tuple, Union import attrs import cirq @@ -27,13 +27,6 @@ from qualtran.symbolics import SymbolicFloat -@runtime_checkable -class _HasEps(Protocol): - """Protocol for typing `RotationBloq` base class mixin that has accuracy specified as eps.""" - - eps: float - - @frozen class ZPowGate(CirqGateAsBloqBase): r"""A gate that rotates around the Z axis of the Bloch sphere. diff --git a/qualtran/resource_counting/t_counts_from_sigma.py b/qualtran/resource_counting/t_counts_from_sigma.py index 78bbb8156b..0d969544a5 100644 --- a/qualtran/resource_counting/t_counts_from_sigma.py +++ b/qualtran/resource_counting/t_counts_from_sigma.py @@ -13,7 +13,7 @@ # limitations under the License. import inspect import sys -from typing import cast, Mapping, Optional, Tuple, Type, TYPE_CHECKING +from typing import cast, Mapping, Optional, Protocol, runtime_checkable, Tuple, Type, TYPE_CHECKING import cirq @@ -21,13 +21,18 @@ if TYPE_CHECKING: from qualtran import Bloq - from qualtran.bloqs.basic_gates.rotation import _HasEps + + +@runtime_checkable +class _HasEps(Protocol): + """Protocol for typing `RotationBloq` base class mixin that has accuracy specified as eps.""" + + eps: float def _get_all_rotation_types() -> Tuple[Type['_HasEps'], ...]: """Returns all classes defined in bloqs.basic_gates which have an attribute `eps`.""" from qualtran.bloqs.basic_gates import GlobalPhase - from qualtran.bloqs.basic_gates.rotation import _HasEps bloqs_to_exclude = [GlobalPhase]