Generated by Cython 0.29.22

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: LIF_funcs_cython.c

+001: """
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 002: Defines functions for leaky integrate and fire model using Cython
 003: References:
 004:     https://blog.paperspace.com/faster-numpy-array-processing-ndarray-cython/
 005:     https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html
 006:     https://cython.readthedocs.io/en/latest/src/tutorial/numpy.html
 007: """
 008: 
+009: import numpy as np
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 010: cimport numpy as np
 011: cimport cython
+012: from scipy.stats import norm
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_norm);
  __Pyx_GIVEREF(__pyx_n_s_norm);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_norm);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_scipy_stats, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_norm); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_norm, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 013: 
+014: DTYPE = np.float
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 015: ctypedef np.float_t DTYPE_t
 016: 
+017: def min_max_norm(x):
/* Python wrapper */
static PyObject *__pyx_pw_16LIF_funcs_cython_1min_max_norm(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_16LIF_funcs_cython_min_max_norm[] = "\n    Given an array x, returns x normalized to 0 and 1\n    ";
static PyMethodDef __pyx_mdef_16LIF_funcs_cython_1min_max_norm = {"min_max_norm", (PyCFunction)__pyx_pw_16LIF_funcs_cython_1min_max_norm, METH_O, __pyx_doc_16LIF_funcs_cython_min_max_norm};
static PyObject *__pyx_pw_16LIF_funcs_cython_1min_max_norm(PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_max_norm (wrapper)", 0);
  __pyx_r = __pyx_pf_16LIF_funcs_cython_min_max_norm(__pyx_self, ((PyObject *)__pyx_v_x));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_16LIF_funcs_cython_min_max_norm(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("min_max_norm", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("LIF_funcs_cython.min_max_norm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_x); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_16LIF_funcs_cython_1min_max_norm, NULL, __pyx_n_s_LIF_funcs_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_min_max_norm, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LIF_funcs_cython_pyx, __pyx_n_s_min_max_norm, 17, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 17, __pyx_L1_error)
 018:     '''
 019:     Given an array x, returns x normalized to 0 and 1
 020:     '''
+021:     return (x - np.min(x))/(np.max(x) - np.min(x))
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_min); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_x) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_x);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Subtract(__pyx_v_x, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_max); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_v_x) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_x);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_min); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_2, __pyx_v_x) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_x);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Subtract(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 022: 
 023: 
+024: def make_AP(sim, i):
/* Python wrapper */
static PyObject *__pyx_pw_16LIF_funcs_cython_3make_AP(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_16LIF_funcs_cython_2make_AP[] = "\n    Given an instance of Simulation class (sim), \n    and a neuron index (i),\n    extracts neuron-specific parameters from sim\n    to return a templated action potential\n\n    template from Kakaria and de Bivort (2017)\n    ";
static PyMethodDef __pyx_mdef_16LIF_funcs_cython_3make_AP = {"make_AP", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_16LIF_funcs_cython_3make_AP, METH_VARARGS|METH_KEYWORDS, __pyx_doc_16LIF_funcs_cython_2make_AP};
static PyObject *__pyx_pw_16LIF_funcs_cython_3make_AP(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sim = 0;
  PyObject *__pyx_v_i = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("make_AP (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sim,&__pyx_n_s_i,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sim)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_i)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("make_AP", 1, 2, 2, 1); __PYX_ERR(0, 24, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "make_AP") < 0)) __PYX_ERR(0, 24, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sim = values[0];
    __pyx_v_i = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("make_AP", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 24, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("LIF_funcs_cython.make_AP", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_16LIF_funcs_cython_2make_AP(__pyx_self, __pyx_v_sim, __pyx_v_i);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_16LIF_funcs_cython_2make_AP(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sim, PyObject *__pyx_v_i) {
  PyObject *__pyx_v_apRiseTime = NULL;
  PyObject *__pyx_v_apRise = NULL;
  PyObject *__pyx_v_apFallTime = NULL;
  PyObject *__pyx_v_apFall = NULL;
  PyObject *__pyx_v_AP = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("make_AP", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("LIF_funcs_cython.make_AP", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_apRiseTime);
  __Pyx_XDECREF(__pyx_v_apRise);
  __Pyx_XDECREF(__pyx_v_apFallTime);
  __Pyx_XDECREF(__pyx_v_apFall);
  __Pyx_XDECREF(__pyx_v_AP);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__7 = PyTuple_Pack(7, __pyx_n_s_sim, __pyx_n_s_i, __pyx_n_s_apRiseTime, __pyx_n_s_apRise, __pyx_n_s_apFallTime, __pyx_n_s_apFall, __pyx_n_s_AP); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_16LIF_funcs_cython_3make_AP, NULL, __pyx_n_s_LIF_funcs_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_AP, __pyx_t_1) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LIF_funcs_cython_pyx, __pyx_n_s_make_AP, 24, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 24, __pyx_L1_error)
 025:     '''
 026:     Given an instance of Simulation class (sim), 
 027:     and a neuron index (i),
 028:     extracts neuron-specific parameters from sim
 029:     to return a templated action potential
 030: 
 031:     template from Kakaria and de Bivort (2017)
 032:     '''
 033: 
 034:     # draw action potential rise (rising part of Gaussian)
+035:     apRiseTime = sim.params['APdurs'][i]/sim.dt/2
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_APdurs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_dt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_3, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_apRiseTime = __pyx_t_2;
  __pyx_t_2 = 0;
+036:     apRise = norm.pdf(np.arange(-1, 0.01, 1/apRiseTime))
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_norm); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_pdf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_int_1, __pyx_v_apRiseTime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_int_neg_1, __pyx_float_0_01, __pyx_t_4};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_int_neg_1, __pyx_float_0_01, __pyx_t_4};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 36, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_int_neg_1);
    __Pyx_INCREF(__pyx_float_0_01);
    __Pyx_GIVEREF(__pyx_float_0_01);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_float_0_01);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_apRise = __pyx_t_2;
  __pyx_t_2 = 0;
+037:     apRise = min_max_norm(apRise)
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_min_max_norm); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_apRise) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_apRise);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_apRise, __pyx_t_2);
  __pyx_t_2 = 0;
+038:     apRise = apRise * (sim.params['Vmaxs'][i] - sim.params['Vthrs'][i]) + \
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_u_Vmaxs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_Vthrs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Subtract(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Multiply(__pyx_v_apRise, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_apRise, __pyx_t_2);
  __pyx_t_2 = 0;
+039:         sim.params['Vthrs'][i]
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_n_u_Vthrs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 040: 
 041:     # draw action potential fall (fall of sine curve)
+042:     apFallTime = sim.params['APdurs'][i]/sim.dt/2 - 1
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_u_APdurs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_dt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_1, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_apFallTime = __pyx_t_1;
  __pyx_t_1 = 0;
+043:     apFall = np.sin( np.arange(np.pi/2, 3*np.pi/2+.001, np.pi/apFallTime))
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_pi); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_4, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_pi); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Multiply(__pyx_int_3, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_4, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyFloat_AddObjC(__pyx_t_6, __pyx_float__001, .001, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_pi); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_9, __pyx_v_apFallTime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_5, __pyx_t_4, __pyx_t_6};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_5, __pyx_t_4, __pyx_t_6};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 43, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_t_6);
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_apFall = __pyx_t_1;
  __pyx_t_1 = 0;
+044:     apFall = min_max_norm(apFall)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_min_max_norm); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_apFall) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_apFall);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_apFall, __pyx_t_1);
  __pyx_t_1 = 0;
