Generated by Cython 0.29.23

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

+001: # -*- coding: utf-8 -*-
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_convert_adac_forte_line_65, __pyx_kp_u_Convert_an_ADAC_Forte_list_mode) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 002: 
 003: 
 004: #    pept is a Python library that unifies Positron Emission Particle
 005: #    Tracking (PEPT) research, including tracking, simulation, data analysis
 006: #    and visualisation tools.
 007: #
 008: #    If you used this codebase or any software making use of it in a scientific
 009: #    publication, we ask you to cite the following paper:
 010: #        Nicuşan AL, Windows-Yule CR. Positron emission particle tracking
 011: #        using machine learning. Review of Scientific Instruments.
 012: #        2020 Jan 1;91(1):013329.
 013: #        https://doi.org/10.1063/1.5129251
 014: #
 015: #    Copyright (C) 2021 the pept developers.
 016: #
 017: #    This program is free software: you can redistribute it and/or modify
 018: #    it under the terms of the GNU General Public License as published by
 019: #    the Free Software Foundation, either version 3 of the License, or
 020: #    (at your option) any later version.
 021: #
 022: #    This program is distributed in the hope that it will be useful,
 023: #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 024: #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 025: #    GNU General Public License for more details.
 026: #
 027: #    You should have received a copy of the GNU General Public License
 028: #    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 029: #    pept is a Python library that unifies Positron Emission Particle
 030: #    Tracking (PEPT) research, including tracking, simulation, data analysis
 031: #    and visualisation tools
 032: 
 033: 
 034: # File              : binary_converter.pyx
 035: # License           : GNU v3.0
 036: # Author            : Andrei Leonard Nicusan <a.l.nicusan@bham.ac.uk>
 037: # Date              : 01.04.2021
 038: 
 039: 
 040: # cython: language_level=3
 041: # cython: boundscheck=False
 042: # cython: wraparound=False
 043: # cython: initializedcheck=False
 044: # cython: nonecheck=False
 045: # cython: embedsignature=True
 046: # cython: cdivision=True
 047: 
 048: 
+049: import numpy as np      # import numpy for Python functions
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 050: cimport numpy as np     # import numpy for C functions (numpy's C API)
 051: 
 052: 
+053: np.import_array()
  __pyx_t_2 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 53, __pyx_L1_error)
 054: 
 055: 
 056: cdef extern from "binary_converter_ext.c":
 057:     # C is included here so that it doesn't need to be compiled externally
 058:     pass
 059: 
 060: 
 061: cdef extern from "binary_converter_ext.h":
 062:     double* read_adac_binary(const char *, Py_ssize_t *) nogil
 063: 
 064: 
