Generated by Cython 3.2.8

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: inner_loops_hardwall.c

+0001: ## ...........................................................................
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_4) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0002: ##
 0003: ## PIMMS (Polymer Interactions in Multicomponent Mixtures)
 0004: ## Author: Alex Holehouse
 0005: ## Developed by the Holehouse and Pappu labs
 0006: ## Copyright 2015 - 2026
 0007: ##
 0008: ## ...........................................................................
 0009: 
+0010: import numpy as np
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_numpy, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  __pyx_t_4 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_np, __pyx_t_4) < (0)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0011: cimport numpy as cnp
+0012: cnp.import_array()
  __pyx_t_9 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 12, __pyx_L1_error)
 0013: cimport cython
 0014: 
+0015: from pimms.latticeExceptions import InnerLoopException
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_InnerLoopException};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_pimms_latticeExceptions, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_InnerLoopException};
    __pyx_t_10 = 0; {
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_10]); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 15, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_10], __pyx_t_5) < (0)) __PYX_ERR(0, 15, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0016: 
+0017: cdef inline int int_max(int a, int b): return a if a >= b else b
static CYTHON_INLINE int __pyx_f_5pimms_20inner_loops_hardwall_int_max(int __pyx_v_a, int __pyx_v_b) {
  int __pyx_r;
  __pyx_t_2 = (__pyx_v_a >= __pyx_v_b);
  if (__pyx_t_2) {
    __pyx_t_1 = __pyx_v_a;
  } else {
    __pyx_t_1 = __pyx_v_b;
  }
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
+0018: cdef inline int int_min(int a, int b): return a if a <= b else b
static CYTHON_INLINE int __pyx_f_5pimms_20inner_loops_hardwall_int_min(int __pyx_v_a, int __pyx_v_b) {
  int __pyx_r;
  __pyx_t_2 = (__pyx_v_a <= __pyx_v_b);
  if (__pyx_t_2) {
    __pyx_t_1 = __pyx_v_a;
  } else {
    __pyx_t_1 = __pyx_v_b;
  }
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
 0019: 
 0020: 
 0021: from pimms.cython_config cimport NUMPY_INT_TYPE
+0022: from pimms.CONFIG import NP_INT_TYPE as NUMPY_INT_TYPE_PYTHON
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_NP_INT_TYPE};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_pimms_CONFIG, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_NP_INT_TYPE};
    __pyx_t_10 = 0; {
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_10]); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      switch (__pyx_t_10) {
        case 0:
        if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON, __pyx_t_5) < (0)) __PYX_ERR(0, 22, __pyx_L1_error)
        break;
        default:;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0023: 
 0024: #from numpy cimport int16_t as NUMPY_INT16_TYPE
 0025: #ctypedef NUMPY_INT16_TYPE  NUMPY_INT_TYPE
 0026: 
 0027: ## inner_loops contains functions for geting positions and bead information in
 0028: ## the local 2D or 3D environment
 0029: ##
 0030: ##
 0031: ##
 0032: 
 0033: 
 0034: 
 0035: ##
 0036: #################################################################################################
 0037: ##
 0038: 
 0039: 
+0040: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_1extract_SR_and_LR_pairs_from_position_3D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_extract_SR_and_LR_pairs_from_position_3D_hardwall, "\n    Function that takes a single position ($position) and the type_grid and determines\n    the set of pairwise interactions between that central position and the positions\n    around it. \n\n    The pairs are inherently numbered (i.e. [A-B] would be A then B). To determine which\n    of the two positions is first in the pair we use the numerical value of the x/y/z \n    positions\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_1extract_SR_and_LR_pairs_from_position_3D_hardwall = {"extract_SR_and_LR_pairs_from_position_3D_hardwall", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_1extract_SR_and_LR_pairs_from_position_3D_hardwall, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_extract_SR_and_LR_pairs_from_position_3D_hardwall};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_1extract_SR_and_LR_pairs_from_position_3D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_XDIM;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_YDIM;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_ZDIM;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_SR_and_LR_pairs_from_position_3D_hardwall (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,&__pyx_mstate_global->__pyx_n_u_ZDIM,0};
  PyObject* values[6] = {0,0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 40, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  6:
        values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 40, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 40, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 40, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 40, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 40, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 40, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_and_LR_pairs_from_position_3D_hardwall", 0) < (0)) __PYX_ERR(0, 40, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 6; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_3D_hardwall", 1, 6, 6, i); __PYX_ERR(0, 40, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 6)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 40, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 40, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 40, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 40, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 40, __pyx_L3_error)
      values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 40, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 42, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_npy_int32(values[1]); if (unlikely((__pyx_v_LR_position == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 44, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_npy_int32(values[3]); if (unlikely((__pyx_v_XDIM == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_npy_int32(values[4]); if (unlikely((__pyx_v_YDIM == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L3_error)
    __pyx_v_ZDIM = __Pyx_PyLong_As_npy_int32(values[5]); if (unlikely((__pyx_v_ZDIM == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_3D_hardwall", 1, 6, 6, __pyx_nargs); __PYX_ERR(0, 40, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_and_LR_pairs_from_position_3D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_extract_SR_and_LR_pairs_from_position_3D_hardwall(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM, __pyx_v_ZDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_extract_SR_and_LR_pairs_from_position_3D_hardwall(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_XDIM, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_YDIM, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_ZDIM) {
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_SLR_index;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_SR_index;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_LR_index;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_x_off;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_y_off;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_z_off;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_x_p;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_y_p;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_z_p;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_x;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_y;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_z;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  { 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_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_and_LR_pairs_from_position_3D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_1extract_SR_and_LR_pairs_from_position_3D_hardwall, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos, __pyx_t_4) < (0)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0041: @cython.wraparound(False)
 0042: def extract_SR_and_LR_pairs_from_position_3D_hardwall(NUMPY_INT_TYPE[:] position,
 0043:                                                       NUMPY_INT_TYPE LR_position,
 0044:                                                       NUMPY_INT_TYPE[:,:,:] type_grid,
 0045:                                                       NUMPY_INT_TYPE XDIM,
 0046:                                                       NUMPY_INT_TYPE YDIM,
 0047:                                                       NUMPY_INT_TYPE ZDIM):
 0048:     """
 0049:     Function that takes a single position ($position) and the type_grid and determines
 0050:     the set of pairwise interactions between that central position and the positions
 0051:     around it.
 0052: 
 0053:     The pairs are inherently numbered (i.e. [A-B] would be A then B). To determine which
 0054:     of the two positions is first in the pair we use the numerical value of the x/y/z
 0055:     positions
 0056: 
 0057:     """
 0058: 
 0059:     ## Note all cdef have to happen at the start for C scoping reasons
 0060: 
 0061:     # declare some variables
 0062:     #cdef int SLR_index, SR_index, LR_index, x_off, y_off, z_off;
 0063:     #cdef int x_tmp, y_tmp, z_tmp;
 0064: 
 0065:     cdef NUMPY_INT_TYPE SLR_index, SR_index, LR_index, x_off, y_off, z_off
 0066:     cdef NUMPY_INT_TYPE x_p, y_p, z_p
 0067: 
 0068:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs
 0069:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 0070:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 0071: 
 0072:     # first set the central x, y and z positions
+0073:     cdef NUMPY_INT_TYPE x = position[0]
  __pyx_t_1 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+0074:     cdef NUMPY_INT_TYPE y = position[1]
  __pyx_t_1 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+0075:     cdef NUMPY_INT_TYPE z = position[2]
  __pyx_t_1 = 2;
  __pyx_v_z = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
 0076: 
 0077:     # short range only
+0078:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
 0079: 
+0080:         return (extract_SR_pairs_from_position_3D_hardwall(position, XDIM, YDIM, ZDIM), np.array([], dtype=NUMPY_INT_TYPE_PYTHON), np.array([], dtype=NUMPY_INT_TYPE_PYTHON))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_position, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyLong_From_npy_int32(__pyx_v_XDIM); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_YDIM); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyLong_From_npy_int32(__pyx_v_ZDIM); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_9 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_9, (5-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_8 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_8);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_9 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_8, __pyx_t_7};
      __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_5, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 80, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
      __pyx_t_9 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_8, __pyx_t_10, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 80, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 80, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4) != (0)) __PYX_ERR(0, 80, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6) != (0)) __PYX_ERR(0, 80, __pyx_L1_error);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;
 0081: 
 0082: 
 0083:         # old code that seems to just re-implement the extract_SR_pairs_from_position_3D_hardwall function
 0084:         """
 0085:         SR_index = 0
 0086:         for x_off in xrange(-1,2):
 0087:             for y_off in xrange(-1,2):
 0088:                 for z_off in xrange(-1,2):
 0089: 
 0090:                     # if x_off > 0 then the non-central position must come first in the pair
 0091:                     if x_off > 0:
 0092:                         SR_pairs[SR_index, 1, 0] = x
 0093:                         SR_pairs[SR_index, 1, 1] = y
 0094:                         SR_pairs[SR_index, 1, 2] = z
 0095: 
 0096:                         SR_pairs[SR_index, 0, 0] = pbc_hardwall(x + x_off, XDIM)
 0097:                         SR_pairs[SR_index, 0, 1] = pbc_hardwall(y + y_off, YDIM)
 0098:                         SR_pairs[SR_index, 0, 2] = pbc_hardwall(z + z_off, ZDIM)
 0099: 
 0100: 
 0101:                     # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
 0102:                     elif x_off == 0 and y_off > 0:
 0103:                         SR_pairs[SR_index, 1, 0] = x
 0104:                         SR_pairs[SR_index, 1, 1] = y
 0105:                         SR_pairs[SR_index, 1, 2] = z
 0106: 
 0107:                         SR_pairs[SR_index, 0, 0] = pbc_hardwall(x + x_off, XDIM)
 0108:                         SR_pairs[SR_index, 0, 1] = pbc_hardwall(y + y_off, YDIM)
 0109:                         SR_pairs[SR_index, 0, 2] = pbc_hardwall(z + z_off, ZDIM)
 0110: 
 0111:                     # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
 0112:                     elif x_off == 0 and y_off == 0 and z_off > 0:
 0113:                         SR_pairs[SR_index, 1, 0] = x
 0114:                         SR_pairs[SR_index, 1, 1] = y
 0115:                         SR_pairs[SR_index, 1, 2] = z
 0116: 
 0117:                         SR_pairs[SR_index, 0, 0] = pbc_hardwall(x + x_off, XDIM)
 0118:                         SR_pairs[SR_index, 0, 1] = pbc_hardwall(y + y_off, YDIM)
 0119:                         SR_pairs[SR_index, 0, 2] = pbc_hardwall(z + z_off, ZDIM)
 0120: 
 0121:                     else:
 0122:                         SR_pairs[SR_index, 0, 0] = x
 0123:                         SR_pairs[SR_index, 0, 1] = y
 0124:                         SR_pairs[SR_index, 0, 2] = z
 0125: 
 0126:                         SR_pairs[SR_index, 1, 0] = pbc_hardwall(x + x_off, XDIM)
 0127:                         SR_pairs[SR_index, 1, 1] = pbc_hardwall(y + y_off, YDIM)
 0128:                         SR_pairs[SR_index, 1, 2] = pbc_hardwall(z + z_off, ZDIM)
 0129: 
 0130:                     SR_index = SR_index+1
 0131: 
 0132: 
 0133:         # delete the self-pair
 0134:         SR_pairs = np.delete(SR_pairs, 13,0)
 0135: 
 0136:         #for i in SR_pairs:
 0137:         #    print "[%i, %i, %i] -- [%i, %i, %i]" %(i[0][0],i[0][1],i[0][2],i[1][0],i[1][1],i[1][2],)
 0138: 
 0139: 
 0140:         return (SR_pairs, np.array([], dtype=np.int), np.array([], dtype=int))
 0141:         """
 0142: 
+0143:     elif LR_position == 1:
    break;
    default:
 0144: 
 0145: 
+0146:         SR_pairs  = np.zeros((26,2,3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_6 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_6);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_9 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_tuple[1]};
      __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 146, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_4, __pyx_t_10, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 146, __pyx_L1_error)
      __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    }
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 146, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_7), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
        __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
      }
      __pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 146, __pyx_L1_error)
    }
    __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[1] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_26, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_3); if (unlikely(!__pyx_mstate_global->__pyx_tuple[1])) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[1]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[1]);
+0147:         LR_pairs  = np.zeros((98, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_9 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_9 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[2]};
      __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_10, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 147, __pyx_L1_error)
      __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    }
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 147, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_7), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_14, __pyx_t_13, __pyx_t_12);
        }
        __pyx_t_14 = __pyx_t_13 = __pyx_t_12 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 147, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[2] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_98, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_3); if (unlikely(!__pyx_mstate_global->__pyx_tuple[2])) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[2]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[2]);
+0148:         SLR_pairs = np.zeros((218, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_9 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_tuple[3]};
      __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_6, __pyx_t_2, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 148, __pyx_L1_error)
      __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 148, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    }
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 148, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_7), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
        __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 148, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[3] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_218, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_3); if (unlikely(!__pyx_mstate_global->__pyx_tuple[3])) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[3]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[3]);
 0149: 
+0150:         SR_index  = 0
    __pyx_v_SR_index = 0;
+0151:         LR_index  = 0
    __pyx_v_LR_index = 0;
