Signature#
qualtran.Signature
View source on GitHub
|
An ordered sequence of Registers that follow the rules for a bloq signature.
qualtran.Signature(
registers: Iterable[qualtran.Register]
)
Bloq.signature is a property of all bloqs, and should be an object of this type.
It is analogous to a function signature in traditional computing where we specify the
names and types of the expected inputs and outputs.
Each LEFT (including thru) register must have a unique name. Each RIGHT (including thru) register must have a unique name.
Args
Methods#
build
@classmethodbuild( **registers ) -> 'Signature'
Construct a Signature comprised of simple thru registers given the register bitsizes.
Args
registerskeyword arguments mapping register name to bitsize. All registers will be 0-dimensional and THRU.
build_from_dtypes
@classmethodbuild_from_dtypes( **registers ) -> 'Signature'
Construct a Signature comprised of simple thru registers given the register dtypes.
Args
registerskeyword arguments mapping register name to QDType. All registers will be 0-dimensional and THRU.
lefts
lefts() -> Iterable[qualtran.Register]
Iterable over all registers that appear on the LEFT as input.
rights
rights() -> Iterable[qualtran.Register]
Iterable over all registers that appear on the RIGHT as output.
get_left
get_left(
name: str
) -> qualtran.Register
Get a left register by name.
get_right
get_right(
name: str
) -> qualtran.Register
Get a right register by name.
groups
groups() -> Iterable[Tuple[str, List[Register]]]
Iterate over register groups by name.
Registers with shared names (but differing side attributes) can be implicitly grouped.
adjoint
adjoint() -> 'Signature'
Swap all RIGHT and LEFT registers in this collection.
n_qubits
n_qubits() -> int
The number of qubits in the signature.
If the signature has LEFT and RIGHT registers, the number of qubits in the signature is taken to be the greater of the number of left or right qubits. A bloq with this signature uses at least this many qubits.
Classical registers are ignored.
n_cbits
n_cbits() -> int
The number of classical bits in the signature.
If the signature has LEFT and RIGHT registers, the number of classical bits in the signature is taken to be the greater of the number of left or right cbits. A bloq with this signature uses at least this many classical bits.
n_bits
n_bits() -> int
The number of quantum + classical bits in the signature.
If the signature has LEFT and RIGHT registers, the number of bits in the signature is taken to be the greater of the number of left or right bits. A bloq with this signature uses at least this many quantum + classical bits.
See Also
__getitem__
__getitem__(
key
)
__contains__
__contains__(
item: qualtran.Register
) -> bool
__iter__
__iter__() -> Iterator[qualtran.Register]
__len__
__len__() -> int
__eq__
__eq__(
other
) -> bool
Return self==value.
View source on GitHub