+045:     apFall = apFall * (sim.params['Vmaxs'][i] - sim.params['Vmins'][i]) + \
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_Vmaxs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_u_Vmins); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_apFall, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
  __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+046:         sim.params['Vmins'][i]-.0001
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_n_u_Vmins); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* … */
  __pyx_t_3 = __Pyx_PyFloat_SubtractObjC(__pyx_t_1, __pyx_float__0001, .0001, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_apFall, __pyx_t_3);
  __pyx_t_3 = 0;
 047: 
 048:     # connect rise and fall, and add 2 timepoints of same value
+049:     AP = np.concatenate((apRise, apFall))[1:]
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_apRise);
  __Pyx_GIVEREF(__pyx_v_apRise);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_apRise);
  __Pyx_INCREF(__pyx_v_apFall);
  __Pyx_GIVEREF(__pyx_v_apFall);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_apFall);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_3, 1, 0, NULL, NULL, &__pyx_slice_, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_AP = __pyx_t_2;
  __pyx_t_2 = 0;
/* … */
  __pyx_slice_ = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice_);
  __Pyx_GIVEREF(__pyx_slice_);
+050:     AP = np.append(AP, AP[-1] + 0.0001)
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_append); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_AP, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyFloat_AddObjC(__pyx_t_3, __pyx_float_0_0001, 0.0001, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_AP, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_AP, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_AP);
    __Pyx_GIVEREF(__pyx_v_AP);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_v_AP);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_AP, __pyx_t_2);
  __pyx_t_2 = 0;
+051:     AP = np.append(AP, AP[-1] + 0.0001)
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_append); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_AP, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyFloat_AddObjC(__pyx_t_1, __pyx_float_0_0001, 0.0001, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_AP, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_AP, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_AP);
    __Pyx_GIVEREF(__pyx_v_AP);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_v_AP);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF_SET(__pyx_v_AP, __pyx_t_2);
  __pyx_t_2 = 0;
 052: 
+053:     return AP
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_AP);
  __pyx_r = __pyx_v_AP;
  goto __pyx_L0;
 054: 
 055: 
+056: def make_PSC(sim, i, is_input_PSC=False):
/* Python wrapper */
static PyObject *__pyx_pw_16LIF_funcs_cython_5make_PSC(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_16LIF_funcs_cython_4make_PSC[] = "\n    Given an instance of Simulation class (sim), \n    and a neuron index (i),\n    extracts neuron-specific parameters from sim\n    to return a templated post synaptic current\n\n    template from Kakaria and de Bivort (2017)\n    ";
static PyMethodDef __pyx_mdef_16LIF_funcs_cython_5make_PSC = {"make_PSC", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_16LIF_funcs_cython_5make_PSC, METH_VARARGS|METH_KEYWORDS, __pyx_doc_16LIF_funcs_cython_4make_PSC};
static PyObject *__pyx_pw_16LIF_funcs_cython_5make_PSC(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sim = 0;
  PyObject *__pyx_v_i = 0;
  PyObject *__pyx_v_is_input_PSC = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("make_PSC (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sim,&__pyx_n_s_i,&__pyx_n_s_is_input_PSC,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sim)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_i)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("make_PSC", 0, 2, 3, 1); __PYX_ERR(0, 56, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_is_input_PSC);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "make_PSC") < 0)) __PYX_ERR(0, 56, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sim = values[0];
    __pyx_v_i = values[1];
    __pyx_v_is_input_PSC = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("make_PSC", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 56, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("LIF_funcs_cython.make_PSC", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_16LIF_funcs_cython_4make_PSC(__pyx_self, __pyx_v_sim, __pyx_v_i, __pyx_v_is_input_PSC);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_16LIF_funcs_cython_4make_PSC(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sim, PyObject *__pyx_v_i, PyObject *__pyx_v_is_input_PSC) {
  PyObject *__pyx_v_pscRiseT = NULL;
  PyObject *__pyx_v_pscRise = NULL;
  PyObject *__pyx_v_pscFallT = NULL;
  PyObject *__pyx_v_pscFall = NULL;
  PyObject *__pyx_v_PSC = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("make_PSC", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("LIF_funcs_cython.make_PSC", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pscRiseT);
  __Pyx_XDECREF(__pyx_v_pscRise);
  __Pyx_XDECREF(__pyx_v_pscFallT);
  __Pyx_XDECREF(__pyx_v_pscFall);
  __Pyx_XDECREF(__pyx_v_PSC);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__9 = PyTuple_Pack(8, __pyx_n_s_sim, __pyx_n_s_i, __pyx_n_s_is_input_PSC, __pyx_n_s_pscRiseT, __pyx_n_s_pscRise, __pyx_n_s_pscFallT, __pyx_n_s_pscFall, __pyx_n_s_PSC); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_16LIF_funcs_cython_5make_PSC, NULL, __pyx_n_s_LIF_funcs_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_PSC, __pyx_t_1) < 0) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(3, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LIF_funcs_cython_pyx, __pyx_n_s_make_PSC, 56, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 56, __pyx_L1_error)
 057:     '''
 058:     Given an instance of Simulation class (sim), 
 059:     and a neuron index (i),
 060:     extracts neuron-specific parameters from sim
 061:     to return a templated post synaptic current
 062: 
 063:     template from Kakaria and de Bivort (2017)
 064:     '''
 065:     # draw PSC rise (rising part of a sine curve)
+066:     pscRiseT = sim.params['PSCrisedurs'][i]
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_PSCrisedurs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_pscRiseT = __pyx_t_1;
  __pyx_t_1 = 0;
+067:     pscRise = np.sin(np.linspace(-np.pi/2, np.pi/2, int(pscRiseT/sim.dt)))
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_linspace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_pi); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Negative(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_4, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_pi); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_7, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_dt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_v_pscRiseT, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_6, __pyx_t_4, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_6, __pyx_t_4, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 67, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7);
    __pyx_t_6 = 0;
    __pyx_t_4 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_pscRise = __pyx_t_1;
  __pyx_t_1 = 0;
+068:     pscRise = min_max_norm(pscRise)
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_min_max_norm); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_pscRise) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_pscRise);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_pscRise, __pyx_t_1);
  __pyx_t_1 = 0;
 069: 
 070:     # draw PSC fall (exponential)
+071:     pscFallT = sim.params['PSCfalldurs'][i]
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_PSCfalldurs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_pscFallT = __pyx_t_1;
  __pyx_t_1 = 0;
+072:     if is_input_PSC:
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_is_input_PSC); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 72, __pyx_L1_error)
  if (__pyx_t_11) {
/* … */
  }
+073:         pscFallT = sim.params['inputPSCfalldur']
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_inputPSCfalldur); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_pscFallT, __pyx_t_3);
    __pyx_t_3 = 0;
+074:     pscFall = 2**( -sim.dt/pscFallT * np.arange(7*pscFallT/sim.dt+1))
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_dt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Negative(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_v_pscFallT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Multiply(__pyx_int_7, __pyx_v_pscFallT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_dt); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_PowerOf2(__pyx_int_2, __pyx_t_5, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_pscFall = __pyx_t_1;
  __pyx_t_1 = 0;
+075:     pscFall = min_max_norm(pscFall)
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_min_max_norm); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, __pyx_v_pscFall) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_pscFall);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_pscFall, __pyx_t_1);
  __pyx_t_1 = 0;
 076: 
 077:     # connect rise and fall, and normalize PSC magnitude
 078:     # to counteract changes in duration or time-constants
+079:     PSC = np.concatenate((pscRise, pscFall))
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_pscRise);
  __Pyx_GIVEREF(__pyx_v_pscRise);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_pscRise);
  __Pyx_INCREF(__pyx_v_pscFall);
  __Pyx_GIVEREF(__pyx_v_pscFall);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_pscFall);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_10, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_PSC = __pyx_t_1;
  __pyx_t_1 = 0;
