# Path: bionet/utils/misc.py
# def func_timer(f):
#     """
#     Time the execution of a function.
# 
#     Parameters
#     ----------
#     f : function
#         Function to time.
#     """
# 
#     def wrapper(*args, **kwargs):
#         start = time.time()
#         res = f(*args, **kwargs)
#         stop = time.time()
#         print 'execution time = %.5f s' % (stop-start)
#         return res
#     return wrapper


import numpy as np
import matplotlib
import bionet.utils.band_limited as bl
import bionet.utils.plotting as pl
import bionet.ted.iaf as iaf
from bionet.utils.misc import func_timer
dur = 2*T
dt = 1e-6
f = 100
bw = 2*np.pi*f

np.random.seed(0)
noise_power = None
comps = 8

if noise_power == None:
    fig_title = 'IAF Input Signal with No Noise'
else:
    fig_title = 'IAF Input Signal with %d dB of Noise' % noise_power

M = 3 # number of input signals
N = 9 # number of neurons

# Starting and ending points of interval that is encoded:
t_start = 0.02
t_end = t_start+T
if t_end > dur:
    raise ValueError('t_start is too large')
k_start = int(np.round(t_start/dt))
k_end = int(np.round(t_end/dt))
t_enc = np.arange(k_start, k_end, dtype=np.float)*dt

u_list = []
for i in xrange(M):
    fig_title_in = fig_title + ' (Signal #' + str(i+1) + ')'
    print fig_title_in

# Path: bionet/utils/misc.py
# def func_timer(f):
#     """
#     Time the execution of a function.
# 
#     Parameters
#     ----------
#     f : function
#         Function to time.
#     """
# 
#     def wrapper(*args, **kwargs):
#         start = time.time()
#         res = f(*args, **kwargs)
#         stop = time.time()
#         print 'execution time = %.5f s' % (stop-start)
#         return res
#     return wrapper


# Path: demos/iaf_delay_demo.py
import numpy as np
import matplotlib
import bionet.utils.band_limited as bl
import bionet.utils.plotting as pl
import bionet.ted.iaf as iaf
from bionet.utils.misc import func_timer

dur = 2*T
dt = 1e-6
f = 100
bw = 2*np.pi*f

np.random.seed(0)
noise_power = None
comps = 8

if noise_power == None:
    fig_title = 'IAF Input Signal with No Noise'
else:
    fig_title = 'IAF Input Signal with %d dB of Noise' % noise_power

M = 3 # number of input signals
N = 9 # number of neurons

# Starting and ending points of interval that is encoded:
t_start = 0.02
t_end = t_start+T
if t_end > dur:
    raise ValueError('t_start is too large')
k_start = int(np.round(t_start/dt))
k_end = int(np.round(t_end/dt))
t_enc = np.arange(k_start, k_end, dtype=np.float)*dt

u_list = []
for i in xrange(M):
    fig_title_in = fig_title + ' (Signal #' + str(i+1) + ')'
    print fig_title_in

    u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power, comps)