<commit_before>"""
Test the mask-extracting utilities.
"""
import types
import distutils.version
import numpy as np

from numpy.testing import assert_array_equal
from nose.tools import assert_true, assert_false, assert_equal, assert_raises

from nibabel import Nifti1Image

from .. import masking
from ..masking import compute_epi_mask, compute_multi_epi_mask, \
    unmask, intersect_masks

from ..testing import write_tmp_imgs

np_version = distutils.version.LooseVersion(np.version.short_version).version


def test_mask():
    mean_image = np.ones((9, 9))
    mean_image[3:-3, 3:-3] = 10
    mean_image[5, 5] = 100
    mean_image = Nifti1Image(mean_image, np.eye(4))
    mask1 = compute_epi_mask(mean_image, opening=False)
    mask2 = compute_epi_mask(mean_image, exclude_zeros=True,
                             opening=False)
    # With an array with no zeros, exclude_zeros should not make
    # any difference
    yield np.testing.assert_array_equal, mask1.get_data(), mask2.get_data()
    # Check that padding with zeros does not change the extracted mask
    mean_image2 = np.zeros((30, 30))<commit_msg>TST: make test work on recent numpy<commit_after>"""
Test the mask-extracting utilities.
"""
import types
import distutils.version
import numpy as np

from numpy.testing import assert_array_equal
from nose.tools import assert_true, assert_false, assert_equal, assert_raises

from nibabel import Nifti1Image

from .. import masking
from ..masking import compute_epi_mask, compute_multi_epi_mask, \
    unmask, intersect_masks

from ..testing import write_tmp_imgs

np_version = distutils.version.LooseVersion(np.version.full_version).version


def test_mask():
    mean_image = np.ones((9, 9))
    mean_image[3:-3, 3:-3] = 10
    mean_image[5, 5] = 100
    mean_image = Nifti1Image(mean_image, np.eye(4))
    mask1 = compute_epi_mask(mean_image, opening=False)
    mask2 = compute_epi_mask(mean_image, exclude_zeros=True,
                             opening=False)
    # With an array with no zeros, exclude_zeros should not make
    # any difference
    yield np.testing.assert_array_equal, mask1.get_data(), mask2.get_data()
    # Check that padding with zeros does not change the extracted mask
    mean_image2 = np.zeros((30, 30))
{'fraction_non_alphanumeric': 0.08678237650200267, 'fraction_numerical': 0.022251891410769914, 'mean_word_length': 4.074492099322799, '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': '4196929', 'n_tokens_mistral': 753, 'n_tokens_neox': 706, 'n_words': 195}