+080:     PSC = PSC * sim.params['PSCmags'][i] / max(PSC)
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_PSCmags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_PSC, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_PSC); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_PSC, __pyx_t_5);
  __pyx_t_5 = 0;
 081: 
+082:     return PSC
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_PSC);
  __pyx_r = __pyx_v_PSC;
  goto __pyx_L0;
 083: 
 084: @cython.boundscheck(False) # turn off bounds-checking for entire function
 085: @cython.wraparound(False)  # turn off negative index wrapping for entire function
+086: cpdef run_LIF_general(np.ndarray[DTYPE_t, ndim=2] connect,
static PyObject *__pyx_pw_16LIF_funcs_cython_7run_LIF_general(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_16LIF_funcs_cython_run_LIF_general(PyArrayObject *__pyx_v_connect, int __pyx_v_Nsteps, float __pyx_v_dt, PyObject *__pyx_v_all_APs, PyObject *__pyx_v_all_PSCs, PyArrayObject *__pyx_v_Vthrs, PyArrayObject *__pyx_v_V0s, PyArrayObject *__pyx_v_Cmems, PyArrayObject *__pyx_v_Rmems, PyArrayObject *__pyx_v_Iin, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_numNeurons;
  PyObject *__pyx_v_psc_lens = 0;
  PyObject *__pyx_v_ap_lens = 0;
  int __pyx_v_max_tBuff;
  PyArrayObject *__pyx_v_V = 0;
  PyArrayObject *__pyx_v_I = 0;
  PyArrayObject *__pyx_v_APMask = 0;
  int __pyx_v_t;
  int __pyx_v_i;
  PyArrayObject *__pyx_v_APi = 0;
  PyArrayObject *__pyx_v_PSCi = 0;
  int __pyx_v_APleni;
  int __pyx_v_tBuffi;
  float __pyx_v_currentTemp;
  float __pyx_v_dV;
  PyObject *__pyx_7genexpr__pyx_v_PSC = NULL;
  PyObject *__pyx_8genexpr1__pyx_v_AP = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_APMask;
  __Pyx_Buffer __pyx_pybuffer_APMask;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Cmems;
  __Pyx_Buffer __pyx_pybuffer_Cmems;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_I;
  __Pyx_Buffer __pyx_pybuffer_I;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Iin;
  __Pyx_Buffer __pyx_pybuffer_Iin;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rmems;
  __Pyx_Buffer __pyx_pybuffer_Rmems;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_V;
  __Pyx_Buffer __pyx_pybuffer_V;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_V0s;
  __Pyx_Buffer __pyx_pybuffer_V0s;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vthrs;
  __Pyx_Buffer __pyx_pybuffer_Vthrs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_connect;
  __Pyx_Buffer __pyx_pybuffer_connect;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run_LIF_general", 0);
  __pyx_pybuffer_V.pybuffer.buf = NULL;
  __pyx_pybuffer_V.refcount = 0;
  __pyx_pybuffernd_V.data = NULL;
  __pyx_pybuffernd_V.rcbuffer = &__pyx_pybuffer_V;
  __pyx_pybuffer_I.pybuffer.buf = NULL;
  __pyx_pybuffer_I.refcount = 0;
  __pyx_pybuffernd_I.data = NULL;
  __pyx_pybuffernd_I.rcbuffer = &__pyx_pybuffer_I;
  __pyx_pybuffer_APMask.pybuffer.buf = NULL;
  __pyx_pybuffer_APMask.refcount = 0;
  __pyx_pybuffernd_APMask.data = NULL;
  __pyx_pybuffernd_APMask.rcbuffer = &__pyx_pybuffer_APMask;
  __pyx_pybuffer_connect.pybuffer.buf = NULL;
  __pyx_pybuffer_connect.refcount = 0;
  __pyx_pybuffernd_connect.data = NULL;
  __pyx_pybuffernd_connect.rcbuffer = &__pyx_pybuffer_connect;
  __pyx_pybuffer_Vthrs.pybuffer.buf = NULL;
  __pyx_pybuffer_Vthrs.refcount = 0;
  __pyx_pybuffernd_Vthrs.data = NULL;
  __pyx_pybuffernd_Vthrs.rcbuffer = &__pyx_pybuffer_Vthrs;
  __pyx_pybuffer_V0s.pybuffer.buf = NULL;
  __pyx_pybuffer_V0s.refcount = 0;
  __pyx_pybuffernd_V0s.data = NULL;
  __pyx_pybuffernd_V0s.rcbuffer = &__pyx_pybuffer_V0s;
  __pyx_pybuffer_Cmems.pybuffer.buf = NULL;
  __pyx_pybuffer_Cmems.refcount = 0;
  __pyx_pybuffernd_Cmems.data = NULL;
  __pyx_pybuffernd_Cmems.rcbuffer = &__pyx_pybuffer_Cmems;
  __pyx_pybuffer_Rmems.pybuffer.buf = NULL;
  __pyx_pybuffer_Rmems.refcount = 0;
  __pyx_pybuffernd_Rmems.data = NULL;
  __pyx_pybuffernd_Rmems.rcbuffer = &__pyx_pybuffer_Rmems;
  __pyx_pybuffer_Iin.pybuffer.buf = NULL;
  __pyx_pybuffer_Iin.refcount = 0;
  __pyx_pybuffernd_Iin.data = NULL;
  __pyx_pybuffernd_Iin.rcbuffer = &__pyx_pybuffer_Iin;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_connect.rcbuffer->pybuffer, (PyObject*)__pyx_v_connect, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_connect.diminfo[0].strides = __pyx_pybuffernd_connect.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_connect.diminfo[0].shape = __pyx_pybuffernd_connect.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_connect.diminfo[1].strides = __pyx_pybuffernd_connect.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_connect.diminfo[1].shape = __pyx_pybuffernd_connect.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vthrs, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Vthrs.diminfo[0].strides = __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vthrs.diminfo[0].shape = __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer, (PyObject*)__pyx_v_V0s, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_V0s.diminfo[0].strides = __pyx_pybuffernd_V0s.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V0s.diminfo[0].shape = __pyx_pybuffernd_V0s.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer, (PyObject*)__pyx_v_Cmems, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Cmems.diminfo[0].strides = __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Cmems.diminfo[0].shape = __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rmems, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Rmems.diminfo[0].strides = __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rmems.diminfo[0].shape = __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer, (PyObject*)__pyx_v_Iin, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Iin.diminfo[0].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Iin.diminfo[0].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Iin.diminfo[1].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Iin.diminfo[1].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[1];
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_APMask.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_I.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_connect.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("LIF_funcs_cython.run_LIF_general", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_APMask.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_I.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_connect.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_psc_lens);
  __Pyx_XDECREF(__pyx_v_ap_lens);
  __Pyx_XDECREF((PyObject *)__pyx_v_V);
  __Pyx_XDECREF((PyObject *)__pyx_v_I);
  __Pyx_XDECREF((PyObject *)__pyx_v_APMask);
  __Pyx_XDECREF((PyObject *)__pyx_v_APi);
  __Pyx_XDECREF((PyObject *)__pyx_v_PSCi);
  __Pyx_XDECREF(__pyx_7genexpr__pyx_v_PSC);
  __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_AP);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_16LIF_funcs_cython_7run_LIF_general(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_16LIF_funcs_cython_6run_LIF_general[] = "\n    Run leaky integrate and fire model using Cython.\n    \n    Returns voltage table (V), current table (I), \n    and action potential counter (APMask), which are\n    tables of size (rows: # neurons, columns: # timepoints)\n\n    Code modeled from Kakaria and de Bivort (2017)\n    ";
static PyObject *__pyx_pw_16LIF_funcs_cython_7run_LIF_general(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_connect = 0;
  int __pyx_v_Nsteps;
  float __pyx_v_dt;
  PyObject *__pyx_v_all_APs = 0;
  PyObject *__pyx_v_all_PSCs = 0;
  PyArrayObject *__pyx_v_Vthrs = 0;
  PyArrayObject *__pyx_v_V0s = 0;
  PyArrayObject *__pyx_v_Cmems = 0;
  PyArrayObject *__pyx_v_Rmems = 0;
  PyArrayObject *__pyx_v_Iin = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run_LIF_general (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_connect,&__pyx_n_s_Nsteps,&__pyx_n_s_dt,&__pyx_n_s_all_APs,&__pyx_n_s_all_PSCs,&__pyx_n_s_Vthrs,&__pyx_n_s_V0s,&__pyx_n_s_Cmems,&__pyx_n_s_Rmems,&__pyx_n_s_Iin,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_connect)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Nsteps)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 1); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 2); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_all_APs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 3); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_all_PSCs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 4); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Vthrs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 5); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_V0s)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 6); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Cmems)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 7); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Rmems)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 8); __PYX_ERR(0, 86, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Iin)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, 9); __PYX_ERR(0, 86, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "run_LIF_general") < 0)) __PYX_ERR(0, 86, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 10) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
    }
    __pyx_v_connect = ((PyArrayObject *)values[0]);
    __pyx_v_Nsteps = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_Nsteps == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L3_error)
    __pyx_v_dt = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_dt == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L3_error)
    __pyx_v_all_APs = ((PyObject*)values[3]);
    __pyx_v_all_PSCs = ((PyObject*)values[4]);
    __pyx_v_Vthrs = ((PyArrayObject *)values[5]);
    __pyx_v_V0s = ((PyArrayObject *)values[6]);
    __pyx_v_Cmems = ((PyArrayObject *)values[7]);
    __pyx_v_Rmems = ((PyArrayObject *)values[8]);
    __pyx_v_Iin = ((PyArrayObject *)values[9]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("run_LIF_general", 1, 10, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 86, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("LIF_funcs_cython.run_LIF_general", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_connect), __pyx_ptype_5numpy_ndarray, 1, "connect", 0))) __PYX_ERR(0, 86, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_all_APs), (&PyList_Type), 1, "all_APs", 1))) __PYX_ERR(0, 88, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_all_PSCs), (&PyList_Type), 1, "all_PSCs", 1))) __PYX_ERR(0, 88, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Vthrs), __pyx_ptype_5numpy_ndarray, 1, "Vthrs", 0))) __PYX_ERR(0, 89, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_V0s), __pyx_ptype_5numpy_ndarray, 1, "V0s", 0))) __PYX_ERR(0, 90, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Cmems), __pyx_ptype_5numpy_ndarray, 1, "Cmems", 0))) __PYX_ERR(0, 91, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Rmems), __pyx_ptype_5numpy_ndarray, 1, "Rmems", 0))) __PYX_ERR(0, 92, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Iin), __pyx_ptype_5numpy_ndarray, 1, "Iin", 0))) __PYX_ERR(0, 93, __pyx_L1_error)
  __pyx_r = __pyx_pf_16LIF_funcs_cython_6run_LIF_general(__pyx_self, __pyx_v_connect, __pyx_v_Nsteps, __pyx_v_dt, __pyx_v_all_APs, __pyx_v_all_PSCs, __pyx_v_Vthrs, __pyx_v_V0s, __pyx_v_Cmems, __pyx_v_Rmems, __pyx_v_Iin);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_16LIF_funcs_cython_6run_LIF_general(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_connect, int __pyx_v_Nsteps, float __pyx_v_dt, PyObject *__pyx_v_all_APs, PyObject *__pyx_v_all_PSCs, PyArrayObject *__pyx_v_Vthrs, PyArrayObject *__pyx_v_V0s, PyArrayObject *__pyx_v_Cmems, PyArrayObject *__pyx_v_Rmems, PyArrayObject *__pyx_v_Iin) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Cmems;
  __Pyx_Buffer __pyx_pybuffer_Cmems;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Iin;
  __Pyx_Buffer __pyx_pybuffer_Iin;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rmems;
  __Pyx_Buffer __pyx_pybuffer_Rmems;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_V0s;
  __Pyx_Buffer __pyx_pybuffer_V0s;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vthrs;
  __Pyx_Buffer __pyx_pybuffer_Vthrs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_connect;
  __Pyx_Buffer __pyx_pybuffer_connect;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run_LIF_general", 0);
  __pyx_pybuffer_connect.pybuffer.buf = NULL;
  __pyx_pybuffer_connect.refcount = 0;
  __pyx_pybuffernd_connect.data = NULL;
  __pyx_pybuffernd_connect.rcbuffer = &__pyx_pybuffer_connect;
  __pyx_pybuffer_Vthrs.pybuffer.buf = NULL;
  __pyx_pybuffer_Vthrs.refcount = 0;
  __pyx_pybuffernd_Vthrs.data = NULL;
  __pyx_pybuffernd_Vthrs.rcbuffer = &__pyx_pybuffer_Vthrs;
  __pyx_pybuffer_V0s.pybuffer.buf = NULL;
  __pyx_pybuffer_V0s.refcount = 0;
  __pyx_pybuffernd_V0s.data = NULL;
  __pyx_pybuffernd_V0s.rcbuffer = &__pyx_pybuffer_V0s;
  __pyx_pybuffer_Cmems.pybuffer.buf = NULL;
  __pyx_pybuffer_Cmems.refcount = 0;
  __pyx_pybuffernd_Cmems.data = NULL;
  __pyx_pybuffernd_Cmems.rcbuffer = &__pyx_pybuffer_Cmems;
  __pyx_pybuffer_Rmems.pybuffer.buf = NULL;
  __pyx_pybuffer_Rmems.refcount = 0;
  __pyx_pybuffernd_Rmems.data = NULL;
  __pyx_pybuffernd_Rmems.rcbuffer = &__pyx_pybuffer_Rmems;
  __pyx_pybuffer_Iin.pybuffer.buf = NULL;
  __pyx_pybuffer_Iin.refcount = 0;
  __pyx_pybuffernd_Iin.data = NULL;
  __pyx_pybuffernd_Iin.rcbuffer = &__pyx_pybuffer_Iin;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_connect.rcbuffer->pybuffer, (PyObject*)__pyx_v_connect, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_connect.diminfo[0].strides = __pyx_pybuffernd_connect.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_connect.diminfo[0].shape = __pyx_pybuffernd_connect.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_connect.diminfo[1].strides = __pyx_pybuffernd_connect.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_connect.diminfo[1].shape = __pyx_pybuffernd_connect.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vthrs, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Vthrs.diminfo[0].strides = __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vthrs.diminfo[0].shape = __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer, (PyObject*)__pyx_v_V0s, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_V0s.diminfo[0].strides = __pyx_pybuffernd_V0s.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V0s.diminfo[0].shape = __pyx_pybuffernd_V0s.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer, (PyObject*)__pyx_v_Cmems, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Cmems.diminfo[0].strides = __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Cmems.diminfo[0].shape = __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rmems, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Rmems.diminfo[0].strides = __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rmems.diminfo[0].shape = __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer, (PyObject*)__pyx_v_Iin, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_pybuffernd_Iin.diminfo[0].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Iin.diminfo[0].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Iin.diminfo[1].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Iin.diminfo[1].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_16LIF_funcs_cython_run_LIF_general(__pyx_v_connect, __pyx_v_Nsteps, __pyx_v_dt, __pyx_v_all_APs, __pyx_v_all_PSCs, __pyx_v_Vthrs, __pyx_v_V0s, __pyx_v_Cmems, __pyx_v_Rmems, __pyx_v_Iin, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_connect.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("LIF_funcs_cython.run_LIF_general", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_connect.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 087:                     int Nsteps, float dt,
 088:                     list all_APs, list all_PSCs,
 089:                     np.ndarray[DTYPE_t, ndim=1] Vthrs,
 090:                     np.ndarray[DTYPE_t, ndim=1] V0s,
 091:                     np.ndarray[DTYPE_t, ndim=1] Cmems,
 092:                     np.ndarray[DTYPE_t, ndim=1] Rmems,
 093:                     np.ndarray[DTYPE_t, ndim=2] Iin):
 094:     '''
 095:     Run leaky integrate and fire model using Cython.
 096:     
 097:     Returns voltage table (V), current table (I), 
 098:     and action potential counter (APMask), which are
 099:     tables of size (rows: # neurons, columns: # timepoints)
 100: 
 101:     Code modeled from Kakaria and de Bivort (2017)
 102:     '''
+103:     cdef int numNeurons = len(connect)
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_connect)); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 103, __pyx_L1_error)
  __pyx_v_numNeurons = __pyx_t_1;
 104:     # find a buffer time to add on to the simulation if a PSC
 105:     # begins right before the simulation end time
