Skip to content

Commit

Permalink
move _HasEps
Browse files Browse the repository at this point in the history
  • Loading branch information
anurudhp committed Aug 20, 2024
1 parent 7823bdb commit da05b45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 1 addition & 8 deletions qualtran/bloqs/basic_gates/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
11 changes: 8 additions & 3 deletions qualtran/resource_counting/t_counts_from_sigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@
# 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

from qualtran.symbolics import ceil, SymbolicInt

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]

Expand Down

0 comments on commit da05b45

Please sign in to comment.