This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fread(fid, nelements, dtype): | |
"""Equivalent to Matlab fread function""" | |
if dtype is np.str: | |
dt = np.uint8 # WARNING: assuming 8-bit ASCII for np.str! | |
else: | |
dt = dtype | |
data_array = np.fromfile(fid, dt, nelements) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def frange(start, end=None, inc=None): | |
"A range function, that does accept float increments..." | |
if end == None: | |
end = start + 0.0 | |
start = 0.0 | |
if inc == None: | |
inc = 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def simpleChar(chaine): | |
"""Fct retournant la version minuscule et sans accent de la chaine | |
entrante""" | |
#http://www.siteduzero.com/forum-83-810635-p1-sqlite-recherche-avec-like-insensible-a-la-casse.html#r7767300 | |
# Nouvelle fct de renommage, qui prend aussi les chiffres | |
#http://stackoverflow.com/questions/5574042/string-slugification-in-python | |
chaine = unidecode.unidecode(chaine).lower() | |
return re.sub(r'\W+', ' ', chaine) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sizeof(nbr, unit="o", rounded=1): | |
"""On récupère la taille en octets, et on la formate en Mo | |
ou en Go si plus grand que 1000 Mo. Si on passe l'argument 'b' | |
en paramètre, on calcule en ibytes""" | |
# http://www.fevrierdorian.com/blog/post/2011/06/26/Taille-d-un-fichier-humainement-comprehensible-en-Python | |
if unit == "o": | |
if nbr < 1000.0: |