+106:     cdef list psc_lens = [len(PSC) for PSC in all_PSCs]
  { /* enter inner scope */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__pyx_v_all_PSCs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 106, __pyx_L5_error)
    }
    __pyx_t_3 = __pyx_v_all_PSCs; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
    for (;;) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 106, __pyx_L5_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_PSC, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_5 = PyObject_Length(__pyx_7genexpr__pyx_v_PSC); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 106, __pyx_L5_error)
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 106, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_PSC); __pyx_7genexpr__pyx_v_PSC = 0;
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_PSC); __pyx_7genexpr__pyx_v_PSC = 0;
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_v_psc_lens = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
+107:     cdef list ap_lens = [len(AP) for AP in all_APs]
  { /* enter inner scope */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__pyx_v_all_APs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 107, __pyx_L11_error)
    }
    __pyx_t_3 = __pyx_v_all_APs; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
    for (;;) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 107, __pyx_L11_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_AP, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_5 = PyObject_Length(__pyx_8genexpr1__pyx_v_AP); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 107, __pyx_L11_error)
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 107, __pyx_L11_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_AP); __pyx_8genexpr1__pyx_v_AP = 0;
    goto __pyx_L14_exit_scope;
    __pyx_L11_error:;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_AP); __pyx_8genexpr1__pyx_v_AP = 0;
    goto __pyx_L1_error;
    __pyx_L14_exit_scope:;
  } /* exit inner scope */
  __pyx_v_ap_lens = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
