<commit_before>import unittest
import importlib
import tempfile
import os
from uuid import uuid4
from functools import wraps

from distarray.error import InvalidCommSizeError
from distarray.mpiutils import MPI, create_comm_of_size


def temp_filepath(extension=''):
    """Return a random 8-character filename."""
    tempdir = tempfile.gettempdir()
    filename = str(uuid4())[:8] + extension
    return os.path.join(tempdir, filename)


def import_or_skip(name):
    """Try importing `name`, raise SkipTest on failure.<commit_msg>Improve the docstring for `temp_filepath`.<commit_after>import unittest
import importlib
import tempfile
import os
from uuid import uuid4
from functools import wraps

from distarray.error import InvalidCommSizeError
from distarray.mpiutils import MPI, create_comm_of_size


def temp_filepath(extension=''):
    """Return a randomly generated filename.

    This filename is appended to the directory path returned by
    `tempfile.gettempdir()` and has `extension` appended to it.
    """
    tempdir = tempfile.gettempdir()
    filename = str(uuid4())[:8] + extension
    return os.path.join(tempdir, filename)


def import_or_skip(name):
    """Try importing `name`, raise SkipTest on failure.
{'fraction_non_alphanumeric': 0.08638956805215973, 'fraction_numerical': 0.0057049714751426246, 'mean_word_length': 4.961165048543689, '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': '4698114', 'n_tokens_mistral': 363, 'n_tokens_neox': 348, 'n_words': 118}