+0152:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 0153: 
 0154:         # loop over long range cube around site
+0155:         for x_off in xrange(-3,4):
    for (__pyx_t_15 = -3; __pyx_t_15 < 4; __pyx_t_15+=1) {
      __pyx_v_x_off = __pyx_t_15;
+0156:             for y_off in xrange(-3,4):
      for (__pyx_t_16 = -3; __pyx_t_16 < 4; __pyx_t_16+=1) {
        __pyx_v_y_off = __pyx_t_16;
+0157:                 for z_off in xrange(-3,4):
        for (__pyx_t_17 = -3; __pyx_t_17 < 4; __pyx_t_17+=1) {
          __pyx_v_z_off = __pyx_t_17;
+0158:                     x_p = pbc_hardwall(x + x_off, XDIM)
          __pyx_t_18 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_18 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 158, __pyx_L1_error)
          __pyx_v_x_p = __pyx_t_18;
+0159:                     y_p = pbc_hardwall(y + y_off, YDIM)
          __pyx_t_18 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_18 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 159, __pyx_L1_error)
          __pyx_v_y_p = __pyx_t_18;
+0160:                     z_p = pbc_hardwall(z + z_off, ZDIM)
          __pyx_t_18 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_z + __pyx_v_z_off), __pyx_v_ZDIM); if (unlikely(__pyx_t_18 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 160, __pyx_L1_error)
          __pyx_v_z_p = __pyx_t_18;
 0161: 
 0162:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0163:                     # if short range_interaction
+0164:                     if abs(x_off) < 2 and abs(y_off) < 2 and abs(z_off) <2:
          __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_x_off); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyNumber_Absolute(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyObject_RichCompare(__pyx_t_10, __pyx_mstate_global->__pyx_int_2, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_20 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_20 < 0))) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (__pyx_t_20) {
          } else {
            __pyx_t_19 = __pyx_t_20;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_y_off); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyNumber_Absolute(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyObject_RichCompare(__pyx_t_10, __pyx_mstate_global->__pyx_int_2, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_20 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_20 < 0))) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (__pyx_t_20) {
          } else {
            __pyx_t_19 = __pyx_t_20;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_z_off); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyNumber_Absolute(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyObject_RichCompare(__pyx_t_10, __pyx_mstate_global->__pyx_int_2, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_20 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_20 < 0))) __PYX_ERR(0, 164, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_19 = __pyx_t_20;
          __pyx_L10_bool_binop_done:;
          if (__pyx_t_19) {
/* … */
            goto __pyx_L9;
          }
+0165:                         if x_off == 0 and y_off == 0 and z_off == 0:
            __pyx_t_20 = (__pyx_v_x_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L14_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L14_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_z_off == 0);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L14_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
            }
+0166:                             continue
              goto __pyx_L7_continue;
+0167:                         if x_p == -1 or y_p == -1 or z_p == -1:
            __pyx_t_20 = (__pyx_v_x_p == -1L);
            if (!__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L18_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_p == -1L);
            if (!__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L18_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_z_p == -1L);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L18_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
            }
+0168:                             continue
              goto __pyx_L7_continue;
 0169: 
 0170:                         # if x_off > 0 then the non-central position must come first in the pair
+0171:                         if x_off > 0:
            __pyx_t_19 = (__pyx_v_x_off > 0);
            if (__pyx_t_19) {
/* … */
              goto __pyx_L21;
            }
+0172:                             SR_pairs[SR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0173:                             SR_pairs[SR_index, 1, 1] = y
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0174:                             SR_pairs[SR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0175: 
+0176:                             SR_pairs[SR_index, 0, 0] = x_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0177:                             SR_pairs[SR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0178:                             SR_pairs[SR_index, 0, 2] = z_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0179: 
 0180: 
 0181:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0182:                         elif x_off == 0 and y_off > 0:
            __pyx_t_20 = (__pyx_v_x_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L22_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_off > 0);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L22_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
              goto __pyx_L21;
            }
+0183:                             SR_pairs[SR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0184:                             SR_pairs[SR_index, 1, 1] = y
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0185:                             SR_pairs[SR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0186: 
+0187:                             SR_pairs[SR_index, 0, 0] = x_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0188:                             SR_pairs[SR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0189:                             SR_pairs[SR_index, 0, 2] = z_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0190: 
 0191:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+0192:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_20 = (__pyx_v_x_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L24_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L24_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_z_off > 0);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L24_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
              goto __pyx_L21;
            }
+0193:                             SR_pairs[SR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0194:                             SR_pairs[SR_index, 1, 1] = y
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0195:                             SR_pairs[SR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0196: 
+0197:                             SR_pairs[SR_index, 0, 0] = x_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0198:                             SR_pairs[SR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0199:                             SR_pairs[SR_index, 0, 2] = z_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0200: 
 0201:                         else:
+0202:                             SR_pairs[SR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0203:                             SR_pairs[SR_index, 0, 1] = y
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0204:                             SR_pairs[SR_index, 0, 2] = z
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0205: 
+0206:                             SR_pairs[SR_index, 1, 0] = x_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0207:                             SR_pairs[SR_index, 1, 1] = y_p
              __pyx_t_1 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0208:                             SR_pairs[SR_index, 1, 2] = z_p
              __pyx_t_22 = __pyx_v_SR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L21:;
 0209: 
+0210:                         SR_index = SR_index+1
            __pyx_v_SR_index = (__pyx_v_SR_index + 1);
 0211: 
 0212:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0213:                     ## Long range interaction
+0214:                     elif abs(x_off) < 3 and abs(y_off) < 3 and abs(z_off) < 3:
          __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_x_off); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyNumber_Absolute(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyObject_RichCompare(__pyx_t_10, __pyx_mstate_global->__pyx_int_3, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_20 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_20 < 0))) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (__pyx_t_20) {
          } else {
            __pyx_t_19 = __pyx_t_20;
            goto __pyx_L27_bool_binop_done;
          }
          __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_y_off); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyNumber_Absolute(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyObject_RichCompare(__pyx_t_10, __pyx_mstate_global->__pyx_int_3, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_20 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_20 < 0))) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (__pyx_t_20) {
          } else {
            __pyx_t_19 = __pyx_t_20;
            goto __pyx_L27_bool_binop_done;
          }
          __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_z_off); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyNumber_Absolute(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyObject_RichCompare(__pyx_t_10, __pyx_mstate_global->__pyx_int_3, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_20 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_20 < 0))) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_19 = __pyx_t_20;
          __pyx_L27_bool_binop_done:;
          if (__pyx_t_19) {
/* … */
            goto __pyx_L9;
          }
+0215:                         if x_p == -1 or y_p == -1 or z_p == -1:
            __pyx_t_20 = (__pyx_v_x_p == -1L);
            if (!__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L31_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_p == -1L);
            if (!__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L31_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_z_p == -1L);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L31_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
            }
+0216:                             continue
              goto __pyx_L7_continue;
+0217:                         if type_grid[x_p, y_p, z_p] == 0:
            __pyx_t_1 = __pyx_v_x_p;
            __pyx_t_21 = __pyx_v_y_p;
            __pyx_t_22 = __pyx_v_z_p;
            __pyx_t_19 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_1 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_21 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_22 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_19) {
/* … */
            }
+0218:                             continue
              goto __pyx_L7_continue;
 0219: 
 0220:                         # if x_off < 0 then the non-central position must come first in the pair
+0221:                         if x_off > 0:
            __pyx_t_19 = (__pyx_v_x_off > 0);
            if (__pyx_t_19) {
/* … */
              goto __pyx_L35;
            }
+0222:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0223:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0224:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0225: 
+0226:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0227:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0228:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0229: 
 0230:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0231:                         elif x_off == 0 and y_off > 0:
            __pyx_t_20 = (__pyx_v_x_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L36_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_off > 0);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L36_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
              goto __pyx_L35;
            }
+0232:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0233:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0234:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0235: 
+0236:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0237:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0238:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0239: 
 0240:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+0241:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_20 = (__pyx_v_x_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L38_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L38_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_z_off > 0);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L38_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
              goto __pyx_L35;
            }
+0242:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0243:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0244:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0245: 
+0246:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0247:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0248:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0249: 
 0250:                         else:
+0251:                             LR_pairs[LR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0252:                             LR_pairs[LR_index, 0, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0253:                             LR_pairs[LR_index, 0, 2] = z
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0254: 
+0255:                             LR_pairs[LR_index, 1, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0256:                             LR_pairs[LR_index, 1, 1] = y_p
              __pyx_t_22 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0257:                             LR_pairs[LR_index, 1, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L35:;
 0258: 
+0259:                         LR_index = LR_index+1
            __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 0260: 
 0261:                     # SUPER LONG RANGE INTERACTIONS...
 0262:                     else:
+0263:                         if x_p == -1 or y_p == -1 or z_p == -1:
          /*else*/ {
            __pyx_t_20 = (__pyx_v_x_p == -1L);
            if (!__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L42_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_p == -1L);
            if (!__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L42_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_z_p == -1L);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L42_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
            }
+0264:                             continue
              goto __pyx_L7_continue;
+0265:                         if type_grid[x_p, y_p, z_p] == 0:
            __pyx_t_22 = __pyx_v_x_p;
            __pyx_t_21 = __pyx_v_y_p;
            __pyx_t_1 = __pyx_v_z_p;
            __pyx_t_19 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_22 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_21 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_1 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_19) {
/* … */
            }
+0266:                             continue
              goto __pyx_L7_continue;
 0267: 
 0268:                         # if x_off < 0 then the non-central position must come first in the pair
+0269:                         if x_off > 0:
            __pyx_t_19 = (__pyx_v_x_off > 0);
            if (__pyx_t_19) {
/* … */
              goto __pyx_L46;
            }
+0270:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0271:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0272:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0273: 
+0274:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0275:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0276:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0277: 
 0278:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0279:                         elif x_off == 0 and y_off > 0:
            __pyx_t_20 = (__pyx_v_x_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L47_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_off > 0);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L47_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
              goto __pyx_L46;
            }
+0280:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0281:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0282:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0283: 
+0284:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0285:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0286:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0287: 
 0288:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+0289:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_20 = (__pyx_v_x_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L49_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_y_off == 0);
            if (__pyx_t_20) {
            } else {
              __pyx_t_19 = __pyx_t_20;
              goto __pyx_L49_bool_binop_done;
            }
            __pyx_t_20 = (__pyx_v_z_off > 0);
            __pyx_t_19 = __pyx_t_20;
            __pyx_L49_bool_binop_done:;
            if (__pyx_t_19) {
/* … */
              goto __pyx_L46;
            }
+0290:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0291:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0292:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0293: 
+0294:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0295:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0296:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0297: 
 0298:                         else:
+0299:                             SLR_pairs[SLR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0300:                             SLR_pairs[SLR_index, 0, 1] = y
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0301:                             SLR_pairs[SLR_index, 0, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 0;
              __pyx_t_22 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0302: 
+0303:                             SLR_pairs[SLR_index, 1, 0] = x_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0304:                             SLR_pairs[SLR_index, 1, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_22 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0305:                             SLR_pairs[SLR_index, 1, 2] = z_p
              __pyx_t_22 = __pyx_v_SLR_index;
              __pyx_t_21 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L46:;
 0306: 
+0307:                         SLR_index = SLR_index+1
            __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
          }
          __pyx_L9:;
          __pyx_L7_continue:;
        }
      }
    }
 0308: 
 0309: 
+0310:         return (SR_pairs[0:SR_index], LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __Pyx_PyLong_From_npy_int32(__pyx_v_SR_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_7, Py_None); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SR_pairs), __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyLong_From_npy_int32(__pyx_v_LR_index); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_10, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyLong_From_npy_int32(__pyx_v_SLR_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 310, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_10);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10) != (0)) __PYX_ERR(0, 310, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2) != (0)) __PYX_ERR(0, 310, __pyx_L1_error);
    __pyx_t_7 = 0;
    __pyx_t_10 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
 0311: 
 0312: 
 0313: 
 0314: 
 0315:     else:
+0316:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_9 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_9 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 316, __pyx_L1_error)
    break;
  }
 0317: 
 0318: 