+108:     cdef int max_tBuff = max(psc_lens)
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_psc_lens); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_max_tBuff = __pyx_t_6;
 109: 
 110:     # initialize voltages to resting potential
+111:     cdef np.ndarray[DTYPE_t, ndim=2] V = np.tile(V0s, (Nsteps + max_tBuff, 1)).T
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_Nsteps + __pyx_v_max_tBuff)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_1);
  __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_V0s), __pyx_t_7};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_V0s), __pyx_t_7};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_V0s));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_V0s));
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, ((PyObject *)__pyx_v_V0s));
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_T); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 111, __pyx_L1_error)
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_V = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 111, __pyx_L1_error)
    } else {__pyx_pybuffernd_V.diminfo[0].strides = __pyx_pybuffernd_V.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V.diminfo[0].shape = __pyx_pybuffernd_V.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V.diminfo[1].strides = __pyx_pybuffernd_V.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V.diminfo[1].shape = __pyx_pybuffernd_V.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_V = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 112:     # initialize currents to 0
+113:     cdef np.ndarray[DTYPE_t, ndim=2] I = np.zeros((numNeurons, Nsteps + max_tBuff))
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_numNeurons); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_Nsteps + __pyx_v_max_tBuff)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7);
  __pyx_t_2 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 113, __pyx_L1_error)
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_I.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_I = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_I.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 113, __pyx_L1_error)
    } else {__pyx_pybuffernd_I.diminfo[0].strides = __pyx_pybuffernd_I.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_I.diminfo[0].shape = __pyx_pybuffernd_I.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_I.diminfo[1].strides = __pyx_pybuffernd_I.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_I.diminfo[1].shape = __pyx_pybuffernd_I.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_10 = 0;
  __pyx_v_I = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 114:     # initialize action potential mask (i.e. indicator to 
 115:     # not update a neuron if it is in a templated action potential)
+116:     cdef np.ndarray[DTYPE_t, ndim=2] APMask = np.zeros((numNeurons, Nsteps + max_tBuff))
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_numNeurons); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_Nsteps + __pyx_v_max_tBuff)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
  __pyx_t_8 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 116, __pyx_L1_error)
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_APMask.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_APMask = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_APMask.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 116, __pyx_L1_error)
    } else {__pyx_pybuffernd_APMask.diminfo[0].strides = __pyx_pybuffernd_APMask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_APMask.diminfo[0].shape = __pyx_pybuffernd_APMask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_APMask.diminfo[1].strides = __pyx_pybuffernd_APMask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_APMask.diminfo[1].shape = __pyx_pybuffernd_APMask.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_11 = 0;
  __pyx_v_APMask = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 117: 
 118:     # iterate through time
 119:     cdef int t, i
 120:     cdef np.ndarray APi, PSCi
 121:     cdef int APleni, tBuffi
 122:     cdef float currentTemp, dV
+123:     for t in np.arange(1, Nsteps):
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_arange); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_Nsteps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_int_1, __pyx_t_3};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_int_1, __pyx_t_3};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0;
    __pyx_t_12 = NULL;
  } else {
    __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 123, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_12)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 123, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 123, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_12(__pyx_t_2);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 123, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_t = __pyx_t_6;
/* … */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 124:         # iterature through neurons
+125:         for i in range(numNeurons):
    __pyx_t_6 = __pyx_v_numNeurons;
    __pyx_t_13 = __pyx_t_6;
    for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
      __pyx_v_i = __pyx_t_14;
 126:             # if this neuron is not masked by an action potential...
+127:             if APMask[i, t] == 0:
      __pyx_t_15 = __pyx_v_i;
      __pyx_t_16 = __pyx_v_t;
      __pyx_t_17 = (((*__Pyx_BufPtrStrided2d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_APMask.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_APMask.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_APMask.diminfo[1].strides)) == 0.0) != 0);
      if (__pyx_t_17) {
/* … */
      }
    }
 128:                 # if it is above spiking threshold...
+129:                 if V[i, t-1] > Vthrs[i]:
        __pyx_t_16 = __pyx_v_i;
        __pyx_t_15 = (__pyx_v_t - 1);
        __pyx_t_18 = __pyx_v_i;
        __pyx_t_17 = (((*__Pyx_BufPtrStrided2d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_V.diminfo[1].strides)) > (*__Pyx_BufPtrStrided1d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_Vthrs.diminfo[0].strides))) != 0);
        if (__pyx_t_17) {
/* … */
          goto __pyx_L20;
        }
