<commit_before>"""
A series of performance tests.
"""

import numpy as np

from qitensor import *

def random_channels(D=2, cnt=1000):
    ha = qudit('a', D)
    hb = qudit('b', D)
    hc = qudit('c', D*D)

    accum = hb.O.array()

    for idx in xrange(cnt):
        K = (hb*hc*ha.H).random_isometry()
        U = ha.random_unitary()
        rho = U * ha.diag(np.random.rand(D)) * U.H
        sigma = (K * rho * K.H).trace(hc)
        accum += sigma

    return accum / cnt<commit_msg>another benchmark<commit_after>"""
A series of performance tests.
"""

import numpy as np

from qitensor import *

def random_channels(D=2, cnt=3000):
    ha = qudit('a', D)
    hb = qudit('b', D)
    hc = qudit('c', D*D)

    accum = hb.O.array()

    for idx in xrange(cnt):
        K = (hb*hc*ha.H).random_isometry()
        U = ha.random_unitary()
        rho = U * ha.diag(np.random.rand(D)) * U.H
        sigma = (K * rho * K.H).trace(hc)
        accum += sigma

    return accum / cnt

def orbit(D=2, cnt=50000):
    ha = qudit('a', D)
    hb = qudit('b', D)

    x = (ha*hb).random_unitary()
    y = (ha*hb).random_unitary()

    for idx in xrange(cnt):
        y *= x

    return y
{'fraction_non_alphanumeric': 0.16737468139337297, 'fraction_numerical': 0.013593882752761258, 'mean_word_length': 2.2905027932960893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3361446', 'n_tokens_mistral': 486, 'n_tokens_neox': 455, 'n_words': 117}