+0319: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_3extract_SR_and_LR_pairs_from_position_2D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_2extract_SR_and_LR_pairs_from_position_2D_hardwall, "\n    Extracts the short-range and long-range pairs from a given position in the\n    type grid.  This is a 2D version of the function above.\n\n    Parameters\n    ----------\n    position : NUMPY_INT_TYPE[:]\n        The position in the type grid from which to extract the pairs.\n\n    LR_position : int\n        The long-range position to use.  0 for short-range only, 1 for long-range\n        only, 2 for both.\n\n    type_grid : NUMPY_INT_TYPE[:,:]\n        The type grid.\n\n    XDIM : int\n        The x dimension of the type grid.\n\n    YDIM : int\n        The y dimension of the type grid.\n\n    Returns\n    -------\n    SR_pairs : cnp.ndarray[NUMPY_INT_TYPE, ndim=3]\n        The short-range pairs.\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_3extract_SR_and_LR_pairs_from_position_2D_hardwall = {"extract_SR_and_LR_pairs_from_position_2D_hardwall", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_3extract_SR_and_LR_pairs_from_position_2D_hardwall, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_2extract_SR_and_LR_pairs_from_position_2D_hardwall};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_3extract_SR_and_LR_pairs_from_position_2D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_SR_and_LR_pairs_from_position_2D_hardwall (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,0};
  PyObject* values[5] = {0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 319, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 319, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 319, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 319, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 319, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 319, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_and_LR_pairs_from_position_2D_hardwall", 0) < (0)) __PYX_ERR(0, 319, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_2D_hardwall", 1, 5, 5, i); __PYX_ERR(0, 319, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 5)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 319, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 319, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 319, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 319, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 319, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 321, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_LR_position == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 322, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 323, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 324, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 325, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_2D_hardwall", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 319, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_and_LR_pairs_from_position_2D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_2extract_SR_and_LR_pairs_from_position_2D_hardwall(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_2extract_SR_and_LR_pairs_from_position_2D_hardwall(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, int __pyx_v_XDIM, int __pyx_v_YDIM) {
  int __pyx_v_SR_index;
  int __pyx_v_LR_index;
  int __pyx_v_SLR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  int __pyx_v_x;
  int __pyx_v_y;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  { 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_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_and_LR_pairs_from_position_2D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_3extract_SR_and_LR_pairs_from_position_2D_hardwall, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos_2, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos_2, __pyx_t_4) < (0)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0320: @cython.wraparound(False)
 0321: def extract_SR_and_LR_pairs_from_position_2D_hardwall(NUMPY_INT_TYPE[:] position,
 0322:                                                       int LR_position,
 0323:                                                       NUMPY_INT_TYPE[:,:] type_grid,
 0324:                                                       int XDIM,
 0325:                                                       int YDIM):
 0326:     """
 0327:     Extracts the short-range and long-range pairs from a given position in the
 0328:     type grid.  This is a 2D version of the function above.
 0329: 
 0330:     Parameters
 0331:     ----------
 0332:     position : NUMPY_INT_TYPE[:]
 0333:         The position in the type grid from which to extract the pairs.
 0334: 
 0335:     LR_position : int
 0336:         The long-range position to use.  0 for short-range only, 1 for long-range
 0337:         only, 2 for both.
 0338: 
 0339:     type_grid : NUMPY_INT_TYPE[:,:]
 0340:         The type grid.
 0341: 
 0342:     XDIM : int
 0343:         The x dimension of the type grid.
 0344: 
 0345:     YDIM : int
 0346:         The y dimension of the type grid.
 0347: 
 0348:     Returns
 0349:     -------
 0350:     SR_pairs : cnp.ndarray[NUMPY_INT_TYPE, ndim=3]
 0351:         The short-range pairs.
 0352: 
 0353:     """
 0354: 
 0355:     # declare some variables
 0356:     cdef int SR_index, LR_index, SLR_index, x_off, y_off
 0357:     cdef int x_p, y_p
 0358: 
 0359:     # first set the central x, y and z positions
+0360:     cdef int x = position[0]
  __pyx_t_1 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+0361:     cdef int y = position[1]
  __pyx_t_1 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
 0362: 
 0363:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs
 0364:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 0365:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 0366: 
 0367: 
 0368:     # short range only
+0369:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
 0370: 
+0371:         return (extract_SR_pairs_from_position_2D_hardwall(position, XDIM, YDIM), np.array([], dtype=NUMPY_INT_TYPE_PYTHON), np.array([], dtype=NUMPY_INT_TYPE_PYTHON))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_position, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_XDIM); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyLong_From_int(__pyx_v_YDIM); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_t_5, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_7 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_7);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, __pyx_t_6};
      __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_9, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 371, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __pyx_t_9 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_9);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_9, __pyx_t_3};
      __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_7, __pyx_t_10, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 371, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 371, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4) != (0)) __PYX_ERR(0, 371, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_5);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5) != (0)) __PYX_ERR(0, 371, __pyx_L1_error);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
 0372: 
 0373:         # the code below is (best I can tell) just reprodicing the function
 0374:         # extract_SR_pairs_from_position_2D_hardwalll, so I have used this
 0375:         """
 0376:         for x_off in xrange(-1,2):
 0377:             for y_off in xrange(-1,2):
 0378: 
 0379:                     # if x_off < 0 then the non-central position must come first in the pair
 0380:                     if x_off > 0:
 0381:                         SR_pairs[SR_index, 1, 0] = x
 0382:                         SR_pairs[SR_index, 1, 1] = y
 0383: 
 0384:                         SR_pairs[SR_index, 0, 0] = pbc_hardwall(x + x_off, XDIM)
 0385:                         SR_pairs[SR_index, 0, 1] = pbc_hardwall(y + y_off, YDIM)
 0386: 
 0387: 
 0388:                     # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
 0389:                     elif x_off == 0 and y_off > 0:
 0390:                         SR_pairs[SR_index, 1, 0] = x
 0391:                         SR_pairs[SR_index, 1, 1] = y
 0392: 
 0393:                         SR_pairs[SR_index, 0, 0] = pbc_hardwall(x + x_off, XDIM)
 0394:                         SR_pairs[SR_index, 0, 1] = pbc_hardwall(y + y_off, YDIM)
 0395: 
 0396:                     else:
 0397:                         SR_pairs[SR_index, 0, 0] = x
 0398:                         SR_pairs[SR_index, 0, 1] = y
 0399: 
 0400:                         SR_pairs[SR_index, 1, 0] = pbc_hardwall(x + x_off, XDIM)
 0401:                         SR_pairs[SR_index, 1, 1] = pbc_hardwall(y + y_off, YDIM)
 0402: 
 0403:                     SR_index = SR_index+1
 0404: 
 0405: 
 0406:         # delete the self-pair
 0407:         SR_pairs = np.delete(SR_pairs, 4,0)
 0408: 
 0409:         # delete pairs which would extend across a boundary
 0410:         SR_pairs = delete_pbc_pairs(SR_pairs, 2)
 0411: 
 0412:         # return is SR, LR, SLR
 0413:         return (SR_pairs, np.array([], dtype=int), np.array([], dtype=int))
 0414:         """
 0415: 
+0416:     elif LR_position == 1:
    break;
    default:
 0417: 
 0418: 
+0419:         SR_pairs  = np.zeros((8,  2, 2), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, __pyx_mstate_global->__pyx_tuple[4]};
      __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 419, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_4, __pyx_t_10, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 419, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 419, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 419, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
        __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
      }
      __pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 419, __pyx_L1_error)
    }
    __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[4] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_8, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_2); if (unlikely(!__pyx_mstate_global->__pyx_tuple[4])) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[4]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[4]);
+0420:         LR_pairs  = np.zeros((16, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON) # 5 x 5 -  3 x 3
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[5]};
      __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_10, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 420, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 420, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_14, __pyx_t_13, __pyx_t_12);
        }
        __pyx_t_14 = __pyx_t_13 = __pyx_t_12 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 420, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[5] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_16, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_2); if (unlikely(!__pyx_mstate_global->__pyx_tuple[5])) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[5]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[5]);
+0421:         SLR_pairs = np.zeros((24, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON) # 7 x 7 -  5 x 5
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_tuple[6]};
      __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_5, __pyx_t_2, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 421, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 421, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
        __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 421, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
 0422: 
+0423:         SR_index = 0
    __pyx_v_SR_index = 0;
+0424:         LR_index = 0
    __pyx_v_LR_index = 0;
+0425:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 0426: 
 0427:         # loop over long range cube around site
+0428:         for x_off in xrange(-3,4):
    for (__pyx_t_11 = -3; __pyx_t_11 < 4; __pyx_t_11+=1) {
      __pyx_v_x_off = __pyx_t_11;
+0429:             for y_off in xrange(-3,4):
      for (__pyx_t_15 = -3; __pyx_t_15 < 4; __pyx_t_15+=1) {
        __pyx_v_y_off = __pyx_t_15;
+0430:                     x_p = pbc_hardwall(x + x_off, XDIM)
        __pyx_t_16 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_16 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 430, __pyx_L1_error)
        __pyx_v_x_p = __pyx_t_16;
+0431:                     y_p = pbc_hardwall(y + y_off, YDIM)
        __pyx_t_16 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_16 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 431, __pyx_L1_error)
        __pyx_v_y_p = __pyx_t_16;
 0432: 
 0433:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0434:                     # if short range_interaction
+0435:                     if abs(x_off) < 2 and abs(y_off) < 2:
        __pyx_t_18 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 435, __pyx_L1_error)
        __pyx_t_19 = (__pyx_t_18 < 2);
        if (__pyx_t_19) {
        } else {
          __pyx_t_17 = __pyx_t_19;
          goto __pyx_L8_bool_binop_done;
        }
        __pyx_t_18 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 435, __pyx_L1_error)
        __pyx_t_19 = (__pyx_t_18 < 2);
        __pyx_t_17 = __pyx_t_19;
        __pyx_L8_bool_binop_done:;
        if (__pyx_t_17) {
/* … */
          goto __pyx_L7;
        }
+0436:                         if x_off == 0 and y_off == 0:
          __pyx_t_19 = (__pyx_v_x_off == 0);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L11_bool_binop_done;
          }
          __pyx_t_19 = (__pyx_v_y_off == 0);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L11_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
          }
+0437:                             continue
            goto __pyx_L5_continue;
+0438:                         if x_p == -1 or y_p == -1:
          __pyx_t_19 = (__pyx_v_x_p == -1L);
          if (!__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L14_bool_binop_done;
          }
          __pyx_t_19 = (__pyx_v_y_p == -1L);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L14_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
          }
+0439:                             continue
            goto __pyx_L5_continue;
 0440: 
 0441:                         # if x_off < 0 then the non-central position must come first in the pair
+0442:                         if x_off > 0:
          __pyx_t_17 = (__pyx_v_x_off > 0);
          if (__pyx_t_17) {
/* … */
            goto __pyx_L16;
          }
+0443:                             SR_pairs[SR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SR_index;
            __pyx_t_20 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0444:                             SR_pairs[SR_index, 1, 1] = y
            __pyx_t_21 = __pyx_v_SR_index;
            __pyx_t_20 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 0445: 
+0446:                             SR_pairs[SR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SR_index;
            __pyx_t_20 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0447:                             SR_pairs[SR_index, 0, 1] = y_p
            __pyx_t_21 = __pyx_v_SR_index;
            __pyx_t_20 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0448: 
 0449:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0450:                         elif x_off == 0 and y_off > 0:
          __pyx_t_19 = (__pyx_v_x_off == 0);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L17_bool_binop_done;
          }
          __pyx_t_19 = (__pyx_v_y_off > 0);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L17_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
            goto __pyx_L16;
          }
+0451:                             SR_pairs[SR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SR_index;
            __pyx_t_20 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0452:                             SR_pairs[SR_index, 1, 1] = y
            __pyx_t_21 = __pyx_v_SR_index;
            __pyx_t_20 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 0453: 
+0454:                             SR_pairs[SR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SR_index;
            __pyx_t_20 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0455:                             SR_pairs[SR_index, 0, 1] = y_p
            __pyx_t_21 = __pyx_v_SR_index;
            __pyx_t_20 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0456: 
 0457: 
 0458:                         else:
+0459:                             SR_pairs[SR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_1 = __pyx_v_SR_index;
            __pyx_t_20 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0460:                             SR_pairs[SR_index, 0, 1] = y
            __pyx_t_21 = __pyx_v_SR_index;
            __pyx_t_20 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 0461: 
+0462:                             SR_pairs[SR_index, 1, 0] = x_p
            __pyx_t_1 = __pyx_v_SR_index;
            __pyx_t_20 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0463:                             SR_pairs[SR_index, 1, 1] = y_p
            __pyx_t_21 = __pyx_v_SR_index;
            __pyx_t_20 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L16:;
 0464: 
+0465:                         SR_index = SR_index+1
          __pyx_v_SR_index = (__pyx_v_SR_index + 1);
 0466: 
 0467:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0468:                     ## Long range interaction
+0469:                     elif abs(x_off) < 3 and abs(y_off) < 3:
        __pyx_t_18 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 469, __pyx_L1_error)
        __pyx_t_19 = (__pyx_t_18 < 3);
        if (__pyx_t_19) {
        } else {
          __pyx_t_17 = __pyx_t_19;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_18 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 469, __pyx_L1_error)
        __pyx_t_19 = (__pyx_t_18 < 3);
        __pyx_t_17 = __pyx_t_19;
        __pyx_L19_bool_binop_done:;
        if (__pyx_t_17) {
/* … */
          goto __pyx_L7;
        }
+0470:                         if x_p == -1 or y_p == -1:
          __pyx_t_19 = (__pyx_v_x_p == -1L);
          if (!__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L22_bool_binop_done;
          }
          __pyx_t_19 = (__pyx_v_y_p == -1L);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L22_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
          }
+0471:                             continue
            goto __pyx_L5_continue;
+0472:                         if type_grid[x_p, y_p] == 0:
          __pyx_t_1 = __pyx_v_x_p;
          __pyx_t_20 = __pyx_v_y_p;
          __pyx_t_17 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_1 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_20 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_17) {
/* … */
          }
+0473:                             continue
            goto __pyx_L5_continue;
 0474: 
 0475:                         # if x_off < 0 then the non-central position must come first in the pair
+0476:                         if x_off > 0:
          __pyx_t_17 = (__pyx_v_x_off > 0);
          if (__pyx_t_17) {
/* … */
            goto __pyx_L25;
          }
