Source code for tket_exts.tket.global_phase
"""Global Phase extension operations."""
import functools
from hugr.ext import Extension, OpDef, TypeDef
from hugr.ops import ExtOp
from ._util import TketExtension, load_extension
[docs]
class GlobalPhaseExtension(TketExtension):
"""Operation to add global phase to unitary operations."""
[docs]
@functools.cache
def __call__(self) -> Extension:
"""Returns the quantum extension"""
return load_extension("tket.global_phase")
[docs]
def TYPES(self) -> list[TypeDef]:
"""Return the types defined by this extension"""
return []
[docs]
def OPS(self) -> list[OpDef]:
"""Return the operations defined by this extension"""
return [
self.global_phase.op_def(),
]
@functools.cached_property
def global_phase(self) -> ExtOp:
"""Applies a global phase to the circuit."""
return self().get_op("GlobalPhase").instantiate()