<commit_before>from __future__ import print_function
import os.path as op
import numpy as np

from numpy.testing import (assert_array_equal, assert_array_almost_equal,
                           assert_allclose, assert_equal)

from nose.tools import assert_true, assert_raises

from mne.datasets import sample
from mne import (read_bem_surfaces, write_bem_surface, read_surface,
                 write_surface, decimate_surface, get_head_surface,
                 get_meg_helmet_surf)
from mne.surface import (_make_morph_map, read_morph_map, _compute_nearest,
                         fast_cross_3d)
from mne.utils import _TempDir, requires_tvtk
from mne.fiff import read_info

data_path = sample.data_path(download=False)
subjects_dir = op.join(data_path, 'subjects')
fname = op.join(subjects_dir, 'sample', 'bem',
                'sample-5120-5120-5120-bem-sol.fif')
tempdir = _TempDir()


def test_helmet():
    """Test loading helmet surfaces
    """
    fname_raw = op.join(op.dirname(__file__), '..', 'fiff', 'tests',
                        'data', 'test_raw.fif')
    fname_kit_raw = op.join(op.dirname(__file__), '..', 'fiff', 'kit',
                            'tests', 'data', 'test_bin.fif')
    fname_bti_raw = op.join(op.dirname(__file__), '..', 'fiff', 'bti',
                            'tests', 'data', 'exported4D_linux.fif')
    fname_ctf_raw = op.join(op.dirname(__file__), '..', 'fiff', 'tests',
                            'data', 'test_ctf_comp_raw.fif')
    for fname in [fname_raw, fname_kit_raw, fname_bti_raw, fname_ctf_raw]:
        helmet = get_meg_helmet_surf(read_info(fname))
        assert_equal(len(helmet['rr']), 304)  # they all have 304 verts
        assert_equal(len(helmet['rr']), len(helmet['nn']))


@sample.requires_sample_data
def test_head():
    """Test loading the head surface
    """
    surf_1 = get_head_surface('sample', subjects_dir=subjects_dir)
    surf_2 = get_head_surface('sample', 'head', subjects_dir=subjects_dir)
    assert_true(len(surf_1['rr']) < len(surf_2['rr']))  # BEM vs dense head


def test_huge_cross():
    """Test cross product with lots of elements
    """
    x = np.random.rand(100000, 3)
    y = np.random.rand(1, 3)
    z = np.cross(x, y)
    zz = fast_cross_3d(x, y)
    assert_array_equal(z, zz)


def test_compute_nearest():
    """Test nearest neighbor searches"""<commit_msg>FIX: Fix simple test<commit_after>from __future__ import print_function
import os.path as op
import numpy as np
from nose.tools import assert_true, assert_raises
from numpy.testing import (assert_array_equal, assert_array_almost_equal,
                           assert_allclose, assert_equal)

from mne.datasets import sample
from mne import (read_bem_surfaces, write_bem_surface, read_surface,
                 write_surface, decimate_surface, get_head_surface,
                 get_meg_helmet_surf)
from mne.surface import (_make_morph_map, read_morph_map, _compute_nearest,
                         fast_cross_3d)
from mne.utils import _TempDir, requires_tvtk
from mne.fiff import read_info
from mne.transforms import _get_mri_head_t_from_trans_file

data_path = sample.data_path(download=False)
subjects_dir = op.join(data_path, 'subjects')
fname = op.join(subjects_dir, 'sample', 'bem',
                'sample-5120-5120-5120-bem-sol.fif')
tempdir = _TempDir()


def test_helmet():
    """Test loading helmet surfaces
    """
    base_dir = op.join(op.dirname(__file__), '..', 'fiff')
    fname_raw = op.join(base_dir, 'tests', 'data', 'test_raw.fif')
    fname_kit_raw = op.join(base_dir, 'kit', 'tests', 'data', 'test_bin.fif')
    fname_bti_raw = op.join(base_dir, 'bti', 'tests', 'data',
                            'exported4D_linux.fif')
    fname_ctf_raw = op.join(base_dir, 'tests', 'data', 'test_ctf_raw.fif')
    fname_trans = op.join(base_dir, 'tests', 'data',
                          'sample-audvis-raw-trans.txt')
    trans = _get_mri_head_t_from_trans_file(fname_trans)
    for fname in [fname_raw, fname_kit_raw, fname_bti_raw, fname_ctf_raw]:
        helmet = get_meg_helmet_surf(read_info(fname), trans)
        assert_equal(len(helmet['rr']), 304)  # they all have 304 verts
        assert_equal(len(helmet['rr']), len(helmet['nn']))


@sample.requires_sample_data
def test_head():
    """Test loading the head surface
    """
    surf_1 = get_head_surface('sample', subjects_dir=subjects_dir)
    surf_2 = get_head_surface('sample', 'head', subjects_dir=subjects_dir)
    assert_true(len(surf_1['rr']) < len(surf_2['rr']))  # BEM vs dense head


def test_huge_cross():
    """Test cross product with lots of elements
    """
    x = np.random.rand(100000, 3)
    y = np.random.rand(1, 3)
    z = np.cross(x, y)
    zz = fast_cross_3d(x, y)
    assert_array_equal(z, zz)


def test_compute_nearest():
    """Test nearest neighbor searches"""
{'fraction_non_alphanumeric': 0.12349772067965188, 'fraction_numerical': 0.014090343970161625, 'mean_word_length': 3.4325068870523414, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4521322', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1686, 'n_words': 345}