<commit_before>import warnings
from operator import attrgetter

from toolz import merge, groupby

from .context import _globals


class Base(object):
    """Base class for dask collections"""

    def visualize(self, filename=None, optimize_graph=False):
        from dask.dot import dot_graph
        if optimize_graph:
            dsk = self._optimize(self.dask, self._keys())
        else:
            dsk = self.dask
        return dot_graph(dsk, filename=filename)

    def _visualize(self, filename=None, optimize_graph=False):
        warn = DeprecationWarning("``_visualize`` is deprecated, use "
                                  "``visualize`` instead.")
        warnings.warn(warn)
        return self.visualize(optimize_graph)

    def compute(self, **kwargs):
        return compute(self, **kwargs)[0]

    @classmethod
    def _get(cls, dsk, keys, get=None, **kwargs):
        get = get or _globals['get'] or cls._default_get
        dsk2 = cls._optimize(dsk, keys)
        return get(dsk2, keys, **kwargs)


def compute(*args, **kwargs):
    """Compute several dask collections at once.

    Examples
    --------
    >>> import dask.array as da
    >>> a = da.arange(10, chunks=2).sum()
    >>> b = da.arange(10, chunks=2).mean()
    >>> compute(a, b)
    (45, 4.5)
    """
    groups = groupby(attrgetter('_optimize'), args)
    get = kwargs.pop('get', None) or _globals['get']

    if not get:
        get = args[0]._default_get<commit_msg>provide default filename to visualize method<commit_after>import warnings
from operator import attrgetter

from toolz import merge, groupby

from .context import _globals


class Base(object):
    """Base class for dask collections"""

    def visualize(self, filename='mydask', optimize_graph=False):
        from dask.dot import dot_graph
        if optimize_graph:
            dsk = self._optimize(self.dask, self._keys())
        else:
            dsk = self.dask
        return dot_graph(dsk, filename=filename)

    def _visualize(self, filename='mydask', optimize_graph=False):
        warn = DeprecationWarning("``_visualize`` is deprecated, use "
                                  "``visualize`` instead.")
        warnings.warn(warn)
        return self.visualize(optimize_graph)

    def compute(self, **kwargs):
        return compute(self, **kwargs)[0]

    @classmethod
    def _get(cls, dsk, keys, get=None, **kwargs):
        get = get or _globals['get'] or cls._default_get
        dsk2 = cls._optimize(dsk, keys)
        return get(dsk2, keys, **kwargs)


def compute(*args, **kwargs):
    """Compute several dask collections at once.

    Examples
    --------
    >>> import dask.array as da
    >>> a = da.arange(10, chunks=2).sum()
    >>> b = da.arange(10, chunks=2).mean()
    >>> compute(a, b)
    (45, 4.5)
    """
    groups = groupby(attrgetter('_optimize'), args)
    get = kwargs.pop('get', None) or _globals['get']

    if not get:
        get = args[0]._default_get
{'fraction_non_alphanumeric': 0.1326565143824027, 'fraction_numerical': 0.009475465313028765, 'mean_word_length': 2.667493796526055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '4364990', 'n_tokens_mistral': 948, 'n_tokens_neox': 911, 'n_words': 240}