+0477:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0478:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_21 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_20 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 0479: 
+0480:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0481:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_21 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_20 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0482: 
 0483: 
 0484:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0485:                         elif x_off == 0 and y_off > 0:
          __pyx_t_19 = (__pyx_v_x_off == 0);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L26_bool_binop_done;
          }
          __pyx_t_19 = (__pyx_v_y_off > 0);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L26_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
            goto __pyx_L25;
          }
+0486:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0487:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_21 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_20 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 0488: 
+0489:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0490:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_21 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_20 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0491: 
 0492:                         else:
+0493:                             LR_pairs[LR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0494:                             LR_pairs[LR_index, 0, 1] = y
            __pyx_t_21 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_20 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 0495: 
+0496:                             LR_pairs[LR_index, 1, 0] = x_p
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0497:                             LR_pairs[LR_index, 1, 1] = y_p
            __pyx_t_21 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_20 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L25:;
 0498: 
+0499:                         LR_index = LR_index+1
          __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 0500: 
 0501:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0502:                     # SUPER LONG RANGE INTERACTIONS...
 0503:                     else:
+0504:                         if x_p == -1 or y_p == -1:
        /*else*/ {
          __pyx_t_19 = (__pyx_v_x_p == -1L);
          if (!__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L29_bool_binop_done;
          }
          __pyx_t_19 = (__pyx_v_y_p == -1L);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L29_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
          }
+0505:                             continue
            goto __pyx_L5_continue;
+0506:                         if type_grid[x_p, y_p] == 0:
          __pyx_t_20 = __pyx_v_x_p;
          __pyx_t_1 = __pyx_v_y_p;
          __pyx_t_17 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_20 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_1 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_17) {
/* … */
          }
+0507:                             continue
            goto __pyx_L5_continue;
 0508: 
 0509:                         # if x_off < 0 then the non-central position must come first in the pair
+0510:                         if x_off > 0:
          __pyx_t_17 = (__pyx_v_x_off > 0);
          if (__pyx_t_17) {
/* … */
            goto __pyx_L32;
          }
+0511:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_20 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0512:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_21 = __pyx_v_SLR_index;
            __pyx_t_20 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 0513: 
+0514:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_20 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0515:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_21 = __pyx_v_SLR_index;
            __pyx_t_20 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0516: 
 0517:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0518:                         elif x_off == 0 and y_off > 0:
          __pyx_t_19 = (__pyx_v_x_off == 0);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L33_bool_binop_done;
          }
          __pyx_t_19 = (__pyx_v_y_off > 0);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L33_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
            goto __pyx_L32;
          }
+0519:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_20 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0520:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_21 = __pyx_v_SLR_index;
            __pyx_t_20 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 0521: 
+0522:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_20 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0523:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_21 = __pyx_v_SLR_index;
            __pyx_t_20 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0524: 
 0525:                         else:
+0526:                             SLR_pairs[SLR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_20 = 0;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0527:                             SLR_pairs[SLR_index, 0, 1] = y
            __pyx_t_21 = __pyx_v_SLR_index;
            __pyx_t_20 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 0528: 
+0529:                             SLR_pairs[SLR_index, 1, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_20 = 1;
            __pyx_t_21 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0530:                             SLR_pairs[SLR_index, 1, 1] = y_p
            __pyx_t_21 = __pyx_v_SLR_index;
            __pyx_t_20 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L32:;
 0531: 
+0532:                         SLR_index = SLR_index+1
          __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
        }
        __pyx_L7:;
        __pyx_L5_continue:;
      }
    }
 0533: 
+0534:         return (SR_pairs[0:SR_index], LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_SR_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SR_pairs), __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyLong_From_int(__pyx_v_LR_index); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_10, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_SLR_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 534, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_10);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_10) != (0)) __PYX_ERR(0, 534, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2) != (0)) __PYX_ERR(0, 534, __pyx_L1_error);
    __pyx_t_6 = 0;
    __pyx_t_10 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
 0535: 
 0536: 
 0537:     else:
+0538:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 538, __pyx_L1_error)
    break;
  }
 0539: 
 0540: 
+0541: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_5extract_LR_pairs_from_position_3D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_4extract_LR_pairs_from_position_3D_hardwall, "\n    Same as extract_all except ONLY returns LR and SLR pairs\n\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_5extract_LR_pairs_from_position_3D_hardwall = {"extract_LR_pairs_from_position_3D_hardwall", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_5extract_LR_pairs_from_position_3D_hardwall, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_4extract_LR_pairs_from_position_3D_hardwall};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_5extract_LR_pairs_from_position_3D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  int __pyx_v_ZDIM;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_LR_pairs_from_position_3D_hardwall (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,&__pyx_mstate_global->__pyx_n_u_ZDIM,0};
  PyObject* values[6] = {0,0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 541, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  6:
        values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 541, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 541, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 541, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 541, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 541, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 541, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_LR_pairs_from_position_3D_hardwall", 0) < (0)) __PYX_ERR(0, 541, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 6; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_3D_hardwall", 1, 6, 6, i); __PYX_ERR(0, 541, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 6)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 541, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 541, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 541, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 541, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 541, __pyx_L3_error)
      values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 541, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 543, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_LR_position == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 544, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 545, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 546, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 547, __pyx_L3_error)
    __pyx_v_ZDIM = __Pyx_PyLong_As_int(values[5]); if (unlikely((__pyx_v_ZDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 548, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_3D_hardwall", 1, 6, 6, __pyx_nargs); __PYX_ERR(0, 541, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_LR_pairs_from_position_3D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_4extract_LR_pairs_from_position_3D_hardwall(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM, __pyx_v_ZDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_4extract_LR_pairs_from_position_3D_hardwall(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, int __pyx_v_XDIM, int __pyx_v_YDIM, int __pyx_v_ZDIM) {
  int __pyx_v_LR_index;
  int __pyx_v_SLR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_z_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  int __pyx_v_z_p;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_z;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  { 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_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_LR_pairs_from_position_3D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_5extract_LR_pairs_from_position_3D_hardwall, 0, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_3, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_3, __pyx_t_4) < (0)) __PYX_ERR(0, 541, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0542: @cython.wraparound(False)
 0543: def extract_LR_pairs_from_position_3D_hardwall(NUMPY_INT_TYPE[:] position,
 0544:                                       int LR_position,
 0545:                                       NUMPY_INT_TYPE[:,:,:] type_grid,
 0546:                                       int XDIM,
 0547:                                       int YDIM,
 0548:                                       int ZDIM):
 0549:     """
 0550:     Same as extract_all except ONLY returns LR and SLR pairs
 0551: 
 0552: 
 0553:     """
 0554: 
 0555:     # declare some variables
 0556:     cdef int LR_index, SLR_index, x_off, y_off, z_off
 0557:     cdef int x_p, y_p, z_p
 0558:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 0559:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 0560: 
 0561:     # first set the central x, y and z positions
+0562:     cdef int x = position[0]
  __pyx_t_1 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+0563:     cdef int y = position[1]
  __pyx_t_1 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+0564:     cdef int z = position[2]
  __pyx_t_1 = 2;
  __pyx_v_z = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
 0565: 
 0566:     # if no long-range interactions required the return empy
 0567:     # arrays
+0568:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
+0569:         return (np.array([], dtype=NUMPY_INT_TYPE_PYTHON), np.array([], dtype=NUMPY_INT_TYPE_PYTHON))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_t_4};
      __pyx_t_8 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_6, __pyx_t_8, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 569, __pyx_L1_error)
      __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_8);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_8 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_8);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_8, __pyx_t_6};
      __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_9, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 569, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 569, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 569, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_5);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 569, __pyx_L1_error);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
 0570: 
+0571:     elif LR_position == 1:
    break;
    default:
+0572:         LR_pairs = np.zeros((98, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, __pyx_mstate_global->__pyx_tuple[2]};
      __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_2, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 572, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 572, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
        __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 572, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
+0573:         SLR_pairs = np.zeros((218, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_9 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_9);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_9, __pyx_mstate_global->__pyx_tuple[3]};
      __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 573, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 573, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 573, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 573, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
        }
        __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 573, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
 0574: 
+0575:         LR_index = 0
    __pyx_v_LR_index = 0;
+0576:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 0577: 
 0578:         # loop over long range cube around site
+0579:         for x_off in xrange(-3,4):
    for (__pyx_t_10 = -3; __pyx_t_10 < 4; __pyx_t_10+=1) {
      __pyx_v_x_off = __pyx_t_10;
+0580:             for y_off in xrange(-3,4):
      for (__pyx_t_14 = -3; __pyx_t_14 < 4; __pyx_t_14+=1) {
        __pyx_v_y_off = __pyx_t_14;
+0581:                 for z_off in xrange(-3,4):
        for (__pyx_t_15 = -3; __pyx_t_15 < 4; __pyx_t_15+=1) {
          __pyx_v_z_off = __pyx_t_15;
+0582:                     x_p = pbc_hardwall(x + x_off, XDIM)
          __pyx_t_16 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_16 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 582, __pyx_L1_error)
          __pyx_v_x_p = __pyx_t_16;
+0583:                     y_p = pbc_hardwall(y + y_off, YDIM)
          __pyx_t_16 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_16 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 583, __pyx_L1_error)
          __pyx_v_y_p = __pyx_t_16;
+0584:                     z_p = pbc_hardwall(z + z_off, ZDIM)
          __pyx_t_16 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_z + __pyx_v_z_off), __pyx_v_ZDIM); if (unlikely(__pyx_t_16 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L1_error)
          __pyx_v_z_p = __pyx_t_16;
 0585: 
 0586:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0587:                     # if short range_interaction
+0588:                     if abs(x_off) < 2 and abs(y_off) < 2 and abs(z_off) <2:
          __pyx_t_18 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 588, __pyx_L1_error)
          __pyx_t_19 = (__pyx_t_18 < 2);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_18 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 588, __pyx_L1_error)
          __pyx_t_19 = (__pyx_t_18 < 2);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_18 = abs(__pyx_v_z_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 588, __pyx_L1_error)
          __pyx_t_19 = (__pyx_t_18 < 2);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L10_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
          }
+0589:                         continue
            goto __pyx_L7_continue;
 0590: 
 0591:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0592:                     ## Long range interaction
+0593:                     elif abs(x_off) < 3 and abs(y_off) < 3 and abs(z_off) < 3:
          __pyx_t_18 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 593, __pyx_L1_error)
          __pyx_t_19 = (__pyx_t_18 < 3);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L13_bool_binop_done;
          }
          __pyx_t_18 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 593, __pyx_L1_error)
          __pyx_t_19 = (__pyx_t_18 < 3);
          if (__pyx_t_19) {
          } else {
            __pyx_t_17 = __pyx_t_19;
            goto __pyx_L13_bool_binop_done;
          }
          __pyx_t_18 = abs(__pyx_v_z_off); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 593, __pyx_L1_error)
          __pyx_t_19 = (__pyx_t_18 < 3);
          __pyx_t_17 = __pyx_t_19;
          __pyx_L13_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
            goto __pyx_L9;
          }
+0594:                         if x_p == -1 or y_p == -1 or z_p == -1:
            __pyx_t_19 = (__pyx_v_x_p == -1L);
            if (!__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L17_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_y_p == -1L);
            if (!__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L17_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_z_p == -1L);
            __pyx_t_17 = __pyx_t_19;
            __pyx_L17_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
            }
+0595:                             continue
              goto __pyx_L7_continue;
+0596:                         if type_grid[x_p, y_p, z_p] == 0:
            __pyx_t_1 = __pyx_v_x_p;
            __pyx_t_20 = __pyx_v_y_p;
            __pyx_t_21 = __pyx_v_z_p;
            __pyx_t_17 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_1 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_20 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_21 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_17) {
/* … */
            }
+0597:                             continue
              goto __pyx_L7_continue;
 0598: 
 0599:                         # if x_off < 0 then the non-central position must come first in the pair
+0600:                         if x_off > 0:
            __pyx_t_17 = (__pyx_v_x_off > 0);
            if (__pyx_t_17) {
/* … */
              goto __pyx_L21;
            }
+0601:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0602:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0603:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0604: 
+0605:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0606:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0607:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0608: 
 0609:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0610:                         elif x_off == 0 and y_off > 0:
            __pyx_t_19 = (__pyx_v_x_off == 0);
            if (__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L22_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_y_off > 0);
            __pyx_t_17 = __pyx_t_19;
            __pyx_L22_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L21;
            }
+0611:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0612:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0613:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0614: 
+0615:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0616:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0617:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0618: 
 0619:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+0620:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_19 = (__pyx_v_x_off == 0);
            if (__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L24_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_y_off == 0);
            if (__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L24_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_z_off > 0);
            __pyx_t_17 = __pyx_t_19;
            __pyx_L24_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L21;
            }
+0621:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0622:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0623:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0624: 
+0625:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0626:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0627:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0628: 
 0629:                         else:
