<commit_before>import scipy
from scipy.optimize import rosen, rosen_der

from climin.nes import Xnes


quadratic = lambda x: (x**2).sum()
quadraticprime = lambda x: 2 * x
quadraticandprime = lambda x: (quadratic(x), quadraticprime(x))


def test_xnes_rosen():
    dim = 2
    wrt = scipy.ones((dim,)) * 0.6
    rosenandprime = lambda x: (rosen(x), rosen_der(x))

    opt = Xnes(wrt, rosen)
    for i, info in enumerate(opt):
        if i > 5000:
            break
    assert (abs(wrt - [1, 1]) < 0.3).all(), 'did not find solution: %s' % wrt<commit_msg>added seed to new test, bcd it would sometimes not work<commit_after>import scipy
from scipy.optimize import rosen, rosen_der

from climin.nes import Xnes


quadratic = lambda x: (x**2).sum()
quadraticprime = lambda x: 2 * x
quadraticandprime = lambda x: (quadratic(x), quadraticprime(x))


def test_xnes_rosen():
    dim = 2
    wrt = scipy.ones((dim,)) * 0.6
    rosenandprime = lambda x: (rosen(x), rosen_der(x))

    scipy.random.seed(1234)

    opt = Xnes(wrt, rosen)
    for i, info in enumerate(opt):
        if i > 3000:
            break
    assert (abs(wrt - [1, 1]) < 0.2).all(), 'did not find solution: %s' % wrt
{'fraction_non_alphanumeric': 0.13678844519966016, 'fraction_numerical': 0.025488530161427356, 'mean_word_length': 3.2222222222222223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4393095', 'n_tokens_mistral': 481, 'n_tokens_neox': 446, 'n_words': 130}