<commit_before># -*- coding: utf-8 -*-
# Copyright (C) 2012, <NAME> <<EMAIL>>
# vim: set ts=4 sts=4 sw=4 expandtab smartindent:
#
# License: MIT (see COPYING.MIT file)

import numpy as np
import _imread

def imread(filename):
    '''
    im = imread(filename)

    The file type is guessed from `filename`.

    Parameters
    ----------
    filename : str
        filename

    Returns
    -------
    im : ndarray
    '''
    return _imread.imread(filename)


def imsave(filename, array, formatstr=None):
    '''
    imsave(filename, array, formatstr={auto-detect})

    Writes `array` into file `filename`

    Parameters
    ----------
    filename : str
        path on file system
    array : ndarray-like
    formatstr: str, optional
        format string
    '''
    array = np.asanyarray(array)
    if formatstr is None:<commit_msg>ENH as_grey argument to imread()<commit_after># -*- coding: utf-8 -*-
# Copyright (C) 2012, <NAME> <<EMAIL>>
# vim: set ts=4 sts=4 sw=4 expandtab smartindent:
#
# License: MIT (see COPYING.MIT file)

import numpy as np
import _imread

def imread(filename, as_grey=False):
    '''
    im = imread(filename, as_grey=False)

    The file type is guessed from `filename`.

    Parameters
    ----------
    filename : str
        filename
    as_grey : boolean, optional
        Whether to convert to grey scale image (default: no)

    Returns
    -------
    im : ndarray
        The type of this array will depend on the contents of the file and of
        `as_grey`. Conversion from colour to grayscale will return a floating
        point image.
    '''
    im = _imread.imread(filename)
    if as_grey and len(im.shape) == 3:
        # these are the values that wikipedia says are typical
        transform = np.array([ 0.30,  0.59,  0.11])
        return np.dot(im, transform)
    return im


def imsave(filename, array, formatstr=None):
    '''
    imsave(filename, array, formatstr={auto-detect})

    Writes `array` into file `filename`

    Parameters
    ----------
    filename : str
        path on file system
    array : ndarray-like
    formatstr: str, optional
        format string
    '''
    array = np.asanyarray(array)
    if formatstr is None:
{'fraction_non_alphanumeric': 0.12159709618874773, 'fraction_numerical': 0.011796733212341199, 'mean_word_length': 2.32579185520362, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6911882', 'n_tokens_mistral': 698, 'n_tokens_neox': 664, 'n_words': 224}