+0630:                             LR_pairs[LR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0631:                             LR_pairs[LR_index, 0, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+0632:                             LR_pairs[LR_index, 0, 2] = z
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 0633: 
+0634:                             LR_pairs[LR_index, 1, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0635:                             LR_pairs[LR_index, 1, 1] = y_p
              __pyx_t_21 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0636:                             LR_pairs[LR_index, 1, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L21:;
 0637: 
+0638:                         LR_index = LR_index+1
            __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 0639: 
 0640:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0641:                     ## Super long range interaction
 0642:                     else:
+0643:                         if x_p == -1 or y_p == -1 or z_p == -1:
          /*else*/ {
            __pyx_t_19 = (__pyx_v_x_p == -1L);
            if (!__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L28_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_y_p == -1L);
            if (!__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L28_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_z_p == -1L);
            __pyx_t_17 = __pyx_t_19;
            __pyx_L28_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
            }
+0644:                             continue
              goto __pyx_L7_continue;
+0645:                         if type_grid[x_p, y_p, z_p] == 0:
            __pyx_t_21 = __pyx_v_x_p;
            __pyx_t_20 = __pyx_v_y_p;
            __pyx_t_1 = __pyx_v_z_p;
            __pyx_t_17 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_21 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_20 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_1 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_17) {
/* … */
            }
+0646:                             continue
              goto __pyx_L7_continue;
 0647: 
 0648:                         # if x_off < 0 then the non-central position must come first in the pair
+0649:                         if x_off > 0:
            __pyx_t_17 = (__pyx_v_x_off > 0);
            if (__pyx_t_17) {
/* … */
              goto __pyx_L32;
            }
+0650:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0651:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0652:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0653: 
+0654:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0655:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0656:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0657: 
 0658:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0659:                         elif x_off == 0 and y_off > 0:
            __pyx_t_19 = (__pyx_v_x_off == 0);
            if (__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L33_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_y_off > 0);
            __pyx_t_17 = __pyx_t_19;
            __pyx_L33_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L32;
            }
+0660:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0661:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0662:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0663: 
+0664:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0665:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0666:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0667: 
 0668:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+0669:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_19 = (__pyx_v_x_off == 0);
            if (__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L35_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_y_off == 0);
            if (__pyx_t_19) {
            } else {
              __pyx_t_17 = __pyx_t_19;
              goto __pyx_L35_bool_binop_done;
            }
            __pyx_t_19 = (__pyx_v_z_off > 0);
            __pyx_t_17 = __pyx_t_19;
            __pyx_L35_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L32;
            }
+0670:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0671:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0672:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0673: 
+0674:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0675:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0676:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0677: 
 0678:                         else:
+0679:                             SLR_pairs[SLR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0680:                             SLR_pairs[SLR_index, 0, 1] = y
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+0681:                             SLR_pairs[SLR_index, 0, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 0;
              __pyx_t_21 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 0682: 
+0683:                             SLR_pairs[SLR_index, 1, 0] = x_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0684:                             SLR_pairs[SLR_index, 1, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_21 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0685:                             SLR_pairs[SLR_index, 1, 2] = z_p
              __pyx_t_21 = __pyx_v_SLR_index;
              __pyx_t_20 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L32:;
 0686: 
+0687:                         SLR_index = SLR_index+1
            __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
          }
          __pyx_L9:;
          __pyx_L7_continue:;
        }
      }
    }
 0688: 
+0689:         return (LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_LR_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_SLR_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 689, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 689, __pyx_L1_error);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
 0690: 
 0691:     else:
+0692:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 692, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 692, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 692, __pyx_L1_error)
    break;
  }
 0693: 
 0694: 
 0695: ##
 0696: #################################################################################################
 0697: ##
