def test_gate_inverse(gate):
    """Tests that the inverse of natives gate are correct."""
    mat = cirq.protocols.unitary(gate)
    mat_inverse = cirq.protocols.unitary(gate**-1)
    dim = mat.shape[0]

    numpy.testing.assert_array_almost_equal(mat.dot(mat_inverse), numpy.identity(dim))
Tests that the inverse of natives gate are correct.
cirq-ionq/cirq_ionq/ionq_native_gates_test.py