<commit_before>import math

import numpy as np

import analysis


def test_magnitude():
    x = np.array([[1, 2, 3.]])
    # requirement for magnitude:
    assert x.shape == (1, 3)

    # compute result we expect
    y1 = math.sqrt(1 ** 2 + 2 ** 2 + 3 ** 2)

    # compute actual result from analysis.magnitude
    y2 = analysis.magnitude(x)
    assert y1 == float(y2)<commit_msg>Adding more test cases: n == 5 and negative vector entries<commit_after>import math

import numpy as np

import analysis


def test_magnitude_n():

    # n = 3

    x = np.array([[1, 2, 3.]])
    # requirement for magnitude:
    assert x.shape == (1, 3)

    # compute result we expect
    y1 = math.sqrt(1 ** 2 + 2 ** 2 + 3 ** 2)

    # compute actual result from analysis.magnitude
    y2 = analysis.magnitude(x)
    assert y1 == float(y2)

    # n = 5
    x = np.array([[1, 2, 3., 0.1, 0]])
    # requirement for magnitude:
    assert x.shape == (1, 5)

    # compute result we expect
    y1 = math.sqrt(1 ** 2 + 2 ** 2 + 3 ** 2 + 0.1 ** 2 + 0 ** 2)

    # compute actual result from analysis.magnitude
    y2 = analysis.magnitude(x)
    assert y1 == float(y2)

    # n = 3, with negative entries

    x = np.array([[-1, -2, 3.]])
    # requirement for magnitude:
    assert x.shape == (1, 3)

    # compute result we expect
    y1 = math.sqrt((-1) ** 2 + (-2) ** 2 + 3. ** 2)

    # compute actual result from analysis.magnitude
    y2 = analysis.magnitude(x)
    assert y1 == float(y2)
{'fraction_non_alphanumeric': 0.14217687074829932, 'fraction_numerical': 0.04897959183673469, 'mean_word_length': 2.4530516431924885, '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': '3489199', 'n_tokens_mistral': 567, 'n_tokens_neox': 500, 'n_words': 171}