+0698: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_7extract_SR_pairs_from_position_3D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_6extract_SR_pairs_from_position_3D_hardwall, "\n\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_7extract_SR_pairs_from_position_3D_hardwall = {"extract_SR_pairs_from_position_3D_hardwall", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_7extract_SR_pairs_from_position_3D_hardwall, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_6extract_SR_pairs_from_position_3D_hardwall};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_7extract_SR_pairs_from_position_3D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_XDIM;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_YDIM;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_ZDIM;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_SR_pairs_from_position_3D_hardwall (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,&__pyx_mstate_global->__pyx_n_u_ZDIM,0};
  PyObject* values[4] = {0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 698, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 698, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 698, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 698, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 698, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_pairs_from_position_3D_hardwall", 0) < (0)) __PYX_ERR(0, 698, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 4; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_3D_hardwall", 1, 4, 4, i); __PYX_ERR(0, 698, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 698, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 698, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 698, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 698, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 700, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_npy_int32(values[1]); if (unlikely((__pyx_v_XDIM == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_npy_int32(values[2]); if (unlikely((__pyx_v_YDIM == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 702, __pyx_L3_error)
    __pyx_v_ZDIM = __Pyx_PyLong_As_npy_int32(values[3]); if (unlikely((__pyx_v_ZDIM == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 703, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_3D_hardwall", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 698, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_pairs_from_position_3D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_6extract_SR_pairs_from_position_3D_hardwall(__pyx_self, __pyx_v_position, __pyx_v_XDIM, __pyx_v_YDIM, __pyx_v_ZDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_6extract_SR_pairs_from_position_3D_hardwall(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_XDIM, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_YDIM, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_ZDIM) {
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_SR_index;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_x_off;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_y_off;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_z_off;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_x_p;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_y_p;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_z_p;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_x;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_y;
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_z;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
/* … */
  /* 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_6);
  { 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_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_pairs_from_position_3D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_7extract_SR_pairs_from_position_3D_hardwall, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_3, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 698, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_3, __pyx_t_4) < (0)) __PYX_ERR(0, 698, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0699: @cython.wraparound(False)
 0700: def extract_SR_pairs_from_position_3D_hardwall(NUMPY_INT_TYPE[:] position,
 0701:                                                NUMPY_INT_TYPE XDIM,
 0702:                                                NUMPY_INT_TYPE YDIM,
 0703:                                                NUMPY_INT_TYPE ZDIM):
 0704:     """
 0705: 
 0706: 
 0707:     """
 0708: 
 0709:     # ~ash 2024-01-22
 0710:     # declare some variables; note we declare these here as NUMPY_INT_TYP but to be honest that's
 0711:     # probably not necessary, this was done while I was debugging some code and it works and is
 0712:     # fast but other functions define these tmp variables as int which I expect is fine. The main
 0713:     # reason I tried converting from int to NUMPY_INT_TYPE was to see if it would speed things up
 0714:     # because then addition operations don't need to do a potential type conversion; however,
 0715:     # I don't think it made much difference in the end.
 0716:     cdef NUMPY_INT_TYPE SR_index, x_off, y_off, z_off
 0717:     cdef NUMPY_INT_TYPE x_p, y_p, z_p
+0718:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs = np.zeros((26,2,3), dtype=NUMPY_INT_TYPE_PYTHON)
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[1]};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 718, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 718, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_SR_pairs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 718, __pyx_L1_error)
    } else {__pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 0719: 
 0720:     # first set the central x, y and z positions
+0721:     cdef NUMPY_INT_TYPE x = position[0]
  __pyx_t_7 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
+0722:     cdef NUMPY_INT_TYPE y = position[1]
  __pyx_t_7 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
+0723:     cdef NUMPY_INT_TYPE z = position[2]
  __pyx_t_7 = 2;
  __pyx_v_z = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
 0724: 
 0725: 
+0726:     SR_index = 0
  __pyx_v_SR_index = 0;
 0727: 
+0728:     for x_off in xrange(-1,2):
  for (__pyx_t_8 = -1; __pyx_t_8 < 2; __pyx_t_8+=1) {
    __pyx_v_x_off = __pyx_t_8;
+0729:         for y_off in xrange(-1,2):
    for (__pyx_t_9 = -1; __pyx_t_9 < 2; __pyx_t_9+=1) {
      __pyx_v_y_off = __pyx_t_9;
+0730:             for z_off in xrange(-1,2):
      for (__pyx_t_10 = -1; __pyx_t_10 < 2; __pyx_t_10+=1) {
        __pyx_v_z_off = __pyx_t_10;
+0731:                 if x_off == 0 and y_off == 0 and z_off == 0:
        __pyx_t_12 = (__pyx_v_x_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_y_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_z_off == 0);
        __pyx_t_11 = __pyx_t_12;
        __pyx_L10_bool_binop_done:;
        if (__pyx_t_11) {
/* … */
        }
+0732:                     continue
          goto __pyx_L7_continue;
 0733: 
+0734:                 x_p = pbc_hardwall(x + x_off, XDIM)
        __pyx_t_13 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_13 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 734, __pyx_L1_error)
        __pyx_v_x_p = __pyx_t_13;
+0735:                 y_p = pbc_hardwall(y + y_off, YDIM)
        __pyx_t_13 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_13 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 735, __pyx_L1_error)
        __pyx_v_y_p = __pyx_t_13;
+0736:                 z_p = pbc_hardwall(z + z_off, ZDIM)
        __pyx_t_13 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_z + __pyx_v_z_off), __pyx_v_ZDIM); if (unlikely(__pyx_t_13 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 736, __pyx_L1_error)
        __pyx_v_z_p = __pyx_t_13;
 0737: 
+0738:                 if x_p == -1 or y_p == -1 or z_p == -1:
        __pyx_t_12 = (__pyx_v_x_p == -1L);
        if (!__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L14_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_y_p == -1L);
        if (!__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L14_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_z_p == -1L);
        __pyx_t_11 = __pyx_t_12;
        __pyx_L14_bool_binop_done:;
        if (__pyx_t_11) {
/* … */
        }
+0739:                     continue
          goto __pyx_L7_continue;
 0740: 
 0741:                 # if x_off < 0 then the non-central position must come first in the pair
+0742:                 if x_off > 0:
        __pyx_t_11 = (__pyx_v_x_off > 0);
        if (__pyx_t_11) {
/* … */
          goto __pyx_L17;
        }
+0743:                     SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0744:                     SR_pairs[SR_index, 1, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0745:                     SR_pairs[SR_index, 1, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0746: 
+0747:                     SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0748:                     SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0749:                     SR_pairs[SR_index, 0, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0750: 
 0751: 
 0752:                 # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0753:                 elif x_off == 0 and y_off > 0:
        __pyx_t_12 = (__pyx_v_x_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_y_off > 0);
        __pyx_t_11 = __pyx_t_12;
        __pyx_L18_bool_binop_done:;
        if (__pyx_t_11) {
/* … */
          goto __pyx_L17;
        }
+0754:                     SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0755:                     SR_pairs[SR_index, 1, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0756:                     SR_pairs[SR_index, 1, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0757: 
+0758:                     SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0759:                     SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0760:                     SR_pairs[SR_index, 0, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0761: 
 0762:                 # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+0763:                 elif x_off == 0 and y_off == 0 and z_off > 0:
        __pyx_t_12 = (__pyx_v_x_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L20_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_y_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L20_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_z_off > 0);
        __pyx_t_11 = __pyx_t_12;
        __pyx_L20_bool_binop_done:;
        if (__pyx_t_11) {
/* … */
          goto __pyx_L17;
        }
+0764:                     SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0765:                     SR_pairs[SR_index, 1, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0766:                     SR_pairs[SR_index, 1, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0767: 
+0768:                     SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0769:                     SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0770:                     SR_pairs[SR_index, 0, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 0771: 
 0772:                 else:
+0773:                     SR_pairs[SR_index, 0, 0] = x
        /*else*/ {
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0774:                     SR_pairs[SR_index, 0, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+0775:                     SR_pairs[SR_index, 0, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 0776: 
+0777:                     SR_pairs[SR_index, 1, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0778:                     SR_pairs[SR_index, 1, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+0779:                     SR_pairs[SR_index, 1, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
        }
        __pyx_L17:;
 0780: 
+0781:                 SR_index = SR_index+1
        __pyx_v_SR_index = (__pyx_v_SR_index + 1);
        __pyx_L7_continue:;
      }
    }
  }
 0782: 
 0783: 
+0784:     return SR_pairs[0:SR_index]
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyLong_From_npy_int32(__pyx_v_SR_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SR_pairs), __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 0785: 
 0786: 
 0787: ##
 0788: #################################################################################################
 0789: ##
+0790: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_9extract_LR_pairs_from_position_2D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_8extract_LR_pairs_from_position_2D_hardwall, "\n\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_9extract_LR_pairs_from_position_2D_hardwall = {"extract_LR_pairs_from_position_2D_hardwall", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_9extract_LR_pairs_from_position_2D_hardwall, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_8extract_LR_pairs_from_position_2D_hardwall};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_9extract_LR_pairs_from_position_2D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_LR_pairs_from_position_2D_hardwall (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,0};
  PyObject* values[5] = {0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 790, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_LR_pairs_from_position_2D_hardwall", 0) < (0)) __PYX_ERR(0, 790, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_2D_hardwall", 1, 5, 5, i); __PYX_ERR(0, 790, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 5)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 790, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 790, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 790, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 790, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 790, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 792, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_LR_position == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 793, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 794, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 795, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 796, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_2D_hardwall", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 790, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_LR_pairs_from_position_2D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_8extract_LR_pairs_from_position_2D_hardwall(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_8extract_LR_pairs_from_position_2D_hardwall(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, int __pyx_v_XDIM, int __pyx_v_YDIM) {
  int __pyx_v_LR_index;
  int __pyx_v_SLR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  { 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_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_LR_pairs_from_position_2D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_9extract_LR_pairs_from_position_2D_hardwall, 0, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_2, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_2, __pyx_t_4) < (0)) __PYX_ERR(0, 790, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0791: @cython.wraparound(False)
 0792: def extract_LR_pairs_from_position_2D_hardwall(NUMPY_INT_TYPE[:] position,
 0793:                                                int LR_position,
 0794:                                                NUMPY_INT_TYPE[:,:] type_grid,
 0795:                                                int XDIM,
 0796:                                                int YDIM):
 0797: 
 0798:     """
 0799: 
 0800: 
 0801:     """
 0802: 
 0803:     # declare some variables
 0804:     cdef int LR_index, SLR_index, x_off, y_off
 0805:     cdef int x_p, y_p
 0806:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 0807:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 0808: 
 0809:     # first set the central x, y and z positions
+0810:     cdef int x = position[0]
  __pyx_t_1 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+0811:     cdef int y = position[1]
  __pyx_t_1 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
 0812: 
 0813:     # if no long-range interactions required the return empy
 0814:     # array
+0815:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
+0816:         return (np.array([], dtype=NUMPY_INT_TYPE_PYTHON), np.array([], dtype=NUMPY_INT_TYPE_PYTHON))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_t_4};
      __pyx_t_8 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_6, __pyx_t_8, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 816, __pyx_L1_error)
      __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_8);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_8 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_8);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_8, __pyx_t_6};
      __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_9, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 816, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 816, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 816, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_5);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 816, __pyx_L1_error);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
 0817: 
+0818:     elif LR_position == 1:
    break;
    default:
+0819:         LR_pairs = np.zeros((16, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 819, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 819, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 819, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, __pyx_mstate_global->__pyx_tuple[5]};
      __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_2, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 819, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 819, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
        __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 819, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
+0820:         SLR_pairs = np.zeros((24, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_9 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_9);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_9, __pyx_mstate_global->__pyx_tuple[6]};
      __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 820, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 820, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
        }
        __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 820, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
 0821: 
+0822:         LR_index = 0
    __pyx_v_LR_index = 0;
+0823:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 0824: 
 0825:         # loop over long range cube around site
+0826:         for x_off in xrange(-3,4):
    for (__pyx_t_10 = -3; __pyx_t_10 < 4; __pyx_t_10+=1) {
      __pyx_v_x_off = __pyx_t_10;
+0827:             for y_off in xrange(-3,4):
      for (__pyx_t_14 = -3; __pyx_t_14 < 4; __pyx_t_14+=1) {
        __pyx_v_y_off = __pyx_t_14;
+0828:                     x_p = pbc_hardwall(x + x_off, XDIM)
        __pyx_t_15 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_15 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 828, __pyx_L1_error)
        __pyx_v_x_p = __pyx_t_15;
+0829:                     y_p = pbc_hardwall(y + y_off, YDIM)
        __pyx_t_15 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_15 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 829, __pyx_L1_error)
        __pyx_v_y_p = __pyx_t_15;
 0830: 
 0831:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0832:                     # if short range_interaction
+0833:                     if abs(x_off) < 2 and abs(y_off) < 2:
        __pyx_t_17 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 833, __pyx_L1_error)
        __pyx_t_18 = (__pyx_t_17 < 2);
        if (__pyx_t_18) {
        } else {
          __pyx_t_16 = __pyx_t_18;
          goto __pyx_L8_bool_binop_done;
        }
        __pyx_t_17 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 833, __pyx_L1_error)
        __pyx_t_18 = (__pyx_t_17 < 2);
        __pyx_t_16 = __pyx_t_18;
        __pyx_L8_bool_binop_done:;
        if (__pyx_t_16) {
/* … */
        }
+0834:                         continue
          goto __pyx_L5_continue;
 0835: 
 0836:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0837:                     ## Long range interaction
+0838:                     elif abs(x_off) < 3 and abs(y_off) < 3:
        __pyx_t_17 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 838, __pyx_L1_error)
        __pyx_t_18 = (__pyx_t_17 < 3);
        if (__pyx_t_18) {
        } else {
          __pyx_t_16 = __pyx_t_18;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_17 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 838, __pyx_L1_error)
        __pyx_t_18 = (__pyx_t_17 < 3);
        __pyx_t_16 = __pyx_t_18;
        __pyx_L10_bool_binop_done:;
        if (__pyx_t_16) {
/* … */
          goto __pyx_L7;
        }
+0839:                         if x_p == -1 or y_p == -1:
          __pyx_t_18 = (__pyx_v_x_p == -1L);
          if (!__pyx_t_18) {
          } else {
            __pyx_t_16 = __pyx_t_18;
            goto __pyx_L13_bool_binop_done;
          }
          __pyx_t_18 = (__pyx_v_y_p == -1L);
          __pyx_t_16 = __pyx_t_18;
          __pyx_L13_bool_binop_done:;
          if (__pyx_t_16) {
/* … */
          }
+0840:                             continue
            goto __pyx_L5_continue;
+0841:                         if type_grid[x_p, y_p] == 0:
          __pyx_t_1 = __pyx_v_x_p;
          __pyx_t_19 = __pyx_v_y_p;
          __pyx_t_16 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_1 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_19 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_16) {
/* … */
          }
+0842:                             continue
            goto __pyx_L5_continue;
 0843: 
 0844:                         # if x_off < 0 then the non-central position must come first in the pair
+0845:                         if x_off > 0:
          __pyx_t_16 = (__pyx_v_x_off > 0);
          if (__pyx_t_16) {
/* … */
            goto __pyx_L16;
          }
+0846:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_19 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0847:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_19 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 0848: 
+0849:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_19 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0850:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_19 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0851: 
 0852:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0853:                         elif x_off == 0 and y_off > 0:
          __pyx_t_18 = (__pyx_v_x_off == 0);
          if (__pyx_t_18) {
          } else {
            __pyx_t_16 = __pyx_t_18;
            goto __pyx_L17_bool_binop_done;
          }
          __pyx_t_18 = (__pyx_v_y_off > 0);
          __pyx_t_16 = __pyx_t_18;
          __pyx_L17_bool_binop_done:;
          if (__pyx_t_16) {
/* … */
            goto __pyx_L16;
          }
+0854:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_19 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0855:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_19 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 0856: 
+0857:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_19 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0858:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_19 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0859: 
 0860: 
 0861:                         else:
+0862:                             LR_pairs[LR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_19 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+0863:                             LR_pairs[LR_index, 0, 1] = y
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_19 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 0864: 
+0865:                             LR_pairs[LR_index, 1, 0] = x_p
            __pyx_t_19 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0866:                             LR_pairs[LR_index, 1, 1] = y_p
            __pyx_t_20 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_19 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L16:;
 0867: 
+0868:                         LR_index = LR_index+1
          __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 0869: 
 0870:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 0871:                     ## Super long range interaction
 0872:                     else:
+0873:                         if x_p == -1 or y_p == -1:
        /*else*/ {
          __pyx_t_18 = (__pyx_v_x_p == -1L);
          if (!__pyx_t_18) {
          } else {
            __pyx_t_16 = __pyx_t_18;
            goto __pyx_L20_bool_binop_done;
          }
          __pyx_t_18 = (__pyx_v_y_p == -1L);
          __pyx_t_16 = __pyx_t_18;
          __pyx_L20_bool_binop_done:;
          if (__pyx_t_16) {
/* … */
          }
+0874:                             continue
            goto __pyx_L5_continue;
+0875:                         if type_grid[x_p, y_p] == 0:
          __pyx_t_19 = __pyx_v_x_p;
          __pyx_t_1 = __pyx_v_y_p;
          __pyx_t_16 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_19 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_1 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_16) {
/* … */
          }
+0876:                             continue
            goto __pyx_L5_continue;
 0877: 
 0878:                         # if x_off < 0 then the non-central position must come first in the pair
+0879:                         if x_off > 0:
          __pyx_t_16 = (__pyx_v_x_off > 0);
          if (__pyx_t_16) {
/* … */
            goto __pyx_L23;
          }
+0880:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_19 = 1;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0881:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_20 = __pyx_v_SLR_index;
            __pyx_t_19 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 0882: 
+0883:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_19 = 0;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0884:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_20 = __pyx_v_SLR_index;
            __pyx_t_19 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0885: 
 0886:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0887:                         elif x_off == 0 and y_off > 0:
          __pyx_t_18 = (__pyx_v_x_off == 0);
          if (__pyx_t_18) {
          } else {
            __pyx_t_16 = __pyx_t_18;
            goto __pyx_L24_bool_binop_done;
          }
          __pyx_t_18 = (__pyx_v_y_off > 0);
          __pyx_t_16 = __pyx_t_18;
          __pyx_L24_bool_binop_done:;
          if (__pyx_t_16) {
/* … */
            goto __pyx_L23;
          }
+0888:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_19 = 1;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0889:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_20 = __pyx_v_SLR_index;
            __pyx_t_19 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 0890: 
+0891:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_19 = 0;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0892:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_20 = __pyx_v_SLR_index;
            __pyx_t_19 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0893: 
 0894: 
 0895:                         else:
+0896:                             SLR_pairs[SLR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_19 = 0;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+0897:                             SLR_pairs[SLR_index, 0, 1] = y
            __pyx_t_20 = __pyx_v_SLR_index;
            __pyx_t_19 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 0898: 
+0899:                             SLR_pairs[SLR_index, 1, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_19 = 1;
            __pyx_t_20 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0900:                             SLR_pairs[SLR_index, 1, 1] = y_p
            __pyx_t_20 = __pyx_v_SLR_index;
            __pyx_t_19 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L23:;
 0901: 
+0902:                         SLR_index = SLR_index+1
          __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
        }
        __pyx_L7:;
        __pyx_L5_continue:;
      }
    }
 0903: 
 0904: 
+0905:         return (LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_LR_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_SLR_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 905, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 905, __pyx_L1_error);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
 0906: 
 0907:     else:
+0908:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 908, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 908, __pyx_L1_error)
    break;
  }
 0909: 
 0910: ##
 0911: #################################################################################################
 0912: ##
+0913: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_11extract_SR_pairs_from_position_2D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_10extract_SR_pairs_from_position_2D_hardwall, "\n    Returns the non-redundant set of pairs associated with the 2D position defined\n    by the position array and all possible short-range interaction sites. Returned\n    positions are sorted with the largest chain location first, where 'largest'\n    is defined as comparing x and x and then y and y. \n    \n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_11extract_SR_pairs_from_position_2D_hardwall = {"extract_SR_pairs_from_position_2D_hardwall", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_11extract_SR_pairs_from_position_2D_hardwall, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_10extract_SR_pairs_from_position_2D_hardwall};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_11extract_SR_pairs_from_position_2D_hardwall(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_SR_pairs_from_position_2D_hardwall (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,0};
  PyObject* values[3] = {0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 913, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 913, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 913, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 913, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_pairs_from_position_2D_hardwall", 0) < (0)) __PYX_ERR(0, 913, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_2D_hardwall", 1, 3, 3, i); __PYX_ERR(0, 913, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 913, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 913, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 913, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 915, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 916, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 917, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_2D_hardwall", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 913, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_pairs_from_position_2D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_10extract_SR_pairs_from_position_2D_hardwall(__pyx_self, __pyx_v_position, __pyx_v_XDIM, __pyx_v_YDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_10extract_SR_pairs_from_position_2D_hardwall(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_XDIM, int __pyx_v_YDIM) {
  int __pyx_v_SR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
/* … */
  /* 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_6);
  { 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_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.extract_SR_pairs_from_position_2D_hardwall", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_11extract_SR_pairs_from_position_2D_hardwall, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_2, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_2, __pyx_t_4) < (0)) __PYX_ERR(0, 913, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0914: @cython.wraparound(False)
 0915: def extract_SR_pairs_from_position_2D_hardwall(NUMPY_INT_TYPE[:] position,
 0916:                                                int XDIM,
 0917:                                                int YDIM):
 0918:     """
 0919:     Returns the non-redundant set of pairs associated with the 2D position defined
 0920:     by the position array and all possible short-range interaction sites. Returned
 0921:     positions are sorted with the largest chain location first, where 'largest'
 0922:     is defined as comparing x and x and then y and y.
 0923: 
 0924:     """
 0925: 
 0926:     # declare some variables
 0927:     cdef int SR_index, x_off, y_off
 0928:     cdef int x_p, y_p
+0929:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs = np.zeros((8,2,2), dtype=NUMPY_INT_TYPE_PYTHON)
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[4]};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 929, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 929, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 929, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 929, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_SR_pairs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 929, __pyx_L1_error)
    } else {__pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 0930: 
 0931:     # first set the central x, y and z positions
+0932:     cdef int x = position[0]
  __pyx_t_7 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
+0933:     cdef int y = position[1]
  __pyx_t_7 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
 0934: 
+0935:     SR_index = 0
  __pyx_v_SR_index = 0;
+0936:     for x_off in xrange(-1,2):
  for (__pyx_t_8 = -1; __pyx_t_8 < 2; __pyx_t_8+=1) {
    __pyx_v_x_off = __pyx_t_8;
+0937:         for y_off in xrange(-1,2):
    for (__pyx_t_9 = -1; __pyx_t_9 < 2; __pyx_t_9+=1) {
      __pyx_v_y_off = __pyx_t_9;
+0938:             if x_off == 0 and y_off == 0:
      __pyx_t_11 = (__pyx_v_x_off == 0);
      if (__pyx_t_11) {
      } else {
        __pyx_t_10 = __pyx_t_11;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_11 = (__pyx_v_y_off == 0);
      __pyx_t_10 = __pyx_t_11;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_10) {
/* … */
      }
+0939:                 continue
        goto __pyx_L5_continue;
 0940: 
+0941:             x_p = pbc_hardwall(x + x_off, XDIM)
      __pyx_t_12 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_12 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L1_error)
      __pyx_v_x_p = __pyx_t_12;
+0942:             y_p = pbc_hardwall(y + y_off, YDIM)
      __pyx_t_12 = __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_12 == ((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE)-1) && PyErr_Occurred())) __PYX_ERR(0, 942, __pyx_L1_error)
      __pyx_v_y_p = __pyx_t_12;
 0943: 
