<commit_before>import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.axes
import os
from pylearn2.utils import string_utils as string
from tempfile import NamedTemporaryFile
import warnings


def imview(*args, **kwargs):
    """
    A more sensible matplotlib-based image viewer command,
    a wrapper around `imshow`.

    Parameters are identical to `matplotlib.pyplot.imshow`
    but this makes modifications to the current figure
    (or the figure supplied by the `figure` keyword argument)
    first, to make the axes use the full frame.

    It also turns on 'nearest' interpolation by default.
    This can be overridden with the 'interpolation'
    keyword argument.

    All other arguments and keyword arguments are passed
    on to `imshow`.`
    """
    if 'figure' not in kwargs:
        f = plt.gcf()
    else:
        f = kwargs['figure']
    new_ax = matplotlib.axes.Axes(f, [0, 0, 1, 1],
                                  xticks=[], yticks=[],
                                  frame_on=False)
    f.delaxes(f.gca())
    f.add_axes(new_ax)
    if len(args) < 5 and 'interpolation' not in kwargs:
        kwargs['interpolation'] = 'nearest'
    plt.imshow(*args, **kwargs)


def show(image):
    """
    Parameters
    ----------
    image : PIL Image object or ndarray
        If ndarray, integer formats are assumed to use 0-255
        and float formats are assumed to use 0-1
    """
    if hasattr(image, '__array__'):
        #do some shape checking because PIL just raises a tuple indexing error<commit_msg>Made imview default to new figure.<commit_after>import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.axes
import os
from pylearn2.utils import string_utils as string
from tempfile import NamedTemporaryFile
import warnings


def imview(*args, **kwargs):
    """
    A more sensible matplotlib-based image viewer command,
    a wrapper around `matplotlib.pyplot.imshow`.

    Parameters are identical to `matplotlib.pyplot.imshow`
    but this behaves somewhat differently:

      * By default, it creates a new figure (unless a
        `figure` keyword argument is supplied.
      * It modifies the axes of that figure to use the
        full frame, without ticks or tick labels.
      * It turns on `nearest` interpolation by default
        (i.e., it does not antialias pixel data). This
        can be overridden with the `interpolation`
        argument as in `imshow`.

    All other arguments and keyword arguments are passed
    on to `imshow`.`
    """
    if 'figure' not in kwargs:
        f = plt.figure()
    else:
        f = kwargs['figure']
    new_ax = matplotlib.axes.Axes(f, [0, 0, 1, 1],
                                  xticks=[], yticks=[],
                                  frame_on=False)
    f.delaxes(f.gca())
    f.add_axes(new_ax)
    if len(args) < 5 and 'interpolation' not in kwargs:
        kwargs['interpolation'] = 'nearest'
    plt.imshow(*args, **kwargs)


def show(image):
    """
    Parameters
    ----------
    image : PIL Image object or ndarray
        If ndarray, integer formats are assumed to use 0-255
        and float formats are assumed to use 0-1
    """
    if hasattr(image, '__array__'):
        #do some shape checking because PIL just raises a tuple indexing error
{'fraction_non_alphanumeric': 0.08691729323308271, 'fraction_numerical': 0.007218045112781955, 'mean_word_length': 2.4827225130890054, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7114320', 'n_tokens_mistral': 987, 'n_tokens_neox': 948, 'n_words': 372}