+065: cpdef convert_adac_forte(filepath):
static PyObject *__pyx_pw_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_1convert_adac_forte(PyObject *__pyx_self, PyObject *__pyx_v_filepath); /*proto*/
static PyObject *__pyx_f_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_convert_adac_forte(PyObject *__pyx_v_filepath, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_filepath_utf = NULL;
  char *__pyx_v_filepath_c;
  double *__pyx_v_lors;
  Py_ssize_t __pyx_v_lors_elements;
  npy_intp __pyx_v_shape[2];
  PyArrayObject *__pyx_v_lors_arr = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_lors_arr;
  __Pyx_Buffer __pyx_pybuffer_lors_arr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_adac_forte", 0);
  __pyx_pybuffer_lors_arr.pybuffer.buf = NULL;
  __pyx_pybuffer_lors_arr.refcount = 0;
  __pyx_pybuffernd_lors_arr.data = NULL;
  __pyx_pybuffernd_lors_arr.rcbuffer = &__pyx_pybuffer_lors_arr;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __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_lors_arr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pept.scanners.parallel_screens.extensions.binary_converter.convert_adac_forte", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lors_arr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_filepath_utf);
  __Pyx_XDECREF((PyObject *)__pyx_v_lors_arr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_1convert_adac_forte(PyObject *__pyx_self, PyObject *__pyx_v_filepath); /*proto*/
static char __pyx_doc_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_convert_adac_forte[] = "convert_adac_forte(filepath)\nConvert an ADAC Forte list mode binary file to a general line data\n    format `[time, x1, y1, z1, x2, y2, z2]`, returned as a NumPy array.\n\n    ::\n\n        Function signature:\n            binary_converter(filepath)\n\n    Binary converter for the ADAC Forte dual-head gamma camera native list\n    mode data. Given the `filepath` to such a binary file (usually with\n    extension \".da01\"), this function converts the binary contents to the\n    general line of response format `[time, x1, y1, z1, x2, y2, z2]`, where\n    `z1 = 0` and `z2 = screen_separation` (found from the file).\n\n    The LoRs are returned as a (N, 7) NumPy array, where N is the number of\n    LoRs that were found in the file.\n\n    Function parameters\n    -------------------\n    filepath: str-like\n        A string of characters containing the path to the binary file. The\n        string's contents are not read in - it will only be used with the\n        `fopen` function, so it can contain any characters allowed by the OS\n        file system.\n\n    Returns\n    -------\n    lors: (N, 7) NumPy array\n        The 2D array of LoRs, each row containing the time and coordinates of\n        the first and second point defining a 3D line, respectively:\n        `[time, x1, y1, z1, x2, y2, z2]`.\n\n    Examples\n    --------\n\n    >>> import numpy as np\n    >>> from pept.scanners.parallel_screens import binary_converter\n    >>>\n    >>> lines = binary_converter(\"adac_experiment_data.da01\")\n\n    ";
static PyObject *__pyx_pw_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_1convert_adac_forte(PyObject *__pyx_self, PyObject *__pyx_v_filepath) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_adac_forte (wrapper)", 0);
  __pyx_r = __pyx_pf_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_convert_adac_forte(__pyx_self, ((PyObject *)__pyx_v_filepath));

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

static PyObject *__pyx_pf_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_convert_adac_forte(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filepath) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_adac_forte", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4pept_8scanners_16parallel_screens_10extensions_16binary_converter_convert_adac_forte(__pyx_v_filepath, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pept.scanners.parallel_screens.extensions.binary_converter.convert_adac_forte", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 066:     '''Convert an ADAC Forte list mode binary file to a general line data
 067:     format `[time, x1, y1, z1, x2, y2, z2]`, returned as a NumPy array.
 068: 
 069:     ::
 070: 
 071:         Function signature:
 072:             binary_converter(filepath)
 073: 
 074:     Binary converter for the ADAC Forte dual-head gamma camera native list
 075:     mode data. Given the `filepath` to such a binary file (usually with
 076:     extension ".da01"), this function converts the binary contents to the
 077:     general line of response format `[time, x1, y1, z1, x2, y2, z2]`, where
 078:     `z1 = 0` and `z2 = screen_separation` (found from the file).
 079: 
 080:     The LoRs are returned as a (N, 7) NumPy array, where N is the number of
 081:     LoRs that were found in the file.
 082: 
 083:     Function parameters
 084:     -------------------
 085:     filepath: str-like
 086:         A string of characters containing the path to the binary file. The
 087:         string's contents are not read in - it will only be used with the
 088:         `fopen` function, so it can contain any characters allowed by the OS
 089:         file system.
 090: 
 091:     Returns
 092:     -------
 093:     lors: (N, 7) NumPy array
 094:         The 2D array of LoRs, each row containing the time and coordinates of
 095:         the first and second point defining a 3D line, respectively:
 096:         `[time, x1, y1, z1, x2, y2, z2]`.
 097: 
 098:     Examples
 099:     --------
 100: 
 101:     >>> import numpy as np
 102:     >>> from pept.scanners.parallel_screens import binary_converter
 103:     >>>
 104:     >>> lines = binary_converter("adac_experiment_data.da01")
 105: 
 106:     '''
 107: 
+108:     filepath_utf = str(filepath).encode('UTF-8')
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_filepath); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyUnicode_AsUTF8String(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_filepath_utf = __pyx_t_2;
  __pyx_t_2 = 0;
 109: 
+110:     cdef char                       *filepath_c = filepath_utf
  __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_filepath_utf); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L1_error)
  __pyx_v_filepath_c = __pyx_t_3;
 111: 
