Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (40 sloc) 1.36 KB
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""All the utility functions used everywhere in this project are here.
import sys
import matplotlib as mp
import matplotlib.pyplot as plt
def _configure_matplotlib():'ggplot')
font_size = 13
fig = mp.pyplot.gcf()
fig.set_size_inches(18, 12)
def progress(count, total, suffix=''):
bar_len = 60
filled_len = int(round(bar_len * count / float(total)))
percents = round(100.0 * count / float(total), 1)
bar = '=' * filled_len + '-' * (bar_len - filled_len)
sys.stdout.write('[%s] %s%s ...%s\r' % (bar, percents, '%', suffix))
sys.stdout.flush() # As suggested by Rom Ruben
def plot_multiline(Ys, X, labels, xlabel, ylabel, title, fig_name=None):
for i, Y in enumerate(Ys):
plt.plot(X, Y, label=labels[i], marker="o", linewidth=2.0,
dash_joinstyle="bevel", solid_capstyle="round", markeredgecolor="none", linestyle="-")
plt.legend(loc="upper left")
plt.ylim(0.0, 1.001)
if fig_name:
plt.savefig("results/%s" % fig_name)
def reverse_argsort(X):
indices = range(len(X))
indices.sort(key=X.__getitem__, reverse=True)
return indices
def dc_compat(X):
return [[x] for x in X]
You can’t perform that action at this time.