+130:                     V[i, t-1] = Vthrs[i]
          __pyx_t_18 = __pyx_v_i;
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_16 = (__pyx_v_t - 1);
          *__Pyx_BufPtrStrided2d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_V.diminfo[1].strides) = (*__Pyx_BufPtrStrided1d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_Vthrs.diminfo[0].strides));
 131:                     # fill in a neuron-specific action potential
+132:                     APi = all_APs[i]; APleni = ap_lens[i]
          if (unlikely(__pyx_v_all_APs == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 132, __pyx_L1_error)
          }
          if (!(likely(((PyList_GET_ITEM(__pyx_v_all_APs, __pyx_v_i)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_all_APs, __pyx_v_i), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 132, __pyx_L1_error)
          __pyx_t_4 = PyList_GET_ITEM(__pyx_v_all_APs, __pyx_v_i);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_XDECREF_SET(__pyx_v_APi, ((PyArrayObject *)__pyx_t_4));
          __pyx_t_4 = 0;
          __pyx_t_19 = __Pyx_PyInt_As_int(PyList_GET_ITEM(__pyx_v_ap_lens, __pyx_v_i)); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 132, __pyx_L1_error)
          __pyx_v_APleni = __pyx_t_19;
+133:                     V[i, t:t+APleni] = APi
          __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_t + __pyx_v_APleni)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_7 = PySlice_New(__pyx_t_8, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7);
          __pyx_t_4 = 0;
          __pyx_t_7 = 0;
          if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_V), __pyx_t_3, ((PyObject *)__pyx_v_APi)) < 0)) __PYX_ERR(0, 133, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+134:                     APMask[i, t:t+APleni] = 1
          __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 134, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_t + __pyx_v_APleni)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = PySlice_New(__pyx_t_7, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 134, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_8);
          __pyx_t_3 = 0;
          __pyx_t_8 = 0;
          if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_APMask), __pyx_t_4, __pyx_int_1) < 0)) __PYX_ERR(0, 134, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 135:                     # fill in a neuron-specific PSC
+136:                     PSCi = all_PSCs[i]; tBuffi = psc_lens[i]
          if (unlikely(__pyx_v_all_PSCs == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 136, __pyx_L1_error)
          }
          if (!(likely(((PyList_GET_ITEM(__pyx_v_all_PSCs, __pyx_v_i)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_all_PSCs, __pyx_v_i), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 136, __pyx_L1_error)
          __pyx_t_4 = PyList_GET_ITEM(__pyx_v_all_PSCs, __pyx_v_i);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_XDECREF_SET(__pyx_v_PSCi, ((PyArrayObject *)__pyx_t_4));
          __pyx_t_4 = 0;
          __pyx_t_19 = __Pyx_PyInt_As_int(PyList_GET_ITEM(__pyx_v_psc_lens, __pyx_v_i)); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 136, __pyx_L1_error)
          __pyx_v_tBuffi = __pyx_t_19;
+137:                     I[i, t:t+tBuffi] = I[i, t:t+tBuffi] + PSCi
          __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_t + __pyx_v_tBuffi)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_7 = PySlice_New(__pyx_t_8, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7);
          __pyx_t_4 = 0;
          __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_I), __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_v_PSCi)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = __Pyx_PyInt_From_int((__pyx_v_t + __pyx_v_tBuffi)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_20 = PySlice_New(__pyx_t_4, __pyx_t_8, Py_None); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_20);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_20);
          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_20);
          __pyx_t_7 = 0;
          __pyx_t_20 = 0;
          if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_I), __pyx_t_8, __pyx_t_3) < 0)) __PYX_ERR(0, 137, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 138:                 else:
 139:                     # draw input current and current from connectivity
+140:                     currentTemp = Iin[i, t-1] + np.dot(connect[:, i], I[:, t-1])
        /*else*/ {
          __pyx_t_18 = __pyx_v_i;
          __pyx_t_16 = (__pyx_v_t - 1);
          __pyx_t_3 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_Iin.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_Iin.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_Iin.diminfo[1].strides))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_n_s_np); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_20);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __pyx_t_20 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_20);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_slice__2);
          __Pyx_GIVEREF(__pyx_slice__2);
          PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__2);
          __Pyx_GIVEREF(__pyx_t_20);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_20);
          __pyx_t_20 = 0;
          __pyx_t_20 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_connect), __pyx_t_4); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_20);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_t - 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_21);
          __Pyx_INCREF(__pyx_slice__2);
          __Pyx_GIVEREF(__pyx_slice__2);
          PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_slice__2);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_t_4);
          __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_I), __pyx_t_21); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          __pyx_t_21 = NULL;
          __pyx_t_19 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_7);
            if (likely(__pyx_t_21)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
              __Pyx_INCREF(__pyx_t_21);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_7, function);
              __pyx_t_19 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[3] = {__pyx_t_21, __pyx_t_20, __pyx_t_4};
            __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
            PyObject *__pyx_temp[3] = {__pyx_t_21, __pyx_t_20, __pyx_t_4};
            __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          {
            __pyx_t_22 = PyTuple_New(2+__pyx_t_19); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_22);
            if (__pyx_t_21) {
              __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21); __pyx_t_21 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_20);
            PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_19, __pyx_t_20);
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_19, __pyx_t_4);
            __pyx_t_20 = 0;
            __pyx_t_4 = 0;
            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_22, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 140, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyNumber_Add(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_23 = __pyx_PyFloat_AsFloat(__pyx_t_7); if (unlikely((__pyx_t_23 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_v_currentTemp = __pyx_t_23;
/* … */
  __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__2);
  __Pyx_GIVEREF(__pyx_slice__2);
 141:                     # compute step in voltage, update voltage table
+142:                     dV = 1./Cmems[i] * ( (V0s[i] - V[i, t-1])/Rmems[i] + currentTemp)
          __pyx_t_16 = __pyx_v_i;
          __pyx_t_24 = (*__Pyx_BufPtrStrided1d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_Cmems.diminfo[0].strides));
          if (unlikely(__pyx_t_24 == 0)) {
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            __PYX_ERR(0, 142, __pyx_L1_error)
          }
          __pyx_t_16 = __pyx_v_i;
          __pyx_t_18 = __pyx_v_i;
          __pyx_t_15 = (__pyx_v_t - 1);
          __pyx_t_25 = ((*__Pyx_BufPtrStrided1d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_V0s.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_V0s.diminfo[0].strides)) - (*__Pyx_BufPtrStrided2d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_V.diminfo[1].strides)));
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_26 = (*__Pyx_BufPtrStrided1d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_Rmems.diminfo[0].strides));
          if (unlikely(__pyx_t_26 == 0)) {
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            __PYX_ERR(0, 142, __pyx_L1_error)
          }
          __pyx_v_dV = ((((__pyx_t_16LIF_funcs_cython_DTYPE_t)1.) / __pyx_t_24) * ((__pyx_t_25 / __pyx_t_26) + __pyx_v_currentTemp));
+143:                     V[i, t] = V[i, t-1] + dV*dt
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_18 = (__pyx_v_t - 1);
          __pyx_t_16 = __pyx_v_i;
          __pyx_t_27 = __pyx_v_t;
          *__Pyx_BufPtrStrided2d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_V.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(__pyx_t_16LIF_funcs_cython_DTYPE_t *, __pyx_pybuffernd_V.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_V.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_V.diminfo[1].strides)) + (__pyx_v_dV * __pyx_v_dt));
        }
        __pyx_L20:;
 144: 
 145:     # return voltage, current, action potentials
+146:     return V, I, APMask
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_V));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_V));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_V));
  __Pyx_INCREF(((PyObject *)__pyx_v_I));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_I));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_I));
  __Pyx_INCREF(((PyObject *)__pyx_v_APMask));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_APMask));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_APMask));
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;
 147: 
 148: 
 149: @cython.boundscheck(False) # turn off bounds-checking for entire function
 150: @cython.wraparound(False)  # turn off negative index wrapping for entire function
