#!/usr/bin/env python
import sys
import os
import numpy as np
import time
import fnmatch
import cPickle
import zlib
[docs]def checkdir(path):
    if not os.path.exists(path):
        os.makedirs(path) 
[docs]def tex(x):
    return r'$\mathrm{' + x + '}$' 
[docs]def save(data, name):
    compressed = zlib.compress(cPickle.dumps(data))
    with open(name, "wb") as f:
        f.writelines(compressed) 
[docs]def load(name):
    with open(name, "rb") as compressed:
        data = cPickle.loads(zlib.decompress(compressed.read()))
    return data 
[docs]def isnumeric(value):
    try:
        int(value)
        return True
    except:
        return False 
[docs]def load_config(fname):
    with open(fname) as f:
        for l in f:
            exec l.replace('<<', '').replace('>>', '')
    return conf 
[docs]def lprint(msg):
    sys.stdout.write('\r')
    sys.stdout.write(msg)
    sys.stdout.flush()