cirq.ops.GateFamily

Wrapper around gate instances/types describing a set of accepted gates.

GateFamily supports initialization via a) Non-parameterized instances of cirq.Gate (Instance Family). b) Python types inheriting from cirq.Gate (Type Family).

By default, the containment checks depend on the initialization type: a) Instance Family: Containment check is done via cirq.equal_up_to_global_phase. b) Type Family: Containment check is done by type comparison.

For example:

a) Instance Family:

```
>>> gate_family = cirq.GateFamily(cirq.X)
>>> assert cirq.X in gate_family
>>> assert cirq.Rx(rads=np.pi) in gate_family
>>> assert cirq.X ** sympy.Symbol("theta") not in gate_family
```

b) Type Family:

```
>>> gate_family = cirq.GateFamily(cirq.XPowGate)
>>> assert cirq.X in gate_family
>>> assert cirq.Rx(rads=np.pi) in gate_family
>>> assert cirq.X ** sympy.Symbol("theta") in gate_family
```

In order to create gate families with constraints on parameters of a gate type, users should derive from the cirq.GateFamily class and override the _predicate method used to check for gate containment.

gate A python type inheriting from cirq.Gate for type based membership checks, or a non-parameterized instance of a cirq.Gate for equality based membership checks.
name The name of the gate family.
description Human readable description of the gate family.
ignore_global_phase If True, value equality is checked via cirq.equal_up_to_global_phase.

ValueError if gate is not a cirq.Gate instance or subclass.
ValueError if gate is a parameterized instance of cirq.Gate.

description

gate

name

Methods

__contains__

View source

__eq__

View source

__ne__

View source