<commit_before># -*- coding: utf-8 -*-

from __future__ import division

import numpy as np
from numpy.testing import assert_almost_equal, assert_array_almost_equal

from .. import initial


def test_ic():
    """initial conditions"""

    ic = initial.IC((
        (0, 0, 0, 0),
        (0, 1, 1, 0),
        (0, 1, 1, 0),
        (0, 0, 0, 0),
    ), 1)

    assert_almost_equal(ic.sum(), 4, err_msg='Incorrect total profile.')

    assert_array_almost_equal(ic.cm(), (0, 0),
                              err_msg='Incorrect center of mass.')

    assert_almost_equal(ic.ecc(2), 0, err_msg='Incorrect epsilon_2.')
    assert_almost_equal(ic.ecc(3), 0, err_msg='Incorrect epsilon_3.')
    assert_almost_equal(ic.ecc(4), 1, err_msg='Incorrect epsilon_4.')

    ic = initial.IC((
        (0, 0, 0, 0, 0),
        (0, 2, 0, 1, 0),
        (0, 0, 0, 0, 0),
        (0, 3, 0, 4, 0),
        (0, 0, 0, 0, 0),
    ), .1)

    assert_almost_equal(ic.sum(), .1, err_msg='Incorrect total profile.')

    assert_array_almost_equal(ic.cm(), (0, -.04),
                              err_msg='Incorrect center of mass.')

    S = np.array((1, 2, 3, 4), dtype=float)
    X = np.array((.1, -.1, -.1, .1))
    Y = np.array((.1, .1, -.1, -.1))
    Y += .04
    Rsq = X*X + Y*Y

    for n in 2, 3, 4:
        ecc = abs(np.average(
            np.exp(1j*n*np.arctan2(Y, X)),
            weights=S*Rsq**(.5*n)
        ))
        assert_almost_equal(ic.ecc(n), ecc,
                            err_msg='Incorrect epsilon_{}.'.format(n))

    # TODO: test non-square grids and grid spacing
<commit_msg>Test epsilon_1.<commit_after># -*- coding: utf-8 -*-

from __future__ import division

import numpy as np
from numpy.testing import assert_almost_equal, assert_array_almost_equal

from .. import initial


def test_ic():
    """initial conditions"""

    ic = initial.IC((
        (0, 0, 0, 0),
        (0, 1, 1, 0),
        (0, 1, 1, 0),
        (0, 0, 0, 0),
    ), 1)

    assert_almost_equal(ic.sum(), 4, err_msg='Incorrect total profile.')

    assert_array_almost_equal(ic.cm(), (0, 0),
                              err_msg='Incorrect center of mass.')

    assert_almost_equal(ic.ecc(1), 0, err_msg='Incorrect epsilon_2.')
    assert_almost_equal(ic.ecc(2), 0, err_msg='Incorrect epsilon_2.')
    assert_almost_equal(ic.ecc(3), 0, err_msg='Incorrect epsilon_3.')
    assert_almost_equal(ic.ecc(4), 1, err_msg='Incorrect epsilon_4.')

    ic = initial.IC((
        (0, 0, 0, 0, 0),
        (0, 2, 0, 1, 0),
        (0, 0, 0, 0, 0),
        (0, 3, 0, 4, 0),
        (0, 0, 0, 0, 0),
    ), .1)

    assert_almost_equal(ic.sum(), .1, err_msg='Incorrect total profile.')

    assert_array_almost_equal(ic.cm(), (0, -.04),
                              err_msg='Incorrect center of mass.')

    S = np.array((1, 2, 3, 4), dtype=float)
    X = np.array((.1, -.1, -.1, .1))
    Y = np.array((.1, .1, -.1, -.1))
    Y += .04
    Rsq = X*X + Y*Y

    for n in range(1, 5):
        ecc = abs(np.average(
            np.exp(1j*n*np.arctan2(Y, X)),
            weights=S*Rsq**(.5*n)
        ))
        assert_almost_equal(ic.ecc(n), ecc,
                            err_msg='Incorrect epsilon_{}.'.format(n))

    # TODO: test non-square grids and grid spacing

{'fraction_non_alphanumeric': 0.17645241038318912, 'fraction_numerical': 0.050370828182941904, 'mean_word_length': 2.1005747126436782, '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': '5797414', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1225, 'n_words': 302}