cirq.Gateset

Gatesets represent a collection of cirq.GateFamily objects.

Used in the notebooks

Used in the tutorials

Gatesets are useful for

  • Describing the set of allowed gates in a human-readable format.
  • Validating a given gate / cirq.OP_TREE against the set of allowed gates.

Gatesets rely on the underlying cirq.GateFamily for both description and validation purposes.

*gates A list of cirq.Gate subclasses / cirq.Gate instances / cirq.GateFamily instances to initialize the Gateset.
name (Optional) Name for the Gateset. Useful for description.
unroll_circuit_op If True, cirq.CircuitOperation is recursively validated by validating the underlying cirq.Circuit.

gates

name

Methods

validate

View source

Validates gates forming circuit_or_optree should be contained in Gateset.

Args
circuit_or_optree The cirq.Circuit or cirq.OP_TREE to validate.

with_params

View source

Returns a copy of this Gateset with identical gates and new values for named arguments.

If a named argument is None then corresponding value of this Gateset is used instead.

Args
name New name for the Gateset.
unroll_circuit_op If True, new Gateset will recursively validate cirq.CircuitOperation by validating the underlying cirq.Circuit.

Returns
self if all new values are None or identical to the values of current Gateset. else a new Gateset with identical gates and new values for named arguments.

__contains__

View source

Check for containment of a given Gate/Operation in this Gateset.

Containment checks are handled as follows:

The complexity of the method in terms of the number of gates, n, is

  • O(1) when any default cirq.GateFamily instance accepts the given item, except for an Instance GateFamily trying to match an item with a different global phase.
  • O(n) for all other cases: matching against custom gate families, matching across global phase for the default Instance GateFamily, no match against any underlying gate family.

Args
item The cirq.Gate or cirq.Operation instance to check containment for.

__eq__

View source

__ne__

View source