+151: cpdef run_LIF_general_sim_wrap(object sim,
static PyObject *__pyx_pw_16LIF_funcs_cython_9run_LIF_general_sim_wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_16LIF_funcs_cython_run_LIF_general_sim_wrap(PyObject *__pyx_v_sim, PyArrayObject *__pyx_v_Iin, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_connect = 0;
  int __pyx_v_numNeurons;
  PyObject *__pyx_v_all_APs = 0;
  PyObject *__pyx_v_all_PSCs = 0;
  int __pyx_v_Nsteps;
  float __pyx_v_dt;
  PyArrayObject *__pyx_v_Vthrs = 0;
  PyArrayObject *__pyx_v_V0s = 0;
  PyArrayObject *__pyx_v_Cmems = 0;
  PyArrayObject *__pyx_v_Rmems = 0;
  int __pyx_8genexpr2__pyx_v_i;
  int __pyx_8genexpr3__pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Cmems;
  __Pyx_Buffer __pyx_pybuffer_Cmems;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Iin;
  __Pyx_Buffer __pyx_pybuffer_Iin;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rmems;
  __Pyx_Buffer __pyx_pybuffer_Rmems;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_V0s;
  __Pyx_Buffer __pyx_pybuffer_V0s;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vthrs;
  __Pyx_Buffer __pyx_pybuffer_Vthrs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_connect;
  __Pyx_Buffer __pyx_pybuffer_connect;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run_LIF_general_sim_wrap", 0);
  __pyx_pybuffer_connect.pybuffer.buf = NULL;
  __pyx_pybuffer_connect.refcount = 0;
  __pyx_pybuffernd_connect.data = NULL;
  __pyx_pybuffernd_connect.rcbuffer = &__pyx_pybuffer_connect;
  __pyx_pybuffer_Vthrs.pybuffer.buf = NULL;
  __pyx_pybuffer_Vthrs.refcount = 0;
  __pyx_pybuffernd_Vthrs.data = NULL;
  __pyx_pybuffernd_Vthrs.rcbuffer = &__pyx_pybuffer_Vthrs;
  __pyx_pybuffer_V0s.pybuffer.buf = NULL;
  __pyx_pybuffer_V0s.refcount = 0;
  __pyx_pybuffernd_V0s.data = NULL;
  __pyx_pybuffernd_V0s.rcbuffer = &__pyx_pybuffer_V0s;
  __pyx_pybuffer_Cmems.pybuffer.buf = NULL;
  __pyx_pybuffer_Cmems.refcount = 0;
  __pyx_pybuffernd_Cmems.data = NULL;
  __pyx_pybuffernd_Cmems.rcbuffer = &__pyx_pybuffer_Cmems;
  __pyx_pybuffer_Rmems.pybuffer.buf = NULL;
  __pyx_pybuffer_Rmems.refcount = 0;
  __pyx_pybuffernd_Rmems.data = NULL;
  __pyx_pybuffernd_Rmems.rcbuffer = &__pyx_pybuffer_Rmems;
  __pyx_pybuffer_Iin.pybuffer.buf = NULL;
  __pyx_pybuffer_Iin.refcount = 0;
  __pyx_pybuffernd_Iin.data = NULL;
  __pyx_pybuffernd_Iin.rcbuffer = &__pyx_pybuffer_Iin;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer, (PyObject*)__pyx_v_Iin, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 151, __pyx_L1_error)
  }
  __pyx_pybuffernd_Iin.diminfo[0].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Iin.diminfo[0].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Iin.diminfo[1].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Iin.diminfo[1].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[1];
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_connect.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("LIF_funcs_cython.run_LIF_general_sim_wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_connect.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_connect);
  __Pyx_XDECREF(__pyx_v_all_APs);
  __Pyx_XDECREF(__pyx_v_all_PSCs);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vthrs);
  __Pyx_XDECREF((PyObject *)__pyx_v_V0s);
  __Pyx_XDECREF((PyObject *)__pyx_v_Cmems);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rmems);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_16LIF_funcs_cython_9run_LIF_general_sim_wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_16LIF_funcs_cython_8run_LIF_general_sim_wrap[] = "\n    Calls run_LIF_general after passing in Sim object and Iin\n    ";
static PyObject *__pyx_pw_16LIF_funcs_cython_9run_LIF_general_sim_wrap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sim = 0;
  PyArrayObject *__pyx_v_Iin = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run_LIF_general_sim_wrap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sim,&__pyx_n_s_Iin,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sim)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Iin)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("run_LIF_general_sim_wrap", 1, 2, 2, 1); __PYX_ERR(0, 151, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "run_LIF_general_sim_wrap") < 0)) __PYX_ERR(0, 151, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sim = values[0];
    __pyx_v_Iin = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("run_LIF_general_sim_wrap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 151, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("LIF_funcs_cython.run_LIF_general_sim_wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Iin), __pyx_ptype_5numpy_ndarray, 1, "Iin", 0))) __PYX_ERR(0, 152, __pyx_L1_error)
  __pyx_r = __pyx_pf_16LIF_funcs_cython_8run_LIF_general_sim_wrap(__pyx_self, __pyx_v_sim, __pyx_v_Iin);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_16LIF_funcs_cython_8run_LIF_general_sim_wrap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sim, PyArrayObject *__pyx_v_Iin) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Iin;
  __Pyx_Buffer __pyx_pybuffer_Iin;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run_LIF_general_sim_wrap", 0);
  __pyx_pybuffer_Iin.pybuffer.buf = NULL;
  __pyx_pybuffer_Iin.refcount = 0;
  __pyx_pybuffernd_Iin.data = NULL;
  __pyx_pybuffernd_Iin.rcbuffer = &__pyx_pybuffer_Iin;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer, (PyObject*)__pyx_v_Iin, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 151, __pyx_L1_error)
  }
  __pyx_pybuffernd_Iin.diminfo[0].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Iin.diminfo[0].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Iin.diminfo[1].strides = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Iin.diminfo[1].shape = __pyx_pybuffernd_Iin.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_16LIF_funcs_cython_run_LIF_general_sim_wrap(__pyx_v_sim, __pyx_v_Iin, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("LIF_funcs_cython.run_LIF_general_sim_wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Iin.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 152:                                np.ndarray[DTYPE_t, ndim=2] Iin):
 153:     '''
 154:     Calls run_LIF_general after passing in Sim object and Iin
 155:     '''
+156:     cdef np.ndarray[DTYPE_t, ndim=2] connect = sim.connect
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_connect); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 156, __pyx_L1_error)
  __pyx_t_2 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_connect.rcbuffer->pybuffer, (PyObject*)__pyx_t_2, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_connect = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_connect.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 156, __pyx_L1_error)
    } else {__pyx_pybuffernd_connect.diminfo[0].strides = __pyx_pybuffernd_connect.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_connect.diminfo[0].shape = __pyx_pybuffernd_connect.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_connect.diminfo[1].strides = __pyx_pybuffernd_connect.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_connect.diminfo[1].shape = __pyx_pybuffernd_connect.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_2 = 0;
  __pyx_v_connect = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+157:     cdef int numNeurons = len(connect)
  __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_connect)); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 157, __pyx_L1_error)
  __pyx_v_numNeurons = __pyx_t_3;
 158: 
