cirq.one_hot

cirq.one_hot(*, index: Union[None, int, Sequence[int]] = None, shape: Union[int, Sequence[int]], value: Any = 1, dtype: Type[numpy.number]) → numpy.ndarray[source]

Returns a numpy array with all 0s and a single non-zero entry(default 1).

Parameters
  • index – The index that should store the value argument instead of 0. If not specified, defaults to the start of the array.

  • shape – The shape of the array.

  • value – The hot value to place at index in the result.

  • dtype – The dtype of the array.

Returns

The created numpy array.