<commit_before>#!/usr/bin/env python2

'''Read and write image files as NumPy arrays
'''


from numpy import amax, amin, around, asarray, zeros as _zeros
from numpy import float32, uint8
from os.path import exists, splitext
from PIL import Image
from random import randint
from sys import float_info as _float_info


DEFAULT_DTYPE = float32


def channels(img):
    '''The number of 2D channels in a 3D array.
    '''
    _channels = lambda x, y, z=1: z
    return _channels(*img.shape)


def _normalize(array):
    '''Normalize an array to the interval [0,1].
    '''
    min = amin(array)
    max = amax(array)
    array -= min
    array /= max - min
    eps = 10.0 * _float_info.epsilon<commit_msg>Improve the formula for normalization.<commit_after>#!/usr/bin/env python2

'''Read and write image files as NumPy arrays
'''


from numpy import around, asarray, mean, std, zeros as _zeros
from numpy import float32, uint8
from os.path import exists, splitext
from PIL import Image
from random import randint
from sys import float_info as _float_info


DEFAULT_DTYPE = float32


def channels(img):
    '''The number of 2D channels in a 3D array.
    '''
    _channels = lambda x, y, z=1: z
    return _channels(*img.shape)


def _normalize(array):
    '''Normalize an array to the interval [0,1].
    '''
    mu = mean(array)
    rho2 = std(array)
    min = mu - 2.0 * rho2
    max = mu + 2.0 * rho2
    array -= min
    array /= max - min
    eps = 10.0 * _float_info.epsilon
{'fraction_non_alphanumeric': 0.0995260663507109, 'fraction_numerical': 0.023696682464454975, 'mean_word_length': 3.1633802816901406, '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': '1029509', 'n_tokens_mistral': 514, 'n_tokens_neox': 480, 'n_words': 183}