Decomposes a value into operations, if possible.

Used in the notebooks

Used in the tutorials

This method decomposes the value exactly once, instead of decomposing it and then continuing to decomposing the decomposed operations recursively until some criteria is met (which is what cirq.decompose does).

val The value to call _decompose_ on, if possible.
default A default result to use if the value doesn't have a _decompose_ method or that method returns NotImplemented or None. If not specified, non-decomposable values cause a TypeError.
*args Positional arguments to forward into the _decompose_ method of val. For example, this is used to tell gates what qubits they are being applied to.
flatten If True, the returned OP-TREE will be flattened to a list of operations.
context Decomposition context specifying common configurable options for controlling the behavior of decompose.
**kwargs Keyword arguments to forward into the _decompose_ method of val.

The result of val._decompose_(*args, **kwargs), if val has a _decompose_ method and it didn't return NotImplemented or None. Otherwise default is returned, if it was specified. Otherwise an error is raised.

TypeError val didn't have a _decompose_ method (or that method returned NotImplemented or None) and default wasn't set.