예제 #1
0
파일: superop_reps.py 프로젝트: qutip/qutip
def _isqubitdims(dims):
    """Checks whether all entries in a dims list are integer powers of 2.

    Parameters
    ----------
    dims : nested list of ints
        Dimensions to be checked.

    Returns
    -------
    isqubitdims : bool
        True if and only if every member of the flattened dims
        list is an integer power of 2.
    """
    return all([2**floor(log2(dim)) == dim for dim in flatten(dims)])
예제 #2
0
def _isqubitdims(dims):
    """Checks whether all entries in a dims list are integer powers of 2.

    Parameters
    ----------
    dims : nested list of ints
        Dimensions to be checked.

    Returns
    -------
    isqubitdims : bool
        True if and only if every member of the flattened dims
        list is an integer power of 2.
    """
    return all([
        2**floor(log2(dim)) == dim
        for dim in flatten(dims)
    ])
예제 #3
0
def test_unflatten():
    l = [[[10, 20, 30], [40, 50, 60]], [[70, 80, 90], [100, 110, 120]]]
    labels = enumerate_flat(l)
    assert unflatten(flatten(l), labels) == l
예제 #4
0
def test_flatten():
    l = [[[0], 1], 2]
    assert_equal(flatten(l), [0, 1, 2])
예제 #5
0
파일: test_tensor.py 프로젝트: yipk2/qutip
def test_unflatten():
    l = [[[10, 20, 30], [40, 50, 60]], [[70, 80, 90], [100, 110, 120]]]
    labels = enumerate_flat(l)
    assert unflatten(flatten(l), labels) == l
예제 #6
0
파일: test_tensor.py 프로젝트: yipk2/qutip
def test_flatten():
    l = [[[0], 1], 2]
    assert_equal(flatten(l), [0, 1, 2])