def test_f(HH, Istim, freq, stim_t0, duration=1, tmax=1000):
    """Istim is amplitude of square pulse input to neuron, having
    given duration in ms and frequency in Hz. Starts at stim_t0.
    """
    baseline_Iapp = HH.pars['Iapp']
    stim_period = 1000./freq
    HH.set(tdata=[0, tmax])
    n = int(floor(tmax/stim_period))
    print "Testing with stimulus frequency %.3f Hz" % freq
    print "  (stimulus period is %.4f ms)" % stim_period
    print "Stimulus amplitude is %.3f" % Istim
    stim_ts = array([stim_t0+i*stim_period for i in range(0,n+1)])
    Istim_vardict = make_spike_signal(stim_ts, 1, tmax*1.1, loval=0, hival=Istim, dt=0.1)
    HH.inputs = Istim_vardict
    HH._extInputsChanged = True
    traj = HH.compute('stim_test')
    pts = traj.sample()
    plt.figure(1)
    plt.clf()
    plt.plot(pts['t'], pts['v'], 'b', lw=2)
    plt.plot(pts['t'], 3*pts['I']-75, 'k', lw=2)
    #plt.ylim([-100, 50])
    plt.xlabel('t')
    plt.ylabel('v')
    plt.title('Voltage trace and I(t) pulse stimulus')
    try:
        show_maps(traj, stim_ts, 0.3*tmax)
    except __HOLE__:
        print "Not enough spikes to show a map"
    return traj, pts, stim_ts
dataset/ETHPy150Open robclewley/compneuro/Entrain_teacher_copy.py/test_f