def to_matrix(self) -> np.ndarray:
    'Return a Numpy.array for the gate unitary matrix.\n\n        Returns:\n            np.ndarray: if the Gate subclass has a matrix definition.\n\n        Raises:\n            CircuitError: If a Gate subclass does not implement this method an\n                exception will be raised when this base class method is called.\n        '
    if hasattr(self, '__array__'):
        return self.__array__(dtype=complex)
    raise CircuitError('to_matrix not defined for this {}'.format(type(self)))
Return a Numpy.array for the gate unitary matrix.

Returns:
    np.ndarray: if the Gate subclass has a matrix definition.

Raises:
    CircuitError: If a Gate subclass does not implement this method an
        exception will be raised when this base class method is called.
def to_matrix(self) -> np.ndarray:
    'Return a Numpy.array for the gate unitary matrix.\n\n        Returns:\n            np.ndarray: if the Gate subclass has a matrix definition.\n\n        Raises:\n            CircuitError: If a Gate subclass does not implement this method an\n                exception will be raised when this base class method is called.\n        '
    if hasattr(self, '__array__'):
        return self.__array__(dtype=complex)
    raise CircuitError('to_matrix not defined for this {}'.format(type(self)))