+159:     cdef list all_APs = [make_AP(sim, i) for i in range(numNeurons)]
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_v_numNeurons;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_8genexpr2__pyx_v_i = __pyx_t_6;
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_make_AP); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_8genexpr2__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_sim, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 159, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_sim, __pyx_t_9};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 159, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 159, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_v_sim);
        __Pyx_GIVEREF(__pyx_v_sim);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_sim);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 159, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  } /* exit inner scope */
  __pyx_v_all_APs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
+160:     cdef list all_PSCs = [make_PSC(sim, i) for i in range(numNeurons)]
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_v_numNeurons;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_8genexpr3__pyx_v_i = __pyx_t_6;
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_make_PSC); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_8genexpr3__pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_9 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_sim, __pyx_t_12};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_sim, __pyx_t_12};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 160, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_INCREF(__pyx_v_sim);
        __Pyx_GIVEREF(__pyx_v_sim);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_v_sim);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  } /* exit inner scope */
  __pyx_v_all_PSCs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 161: 
+162:     cdef int Nsteps = sim.Nsteps
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_Nsteps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_Nsteps = __pyx_t_4;
+163:     cdef float dt = sim.dt
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_dt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_13 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dt = __pyx_t_13;
+164:     cdef np.ndarray[DTYPE_t, ndim=1] Vthrs = sim.params['Vthrs']
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_Vthrs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 164, __pyx_L1_error)
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vthrs.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_Vthrs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 164, __pyx_L1_error)
    } else {__pyx_pybuffernd_Vthrs.diminfo[0].strides = __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vthrs.diminfo[0].shape = __pyx_pybuffernd_Vthrs.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_14 = 0;
  __pyx_v_Vthrs = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;
+165:     cdef np.ndarray[DTYPE_t, ndim=1] V0s = sim.params['V0s']
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_7, __pyx_n_u_V0s); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 165, __pyx_L1_error)
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V0s.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_V0s = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V0s.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 165, __pyx_L1_error)
    } else {__pyx_pybuffernd_V0s.diminfo[0].strides = __pyx_pybuffernd_V0s.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V0s.diminfo[0].shape = __pyx_pybuffernd_V0s.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_15 = 0;
  __pyx_v_V0s = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+166:     cdef np.ndarray[DTYPE_t, ndim=1] Cmems = sim.params['Cmems']
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_Cmems); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 166, __pyx_L1_error)
  __pyx_t_16 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Cmems.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_Cmems = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 166, __pyx_L1_error)
    } else {__pyx_pybuffernd_Cmems.diminfo[0].strides = __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Cmems.diminfo[0].shape = __pyx_pybuffernd_Cmems.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_16 = 0;
  __pyx_v_Cmems = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;
+167:     cdef np.ndarray[DTYPE_t, ndim=1] Rmems = sim.params['Rmems']
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sim, __pyx_n_s_params); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_7, __pyx_n_u_Rmems); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 167, __pyx_L1_error)
  __pyx_t_17 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rmems.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_16LIF_funcs_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_Rmems = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 167, __pyx_L1_error)
    } else {__pyx_pybuffernd_Rmems.diminfo[0].strides = __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rmems.diminfo[0].shape = __pyx_pybuffernd_Rmems.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_17 = 0;
  __pyx_v_Rmems = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 168: 
+169:     return run_LIF_general(connect, Nsteps, dt, all_APs, all_PSCs,
  __Pyx_XDECREF(__pyx_r);
/* … */
  __pyx_t_1 = __pyx_f_16LIF_funcs_cython_run_LIF_general(((PyArrayObject *)__pyx_v_connect), __pyx_v_Nsteps, __pyx_v_dt, __pyx_v_all_APs, __pyx_v_all_PSCs, ((PyArrayObject *)__pyx_v_Vthrs), ((PyArrayObject *)__pyx_v_V0s), ((PyArrayObject *)__pyx_v_Cmems), ((PyArrayObject *)__pyx_v_Rmems), ((PyArrayObject *)__pyx_v_Iin), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 170:                     Vthrs, V0s, Cmems, Rmems, Iin)
 171: 
 172: 
+173: def spikes_from_APMask(APMask):
/* Python wrapper */
static PyObject *__pyx_pw_16LIF_funcs_cython_11spikes_from_APMask(PyObject *__pyx_self, PyObject *__pyx_v_APMask); /*proto*/
static char __pyx_doc_16LIF_funcs_cython_10spikes_from_APMask[] = "\n    Given a table of action potential indicators (APMask),\n    returns a table of same size that marks onsets of action potential\n    ";
static PyMethodDef __pyx_mdef_16LIF_funcs_cython_11spikes_from_APMask = {"spikes_from_APMask", (PyCFunction)__pyx_pw_16LIF_funcs_cython_11spikes_from_APMask, METH_O, __pyx_doc_16LIF_funcs_cython_10spikes_from_APMask};
static PyObject *__pyx_pw_16LIF_funcs_cython_11spikes_from_APMask(PyObject *__pyx_self, PyObject *__pyx_v_APMask) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("spikes_from_APMask (wrapper)", 0);
  __pyx_r = __pyx_pf_16LIF_funcs_cython_10spikes_from_APMask(__pyx_self, ((PyObject *)__pyx_v_APMask));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_16LIF_funcs_cython_10spikes_from_APMask(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_APMask) {
  PyObject *__pyx_v_Spikes = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_row = NULL;
  PyObject *__pyx_v_where_AP = NULL;
  PyObject *__pyx_v_row_spike_times = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("spikes_from_APMask", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("LIF_funcs_cython.spikes_from_APMask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Spikes);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_row);
  __Pyx_XDECREF(__pyx_v_where_AP);
  __Pyx_XDECREF(__pyx_v_row_spike_times);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__11 = PyTuple_Pack(6, __pyx_n_s_APMask, __pyx_n_s_Spikes, __pyx_n_s_i, __pyx_n_s_row, __pyx_n_s_where_AP, __pyx_n_s_row_spike_times); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_16LIF_funcs_cython_11spikes_from_APMask, NULL, __pyx_n_s_LIF_funcs_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_spikes_from_APMask, __pyx_t_1) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 174:     '''
 175:     Given a table of action potential indicators (APMask),
 176:     returns a table of same size that marks onsets of action potential
 177:     '''
+178:     Spikes = np.zeros(APMask.shape)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_APMask, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_Spikes = __pyx_t_1;
  __pyx_t_1 = 0;
 179:     # for each neuron...
+180:     for i in range(APMask.shape[0]):
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_APMask, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 180, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 180, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 180, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 180, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_1 = 0;
/* … */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 181:         # record indices with action potential mask,
 182:         # and save the first index of each stretch
+183:         row = APMask[i, :]
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i);
    __Pyx_INCREF(__pyx_slice__2);
    __Pyx_GIVEREF(__pyx_slice__2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__2);
    __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_APMask, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_2);
    __pyx_t_2 = 0;
+184:         where_AP = np.where(row == 1)[0]
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_where); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_row, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_where_AP, __pyx_t_4);
    __pyx_t_4 = 0;
+185:         row_spike_times = where_AP[row[where_AP-1] == 0]
    __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_where_AP, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_row, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_where_AP, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_row_spike_times, __pyx_t_2);
    __pyx_t_2 = 0;
+186:         Spikes[i, row_spike_times] = 1
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i);
    __Pyx_INCREF(__pyx_v_row_spike_times);
    __Pyx_GIVEREF(__pyx_v_row_spike_times);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_row_spike_times);
    if (unlikely(PyObject_SetItem(__pyx_v_Spikes, __pyx_t_2, __pyx_int_1) < 0)) __PYX_ERR(0, 186, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+187:     return Spikes
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_Spikes);
  __pyx_r = __pyx_v_Spikes;
  goto __pyx_L0;