<commit_before>from __future__ import division,absolute_import
from numpy import uint8,float32
"""
Note: consider using scipy.misc.bytescale instead of this file.

inputs:
-------
I: 2-D Numpy array of grayscale image data
Clim: length 2 of tuple or numpy 1-D array specifying lowest and highest expected values in grayscale image
<NAME>
"""

def sixteen2eight(I,Clim):
    Q = normframe(I,Clim)
    Q *= 255 # stretch to [0,255] as a float
    return Q.round().astype(uint8) # convert to uint8

def normframe(I,Clim):
"""
inputs:
-------
I: 2-D Numpy array of grayscale image data
Clim: length 2 of tuple or numpy 1-D array specifying lowest and highest expected values in grayscale image
"""
    Vmin = Clim[0]; Vmax = Clim[1]

    return (I.astype(float32).clip(Vmin, Vmax) - Vmin) / (Vmax - Vmin) #stretch to [0,1]<commit_msg>syntax<commit_after>from __future__ import division
from numpy import uint8,float32
"""
Note: consider using scipy.misc.bytescale instead of this file.

inputs:
-------
I: 2-D Numpy array of grayscale image data
Clim: length 2 of tuple or numpy 1-D array specifying lowest and highest expected values in grayscale image
<NAME>
"""

def sixteen2eight(I,Clim):
    Q = normframe(I,Clim)
    Q *= 255 # stretch to [0,255] as a float
    return Q.round().astype(uint8) # convert to uint8

def normframe(I,Clim):
    """
    inputs:
    -------
    I: 2-D Numpy array of grayscale image data
    Clim: length 2 of tuple or numpy 1-D array specifying lowest and highest expected values in grayscale image
    """
    Vmin = Clim[0]; Vmax = Clim[1]

    return (I.astype(float32).clip(Vmin, Vmax) - Vmin) / (Vmax - Vmin) #stretch to [0,1]
{'fraction_non_alphanumeric': 0.11619506321493077, 'fraction_numerical': 0.030102347983142687, 'mean_word_length': 3.5785123966942147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3713095', 'n_tokens_mistral': 599, 'n_tokens_neox': 553, 'n_words': 205}