+0944:             if x_p == -1 or y_p == -1:
      __pyx_t_11 = (__pyx_v_x_p == -1L);
      if (!__pyx_t_11) {
      } else {
        __pyx_t_10 = __pyx_t_11;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_11 = (__pyx_v_y_p == -1L);
      __pyx_t_10 = __pyx_t_11;
      __pyx_L11_bool_binop_done:;
      if (__pyx_t_10) {
/* … */
      }
+0945:                 continue
        goto __pyx_L5_continue;
 0946: 
 0947:             # if x_off < 0 then the non-central position must come first in the pair
+0948:             if x_off > 0:
      __pyx_t_10 = (__pyx_v_x_off > 0);
      if (__pyx_t_10) {
/* … */
        goto __pyx_L13;
      }
+0949:                 SR_pairs[SR_index, 1, 0] = x
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0950:                 SR_pairs[SR_index, 1, 1] = y
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 0951: 
+0952:                 SR_pairs[SR_index, 0, 0] = x_p
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0953:                 SR_pairs[SR_index, 0, 1] = y_p
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0954: 
 0955: 
 0956:             # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+0957:             elif x_off == 0 and y_off > 0:
      __pyx_t_11 = (__pyx_v_x_off == 0);
      if (__pyx_t_11) {
      } else {
        __pyx_t_10 = __pyx_t_11;
        goto __pyx_L14_bool_binop_done;
      }
      __pyx_t_11 = (__pyx_v_y_off > 0);
      __pyx_t_10 = __pyx_t_11;
      __pyx_L14_bool_binop_done:;
      if (__pyx_t_10) {
/* … */
        goto __pyx_L13;
      }
+0958:                 SR_pairs[SR_index, 1, 0] = x
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0959:                 SR_pairs[SR_index, 1, 1] = y
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 0960: 
+0961:                 SR_pairs[SR_index, 0, 0] = x_p
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0962:                 SR_pairs[SR_index, 0, 1] = y_p
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 0963: 
 0964:             else:
+0965:                 SR_pairs[SR_index, 0, 0] = x
      /*else*/ {
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+0966:                 SR_pairs[SR_index, 0, 1] = y
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 0967: 
+0968:                 SR_pairs[SR_index, 1, 0] = x_p
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+0969:                 SR_pairs[SR_index, 1, 1] = y_p
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
      }
      __pyx_L13:;
 0970: 
+0971:             SR_index = SR_index+1
      __pyx_v_SR_index = (__pyx_v_SR_index + 1);
      __pyx_L5_continue:;
    }
  }
 0972: 
+0973:     return SR_pairs[0:SR_index]
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_SR_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 973, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 973, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SR_pairs), __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 973, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 0974: 
 0975: 
 0976: 
+0977: @cython.boundscheck(False)  # Deactivate bounds checking for performance
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_13delete_pbc_pairs(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_12delete_pbc_pairs, "\n    Postprocessing function that takes a list of residue pairs in format:\n    [id, pair_id, dimension] = position\n\n    where \n    id indexes into the list\n    pair_id is 1 or 0 (each pair contains two separate poistions)\n    dimension is the relevant dimenion (0=X,1=Y,2=Z)\n\n    This function systematically goes through the list in this format and deletes pairs\n    where the position was -1 (as this means the pair was crossing a periodic boundary).\n\n    Effectively, this trims a list of positions removing any pairs that straddle the PBC.\n\n    Parameters\n    ----------\n    pairs_list : cnp.ndarray[NUMPY_INT_TYPE, ndim=3]\n        The list of pairs to be trimmed\n\n    ndims : int\n        The number of dimensions in the system (2 or 3)\n\n    Returns\n    -------\n    cnp.ndarray[NUMPY_INT_TYPE, ndim=3]\n        The trimmed list of pairs\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_13delete_pbc_pairs = {"delete_pbc_pairs", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_13delete_pbc_pairs, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_12delete_pbc_pairs};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_13delete_pbc_pairs(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyArrayObject *__pyx_v_pairs_list = 0;
  PyObject *__pyx_v_ndims = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("delete_pbc_pairs (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pairs_list,&__pyx_mstate_global->__pyx_n_u_ndims,0};
  PyObject* values[2] = {0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 977, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 977, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 977, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "delete_pbc_pairs", 0) < (0)) __PYX_ERR(0, 977, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("delete_pbc_pairs", 1, 2, 2, i); __PYX_ERR(0, 977, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 977, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 977, __pyx_L3_error)
    }
    __pyx_v_pairs_list = ((PyArrayObject *)values[0]);
    __pyx_v_ndims = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("delete_pbc_pairs", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 977, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.delete_pbc_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pairs_list), __pyx_mstate_global->__pyx_ptype_5numpy_ndarray, 1, "pairs_list", 0))) __PYX_ERR(0, 979, __pyx_L1_error)
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_12delete_pbc_pairs(__pyx_self, __pyx_v_pairs_list, __pyx_v_ndims);
  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;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_12delete_pbc_pairs(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_pairs_list, PyObject *__pyx_v_ndims) {
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_minus_one;
  int __pyx_v_n_pairs;
  int __pyx_v_idx;
  PyArrayObject *__pyx_v_pairs_to_delete = 0;
  int __pyx_v_delete_count;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_pairs_list;
  __Pyx_Buffer __pyx_pybuffer_pairs_list;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_pairs_to_delete;
  __Pyx_Buffer __pyx_pybuffer_pairs_to_delete;
  PyObject *__pyx_r = NULL;
  __Pyx_INCREF((PyObject *)__pyx_v_pairs_list);
  __pyx_pybuffer_pairs_to_delete.pybuffer.buf = NULL;
  __pyx_pybuffer_pairs_to_delete.refcount = 0;
  __pyx_pybuffernd_pairs_to_delete.data = NULL;
  __pyx_pybuffernd_pairs_to_delete.rcbuffer = &__pyx_pybuffer_pairs_to_delete;
  __pyx_pybuffer_pairs_list.pybuffer.buf = NULL;
  __pyx_pybuffer_pairs_list.refcount = 0;
  __pyx_pybuffernd_pairs_list.data = NULL;
  __pyx_pybuffernd_pairs_list.rcbuffer = &__pyx_pybuffer_pairs_list;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pairs_list.rcbuffer->pybuffer, (PyObject*)__pyx_v_pairs_list, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 977, __pyx_L1_error)
  }
  __pyx_pybuffernd_pairs_list.diminfo[0].strides = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pairs_list.diminfo[0].shape = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pairs_list.diminfo[1].strides = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pairs_list.diminfo[1].shape = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_pairs_list.diminfo[2].strides = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_pairs_list.diminfo[2].shape = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.shape[2];
/* … */
  /* 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_7);
  { 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_pairs_list.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.delete_pbc_pairs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pairs_list.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_pairs_to_delete);
  __Pyx_XDECREF((PyObject *)__pyx_v_pairs_list);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_13delete_pbc_pairs, 0, __pyx_mstate_global->__pyx_n_u_delete_pbc_pairs, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_delete_pbc_pairs, __pyx_t_4) < (0)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 0978: @cython.wraparound(False)   # Deactivate negative indexing
 0979: def delete_pbc_pairs(cnp.ndarray[NUMPY_INT_TYPE, ndim=3] pairs_list, ndims):
 0980:     """
 0981:     Postprocessing function that takes a list of residue pairs in format:
 0982:     [id, pair_id, dimension] = position
 0983: 
 0984:     where
 0985:     id indexes into the list
 0986:     pair_id is 1 or 0 (each pair contains two separate poistions)
 0987:     dimension is the relevant dimenion (0=X,1=Y,2=Z)
 0988: 
 0989:     This function systematically goes through the list in this format and deletes pairs
 0990:     where the position was -1 (as this means the pair was crossing a periodic boundary).
 0991: 
 0992:     Effectively, this trims a list of positions removing any pairs that straddle the PBC.
 0993: 
 0994:     Parameters
 0995:     ----------
 0996:     pairs_list : cnp.ndarray[NUMPY_INT_TYPE, ndim=3]
 0997:         The list of pairs to be trimmed
 0998: 
 0999:     ndims : int
 1000:         The number of dimensions in the system (2 or 3)
 1001: 
 1002:     Returns
 1003:     -------
 1004:     cnp.ndarray[NUMPY_INT_TYPE, ndim=3]
 1005:         The trimmed list of pairs
 1006: 
 1007:     """
 1008: 
+1009:     cdef NUMPY_INT_TYPE minus_one = -1
  __pyx_v_minus_one = -1;
+1010:     cdef int n_pairs = pairs_list.shape[0]
  __pyx_v_n_pairs = (__pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_pairs_list))[0]);
+1011:     cdef int idx = 0
  __pyx_v_idx = 0;
 1012: 
+1013:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=1] pairs_to_delete = np.empty(n_pairs, dtype=NUMPY_INT_TYPE_PYTHON)
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_n_pairs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_t_3};
    __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1013, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_5, __pyx_t_7, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1013, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1013, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 1013, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_pairs_to_delete = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 1013, __pyx_L1_error)
    } else {__pyx_pybuffernd_pairs_to_delete.diminfo[0].strides = __pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pairs_to_delete.diminfo[0].shape = __pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_v_pairs_to_delete = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+1014:     cdef int delete_count = 0
  __pyx_v_delete_count = 0;
 1015: 
 1016: 
 1017:     # if we are in two dimensions
+1018:     if ndims == 2:
  __pyx_t_8 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_ndims, __pyx_mstate_global->__pyx_int_2, 2, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1018, __pyx_L1_error)
  if (__pyx_t_8) {
/* … */
    goto __pyx_L3;
  }
 1019: 
 1020:         # dynamically resize pairs_list. We are looping over a numpy array and changing its size. This means that rather than
 1021:         # simply looping over each position we need to loop until the idx (which is only incremented if no deletion occurs)
 1022:         # matches the array length.
+1023:         for idx in range(n_pairs):
    __pyx_t_9 = __pyx_v_n_pairs;
    __pyx_t_10 = __pyx_t_9;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
      __pyx_v_idx = __pyx_t_11;
 1024: 
 1025:             # if we find pbc crossing delete (so list gets shorter)
+1026:             if (pairs_list[idx,0,0] == minus_one) or \
      __pyx_t_12 = __pyx_v_idx;
      __pyx_t_13 = 0;
      __pyx_t_14 = 0;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L7_bool_binop_done;
      }
/* … */
      if (__pyx_t_8) {
/* … */
      }
    }
+1027:                (pairs_list[idx,1,0] == minus_one) or \
      __pyx_t_14 = __pyx_v_idx;
      __pyx_t_13 = 1;
      __pyx_t_12 = 0;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L7_bool_binop_done;
      }
+1028:                (pairs_list[idx,0,1] == minus_one) or \
      __pyx_t_12 = __pyx_v_idx;
      __pyx_t_13 = 0;
      __pyx_t_14 = 1;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L7_bool_binop_done;
      }
+1029:                (pairs_list[idx,1,1] == minus_one):
      __pyx_t_14 = __pyx_v_idx;
      __pyx_t_13 = 1;
      __pyx_t_12 = 1;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      __pyx_t_8 = __pyx_t_15;
      __pyx_L7_bool_binop_done:;
 1030:                 #pairs_list = np.delete(pairs_list, idx, 0)
+1031:                 pairs_to_delete[delete_count] = idx
        __pyx_t_12 = __pyx_v_delete_count;
        *__Pyx_BufPtrStrided1d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_pairs_to_delete.diminfo[0].strides) = __pyx_v_idx;
+1032:                 delete_count = delete_count + 1
        __pyx_v_delete_count = (__pyx_v_delete_count + 1);
 1033: 
 1034:     # same for three dimensions
 1035:     else:
 1036: 
+1037:         for idx in range(n_pairs):
  /*else*/ {
    __pyx_t_9 = __pyx_v_n_pairs;
    __pyx_t_10 = __pyx_t_9;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
      __pyx_v_idx = __pyx_t_11;
 1038: 
 1039:             # if we find pbc crossing delete (so list gets shorter)
+1040:             if (pairs_list[idx,0,0] == minus_one) or \
      __pyx_t_12 = __pyx_v_idx;
      __pyx_t_13 = 0;
      __pyx_t_14 = 0;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L14_bool_binop_done;
      }
/* … */
      if (__pyx_t_8) {
/* … */
      }
    }
  }
  __pyx_L3:;
+1041:                (pairs_list[idx,1,0] == minus_one) or \
      __pyx_t_14 = __pyx_v_idx;
      __pyx_t_13 = 1;
      __pyx_t_12 = 0;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L14_bool_binop_done;
      }
+1042:                (pairs_list[idx,0,1] == minus_one) or \
      __pyx_t_12 = __pyx_v_idx;
      __pyx_t_13 = 0;
      __pyx_t_14 = 1;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L14_bool_binop_done;
      }
