<commit_before>#!/usr/bin/env python

import numpy as np
from scipy.stats import norm

from numpy.testing import assert_almost_equal, assert_array_almost_equal
from nose.tools import (assert_true, assert_equal, assert_false,
                        assert_raises)
from nibabel.tmpdirs import InTemporaryDirectory
from ..utils import (multiple_mahalanobis, z_score, multiple_fast_inv,
                     matrix_rank, full_rank, pos_recipr)


def test_z_score():
    p = np.random.rand(10)
    z = z_score(p)
    assert_array_almost_equal(norm.sf(z), p) 

def test_mahalanobis():
    x = np.random.rand(100) / 100
    A = np.random.rand(100, 100) / 100
    A = np.dot(A.transpose(), A) + np.eye(100)
    mah = np.dot(x, np.dot(np.linalg.inv(A), x))
    assert_almost_equal(mah, multiple_mahalanobis(x, A), decimal=1) 

def test_mahalanobis2():
    x = np.random.randn(100, 3)
    Aa = np.zeros([100, 100, 3])<commit_msg>Removed unsued open4csv<commit_after>#!/usr/bin/env python

import numpy as np

from numpy.testing import assert_almost_equal, assert_array_almost_equal
from nose.tools import assert_true, assert_equal
from nibabel.tmpdirs import InTemporaryDirectory
from ..utils import (multiple_mahalanobis, z_score, multiple_fast_inv,
                     matrix_rank, full_rank, pos_recipr)


def test_z_score():
    p = np.random.rand(10)
    z = z_score(p)
    assert_array_almost_equal(norm.sf(z), p) 

def test_mahalanobis():
    x = np.random.rand(100) / 100
    A = np.random.rand(100, 100) / 100
    A = np.dot(A.transpose(), A) + np.eye(100)
    mah = np.dot(x, np.dot(np.linalg.inv(A), x))
    assert_almost_equal(mah, multiple_mahalanobis(x, A), decimal=1) 

def test_mahalanobis2():
    x = np.random.randn(100, 3)
    Aa = np.zeros([100, 100, 3])
{'fraction_non_alphanumeric': 0.1217440543601359, 'fraction_numerical': 0.037938844847112116, 'mean_word_length': 3.65, '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': '4596942', 'n_tokens_mistral': 736, 'n_tokens_neox': 660, 'n_words': 141}