# AUTOGENERATED! DO NOT EDIT! File to edit: 03_unitary.ipynb (unless otherwise specified).

__all__ = ['rand_unitary_ndarray', 'test_unitary_ndarray']

# Cell
from numpy.random import random_sample
from numpy import array
from numpy.testing import assert_allclose
from qutip.random_objects import rand_unitary
from qutip import Qobj

# Cell
def rand_unitary_ndarray(ndarray_shape):
    r"""Make a random unitary ndarray of ndarray_shape"""
    N = ndarray_shape[0]
    try:
        assert N == ndarray_shape[1]
    except AssertionError as  e:
        print("Please pass a shape that is square")
    unitary_qutip = rand_unitary(N)
    unitary_ndarray = unitary_qutip.full()
    return unitary_ndarray

# Cell
def test_unitary_ndarray(ndarray):
    r"""Returns true if array is unitaryitian"""
    tunitary_qutip = Qobj(ndarray)
    unitary_test_result = tunitary_qutip.isunitary
    return unitary_test_result
