<commit_before>from .. import Tractography
from .. import (
    tractography_from_vtk_files, tractography_to_vtk_file,
    tractography_from_trackvis_file, tractography_to_trackvis_file,
    tractography_from_files, tractography_to_file
)

from nose.tools import with_setup
import copy
from itertools import izip, chain

from numpy import all, eye, ones, allclose
from numpy.random import randint, randn
from numpy.testing import assert_array_equal

dimensions = None
tracts = None
tracts_data = None
tractography = None
max_tract_length = 50
n_tracts = 50


def equal_tracts(a, b):
    for t1, t2 in izip(a, b):
        if not allclose(t1, t2):
            return False

    return True


def equal_tracts_data(a, b):
    if set(a.keys()) != set(b.keys()):
        return False

    for k in a.keys():
        v1 = a[k]
        v2 = b[k]
        if isinstance(v1, str) and isinstance(v2, str) and v1 == v2:
            continue
        elif not isinstance(v1, str) and not isinstance(v2, str):
            for t1, t2 in izip(a[k], b[k]):
                if not allclose(t1, t2):
                    return False
        else:
            return False
    return True


def equal_tractography(a, b):
    return (
        equal_tracts(a.tracts(), b.tracts()) and
        equal_tracts_data(a.tracts_data(), b.tracts_data())
    )


def setup(*args, **kwargs):
    global dimensions
    global tracts
    global tracts_data
    global tractography

    if 'test_active_data' in kwargs:
        test_active_data = kwargs['test_active_data']
    else:
        test_active_data = False
<commit_msg>BUG: Fixed bug in testing<commit_after>from .. import Tractography
from .. import (
    tractography_from_vtk_files, tractography_to_vtk_file,
    tractography_from_trackvis_file, tractography_to_trackvis_file,
    tractography_from_files, tractography_to_file
)

from nose.tools import with_setup
import copy
from itertools import izip, chain

from numpy import all, eye, ones, allclose
from numpy.random import randint, randn
from numpy.testing import assert_array_equal

dimensions = None
tracts = None
tracts_data = None
tractography = None
max_tract_length = 50
n_tracts = 50


def equal_tracts(a, b):
    for t1, t2 in izip(a, b):
        if not (len(t1) == len(t2) and allclose(t1, t2)):
            return False

    return True


def equal_tracts_data(a, b):
    if set(a.keys()) != set(b.keys()):
        return False

    for k in a.keys():
        v1 = a[k]
        v2 = b[k]
        if isinstance(v1, str) and isinstance(v2, str) and v1 == v2:
            continue
        elif not isinstance(v1, str) and not isinstance(v2, str):
            for t1, t2 in izip(a[k], b[k]):
                if not (len(t1) == len(t2) and allclose(t1, t2)):
                    return False
        else:
            return False
    return True


def equal_tractography(a, b):
    return (
        equal_tracts(a.tracts(), b.tracts()) and
        equal_tracts_data(a.tracts_data(), b.tracts_data())
    )


def setup(*args, **kwargs):
    global dimensions
    global tracts
    global tracts_data
    global tractography

    if 'test_active_data' in kwargs:
        test_active_data = kwargs['test_active_data']
    else:
        test_active_data = False

{'fraction_non_alphanumeric': 0.09088108441158349, 'fraction_numerical': 0.013555144793592114, 'mean_word_length': 2.7278989667049367, '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': '132082', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1067, 'n_words': 304}