+1043:                (pairs_list[idx,1,1] == minus_one) or \
      __pyx_t_14 = __pyx_v_idx;
      __pyx_t_13 = 1;
      __pyx_t_12 = 1;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L14_bool_binop_done;
      }
+1044:                (pairs_list[idx,0,2] == minus_one) or \
      __pyx_t_12 = __pyx_v_idx;
      __pyx_t_13 = 0;
      __pyx_t_14 = 2;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_8 = __pyx_t_15;
        goto __pyx_L14_bool_binop_done;
      }
+1045:                (pairs_list[idx,1,2] == minus_one):
      __pyx_t_14 = __pyx_v_idx;
      __pyx_t_13 = 1;
      __pyx_t_12 = 2;
      __pyx_t_15 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_pairs_list.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_pairs_list.diminfo[1].strides, __pyx_t_12, __pyx_pybuffernd_pairs_list.diminfo[2].strides)) == __pyx_v_minus_one);
      __pyx_t_8 = __pyx_t_15;
      __pyx_L14_bool_binop_done:;
 1046: 
+1047:                 pairs_to_delete[delete_count] = idx
        __pyx_t_12 = __pyx_v_delete_count;
        *__Pyx_BufPtrStrided1d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_pairs_to_delete.diminfo[0].strides) = __pyx_v_idx;
+1048:                 delete_count = delete_count + 1
        __pyx_v_delete_count = (__pyx_v_delete_count + 1);
 1049: 
 1050:     # resize the pairs_to_delete array to the correct size
+1051:     pairs_to_delete = pairs_to_delete[:delete_count]
  __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_delete_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PySlice_New(Py_None, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_pairs_to_delete), __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 1051, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer, (PyObject*)__pyx_v_pairs_to_delete, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
      __pyx_t_16 = __pyx_t_17 = __pyx_t_18 = 0;
    }
    __pyx_pybuffernd_pairs_to_delete.diminfo[0].strides = __pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pairs_to_delete.diminfo[0].shape = __pyx_pybuffernd_pairs_to_delete.rcbuffer->pybuffer.shape[0];
    if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1051, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_pairs_to_delete, ((PyArrayObject *)__pyx_t_1));
  __pyx_t_1 = 0;
 1052: 
 1053:     # finally run delete on those pairs. NOTE this returns a
 1054:     # new array so new memory is allocated. This is not ideal
 1055:     # but I can't see a way around it.
+1056:     pairs_list = np.delete(pairs_list, pairs_to_delete, axis=0)
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_delete); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, ((PyObject *)__pyx_v_pairs_list), ((PyObject *)__pyx_v_pairs_to_delete)};
    __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_axis, __pyx_mstate_global->__pyx_int_0, __pyx_t_7, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 1056, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pairs_list.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pairs_list.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pairs_list.rcbuffer->pybuffer, (PyObject*)__pyx_v_pairs_list, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
      __pyx_t_18 = __pyx_t_17 = __pyx_t_16 = 0;
    }
    __pyx_pybuffernd_pairs_list.diminfo[0].strides = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pairs_list.diminfo[0].shape = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pairs_list.diminfo[1].strides = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pairs_list.diminfo[1].shape = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_pairs_list.diminfo[2].strides = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_pairs_list.diminfo[2].shape = __pyx_pybuffernd_pairs_list.rcbuffer->pybuffer.shape[2];
    if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1056, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_pairs_list, ((PyArrayObject *)__pyx_t_1));
  __pyx_t_1 = 0;
 1057: 
+1058:     return pairs_list
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF((PyObject *)__pyx_v_pairs_list);
  __pyx_r = ((PyObject *)__pyx_v_pairs_list);
  goto __pyx_L0;
 1059: 
 1060: 
 1061: 
 1062: ##
 1063: ## OLD IMPLEMENTATION KEPT FOR NOW IN CASE WE NEED TO REVERT.
 1064: ## THIS IS MUCH MUCH SLOWER THAN THE NEW IMPLEMENTATION ABOVE.
 1065: ##
+1066: def delete_pbc_pairs_OLD(pairs_list, ndims):
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_15delete_pbc_pairs_OLD(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_5pimms_20inner_loops_hardwall_14delete_pbc_pairs_OLD, "\n    Postprocessing function that takes a list of residue pairs in format:\n    [id, pair_id, dimension] = position\n\n    where \n    id indexes into the list\n    pair_id is 1 or 0 (each pair contains two separate poistions)\n    dimension is the relevant dimenion (0=X,1=Y,2=Z)\n\n    This function systematically goes through the list in this format and deletes pairs\n    where the position was -1 (as this means the pair was crossing a periodic boundary).\n\n    Effectively, this trims a list of positions removing any pairs that straddle the PBC.\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_20inner_loops_hardwall_15delete_pbc_pairs_OLD = {"delete_pbc_pairs_OLD", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_20inner_loops_hardwall_15delete_pbc_pairs_OLD, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_20inner_loops_hardwall_14delete_pbc_pairs_OLD};
static PyObject *__pyx_pw_5pimms_20inner_loops_hardwall_15delete_pbc_pairs_OLD(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_pairs_list = 0;
  PyObject *__pyx_v_ndims = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("delete_pbc_pairs_OLD (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pairs_list,&__pyx_mstate_global->__pyx_n_u_ndims,0};
  PyObject* values[2] = {0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1066, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1066, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1066, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "delete_pbc_pairs_OLD", 0) < (0)) __PYX_ERR(0, 1066, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("delete_pbc_pairs_OLD", 1, 2, 2, i); __PYX_ERR(0, 1066, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1066, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1066, __pyx_L3_error)
    }
    __pyx_v_pairs_list = values[0];
    __pyx_v_ndims = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("delete_pbc_pairs_OLD", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1066, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.delete_pbc_pairs_OLD", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_20inner_loops_hardwall_14delete_pbc_pairs_OLD(__pyx_self, __pyx_v_pairs_list, __pyx_v_ndims);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5pimms_20inner_loops_hardwall_14delete_pbc_pairs_OLD(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pairs_list, PyObject *__pyx_v_ndims) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_n_pairs;
  PyObject *__pyx_v_idx = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_pairs_to_delete = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_INCREF(__pyx_v_pairs_list);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pimms.inner_loops_hardwall.delete_pbc_pairs_OLD", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_pairs_to_delete);
  __Pyx_XDECREF(__pyx_v_pairs_list);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_20inner_loops_hardwall_15delete_pbc_pairs_OLD, 0, __pyx_mstate_global->__pyx_n_u_delete_pbc_pairs_OLD, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops_hardwall, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_delete_pbc_pairs_OLD, __pyx_t_4) < (0)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1067:     """
 1068:     Postprocessing function that takes a list of residue pairs in format:
 1069:     [id, pair_id, dimension] = position
 1070: 
 1071:     where
 1072:     id indexes into the list
 1073:     pair_id is 1 or 0 (each pair contains two separate poistions)
 1074:     dimension is the relevant dimenion (0=X,1=Y,2=Z)
 1075: 
 1076:     This function systematically goes through the list in this format and deletes pairs
 1077:     where the position was -1 (as this means the pair was crossing a periodic boundary).
 1078: 
 1079:     Effectively, this trims a list of positions removing any pairs that straddle the PBC.
 1080: 
 1081:     """
+1082:     n_pairs = len(pairs_list)
  __pyx_t_1 = PyObject_Length(__pyx_v_pairs_list); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1082, __pyx_L1_error)
  __pyx_v_n_pairs = __pyx_t_1;
+1083:     idx = 0
  __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
  __pyx_v_idx = __pyx_mstate_global->__pyx_int_0;
 1084: 
+1085:     pairs_to_delete = []
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_pairs_to_delete = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
+1086:     if ndims == 2:
  __pyx_t_3 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_ndims, __pyx_mstate_global->__pyx_int_2, 2, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1086, __pyx_L1_error)
  if (__pyx_t_3) {
/* … */
    goto __pyx_L3;
  }
 1087: 
 1088:         # dynamically resize pairs_list. We are looping over a numpy array and changing its size. This means that rather than
 1089:         # simply looping over each position we need to loop until the idx (which is only incremented if no deletion occurs)
 1090:         # matches the array length.
+1091:         while True:
    while (1) {
+1092:             if idx == len(pairs_list)-1:
      __pyx_t_1 = PyObject_Length(__pyx_v_pairs_list); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1092, __pyx_L1_error)
      __pyx_t_2 = PyLong_FromSsize_t((__pyx_t_1 - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1092, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_idx, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1092, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1092, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_3) {
/* … */
      }
+1093:                 return pairs_list
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_pairs_list);
        __pyx_r = __pyx_v_pairs_list;
        goto __pyx_L0;
 1094: 
 1095:             # if we find pbc crossing delete (so list gets shorter)
+1096:             if (pairs_list[idx,0,0] == -1) or (pairs_list[idx,1,0] == -1) or (pairs_list[idx,0,1] == -1) or (pairs_list[idx,1,1] == -1):
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1096, __pyx_L1_error);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1096, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_3 = __pyx_t_5;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_3) {
/* … */
        goto __pyx_L7;
      }
+1097:                 pairs_list = np.delete(pairs_list, idx, 0)
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1097, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_delete); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1097, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_v_pairs_list, __pyx_v_idx, __pyx_mstate_global->__pyx_int_0};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1097, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF_SET(__pyx_v_pairs_list, __pyx_t_4);
        __pyx_t_4 = 0;
 1098: 
 1099:             # else increment gets bigger
 1100:             else:
+1101:                 idx=idx+1
      /*else*/ {
        __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_v_idx, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v_idx, __pyx_t_4);
        __pyx_t_4 = 0;
      }
      __pyx_L7:;
    }
 1102: 
 1103:     # same for three dimensions
 1104:     else:
 1105: 
 1106:         # dynamically resize pairs_list (see 2D implementation for brief discussion of this)
+1107:         while True:
  /*else*/ {
    while (1) {
+1108:             if idx == len(pairs_list)-1:
      __pyx_t_1 = PyObject_Length(__pyx_v_pairs_list); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1108, __pyx_L1_error)
      __pyx_t_4 = PyLong_FromSsize_t((__pyx_t_1 - 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_idx, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1108, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1108, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_3) {
/* … */
      }
+1109:                 return pairs_list
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_pairs_list);
        __pyx_r = __pyx_v_pairs_list;
        goto __pyx_L0;
 1110: 
 1111:             # if we find pbc crossing delete (so list gets shorter)
+1112:             if (pairs_list[idx,0,0] == -1) or (pairs_list[idx,1,0] == -1) or (pairs_list[idx,0,1] == -1) or (pairs_list[idx,1,1] == -1) or (pairs_list[idx,0,2] == -1) or (pairs_list[idx,1,2] == -1):
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_7, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_7, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_mstate_global->__pyx_int_0) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_2);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_2);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_mstate_global->__pyx_int_2) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_3 = __pyx_t_5;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_idx);
      __Pyx_GIVEREF(__pyx_v_idx);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_idx) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_2);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_2);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_mstate_global->__pyx_int_2) != (0)) __PYX_ERR(0, 1112, __pyx_L1_error);
      __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_pairs_list, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_7, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_3 = __pyx_t_5;
      __pyx_L16_bool_binop_done:;
      if (__pyx_t_3) {
/* … */
        goto __pyx_L15;
      }
+1113:                 pairs_list = np.delete(pairs_list, idx, 0)
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1113, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_delete); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1113, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_v_pairs_list, __pyx_v_idx, __pyx_mstate_global->__pyx_int_0};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1113, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF_SET(__pyx_v_pairs_list, __pyx_t_7);
        __pyx_t_7 = 0;
 1114: 
 1115:             # else increment gets bigger
 1116:             else:
+1117:                 idx=idx+1
      /*else*/ {
        __pyx_t_7 = __Pyx_PyLong_AddObjC(__pyx_v_idx, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1117, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF_SET(__pyx_v_idx, __pyx_t_7);
        __pyx_t_7 = 0;
      }
      __pyx_L15:;
    }
  }
  __pyx_L3:;
 1118: 
+1119:     return pairs_list
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_pairs_list);
  __pyx_r = __pyx_v_pairs_list;
  goto __pyx_L0;
 1120: 
 1121: 
+1122: @cython.cdivision(True)
static __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_f_5pimms_20inner_loops_hardwall_pbc_hardwall(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_value, __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_v_DIM) {
  __pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE __pyx_r;
 1123: cdef NUMPY_INT_TYPE pbc_hardwall(NUMPY_INT_TYPE value, NUMPY_INT_TYPE DIM):
 1124:     """
 1125:     Takes an offset position (value) and the max dimensions in that axis (DIM) and if
 1126:     this new position is outside the lattice returns -1 (i.e. this is one part of a pair
 1127:     that will straddle the periodic boundary)
 1128:     """
 1129: 
+1130:     if (value < 0) or value > (DIM-1):
  __pyx_t_2 = (__pyx_v_value < 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_value > (__pyx_v_DIM - 1));
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {
/* … */
  }
+1131:         return -1
    __pyx_r = -1;
    goto __pyx_L0;
 1132:     else:
+1133:         return value
  /*else*/ {
    __pyx_r = __pyx_v_value;
    goto __pyx_L0;
  }