+112:     cdef double                     *lors = NULL
  __pyx_v_lors = NULL;
+113:     cdef Py_ssize_t                 lors_elements = 0
  __pyx_v_lors_elements = 0;
 114:     cdef np.npy_intp[2]             shape
 115: 
 116:     cdef np.ndarray[double, ndim=2] lors_arr
 117: 
+118:     with nogil:
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {
/* … */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }
+119:         lors = read_adac_binary(filepath_c, &lors_elements)
        __pyx_v_lors = read_adac_binary(__pyx_v_filepath_c, (&__pyx_v_lors_elements));
 120: 
+121:         shape[0] = lors_elements // 7
        (__pyx_v_shape[0]) = (__pyx_v_lors_elements / 7);
+122:         shape[1] = 7
        (__pyx_v_shape[1]) = 7;
      }
 123: 
 124:     # Use the `lors` pointer as the internal data of a numpy array with
 125:     # PyArray_SimpleNewFromData
 126:     cdef extern from "numpy/arrayobject.h":
 127:         void PyArray_ENABLEFLAGS(np.ndarray arr, int flags)
 128: 
+129:     if lors is NULL:
  __pyx_t_4 = ((__pyx_v_lors == NULL) != 0);
  if (__pyx_t_4) {
/* … */
    goto __pyx_L6;
  }
+130:         lors_arr = np.PyArray_Empty(2, shape, np.NPY_FLOAT64, 0)
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PyArray_Empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_carray_to_py_npy_intp(__pyx_v_shape, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_int_2, __pyx_t_1, __pyx_t_6, __pyx_int_0};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_int_2, __pyx_t_1, __pyx_t_6, __pyx_int_0};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_int_2);
      __Pyx_GIVEREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_int_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_int_0);
      __pyx_t_1 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 130, __pyx_L1_error)
    __pyx_t_10 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lors_arr.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lors_arr.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lors_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_lors_arr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_lors_arr.diminfo[0].strides = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_lors_arr.diminfo[0].shape = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_lors_arr.diminfo[1].strides = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_lors_arr.diminfo[1].shape = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 130, __pyx_L1_error)
    }
    __pyx_t_10 = 0;
    __pyx_v_lors_arr = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;
 131:     else:
+132:         lors_arr = np.PyArray_SimpleNewFromData(2, shape, np.NPY_FLOAT64, lors)
  /*else*/ {
    __pyx_t_2 = PyArray_SimpleNewFromData(2, __pyx_v_shape, NPY_FLOAT64, __pyx_v_lors); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 132, __pyx_L1_error)
    __pyx_t_10 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lors_arr.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lors_arr.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lors_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_lors_arr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_lors_arr.diminfo[0].strides = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_lors_arr.diminfo[0].shape = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_lors_arr.diminfo[1].strides = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_lors_arr.diminfo[1].shape = __pyx_pybuffernd_lors_arr.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 132, __pyx_L1_error)
    }
    __pyx_t_10 = 0;
    __pyx_v_lors_arr = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L6:;
 133: 
+134:     PyArray_ENABLEFLAGS(lors_arr, np.NPY_OWNDATA)
  PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_lors_arr), NPY_OWNDATA);
 135: 
+136:     return lors_arr
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_lors_arr));
  __pyx_r = ((PyObject *)__pyx_v_lors_arr);
  goto __pyx_L0;