Generated by Cython 0.17pre on Thu Jun 21 13:23:58 2012

Raw output: xutils.c

     1: #!/usr/bin/env python

      /* "xutils.pyx":1
     * #!/usr/bin/env python             # <<<<<<<<<<<<<<
     * # -*- coding: utf8 -*-
     * #
     */
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

     2: # -*- coding: utf8 -*-

     3: #

     4: #    Project: Azimuthal integration

     5: #             https://forge.epn-campus.eu/projects/azimuthal

     6: #

     7: #    File: "$Id$"

     8: #

     9: #    Copyright (C) European Synchrotron Radiation Facility, Grenoble, France

     10: #

     11: #    Principal author:       Jérôme Kieffer (Jerome.Kieffer@ESRF.eu)

     12: #

     13: #    This program is free software: you can redistribute it and/or modify

     14: #    it under the terms of the GNU General Public License as published by

     15: #    the Free Software Foundation, either version 3 of the License, or

     16: #    (at your option) any later version.

     17: #

     18: #    This program is distributed in the hope that it will be useful,

     19: #    but WITHOUT ANY WARRANTY; without even the implied warranty of

     20: #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

     21: #    GNU General Public License for more details.

     22: #

     23: #    You should have received a copy of the GNU General Public License

     24: #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

     25: #

     26:

     27: import cython

     28: cimport numpy

     29: import numpy

      /* "xutils.pyx":29
     * import cython
     * cimport numpy
     * import numpy             # <<<<<<<<<<<<<<
     *
     * ctypedef numpy.int64_t DTYPE_int64_t
     */
      __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__numpy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     30:

     31: ctypedef numpy.int64_t DTYPE_int64_t

    /* "xutils.pyx":31
     * import numpy
     *
     * ctypedef numpy.int64_t DTYPE_int64_t             # <<<<<<<<<<<<<<
     * ctypedef numpy.float64_t DTYPE_float64_t
     *
     */
    typedef __pyx_t_5numpy_int64_t __pyx_t_6xutils_DTYPE_int64_t;

     32: ctypedef numpy.float64_t DTYPE_float64_t

     33:

     34: def boundingBox(data):

    /* "xutils.pyx":34
     * ctypedef numpy.float64_t DTYPE_float64_t
     *
     * def boundingBox(data):             # <<<<<<<<<<<<<<
     *     """
     *     Calculate bounding box around
     */

    static PyObject *__pyx_pf_6xutils_boundingBox(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data) {
      PyArrayObject *__pyx_v_shape = 0;
      long __pyx_v_ndims;
      PyArrayObject *__pyx_v_mins = 0;
      PyArrayObject *__pyx_v_maxs = 0;
      long __pyx_v_i;
      long __pyx_v_j;
      long __pyx_v_k;
      long __pyx_v_l;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_maxs;
      __Pyx_Buffer __pyx_pybuffer_maxs;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_mins;
      __Pyx_Buffer __pyx_pybuffer_mins;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_shape;
      __Pyx_Buffer __pyx_pybuffer_shape;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("boundingBox", 0);
      __pyx_pybuffer_shape.pybuffer.buf = NULL;
      __pyx_pybuffer_shape.refcount = 0;
      __pyx_pybuffernd_shape.data = NULL;
      __pyx_pybuffernd_shape.rcbuffer = &__pyx_pybuffer_shape;
      __pyx_pybuffer_mins.pybuffer.buf = NULL;
      __pyx_pybuffer_mins.refcount = 0;
      __pyx_pybuffernd_mins.data = NULL;
      __pyx_pybuffernd_mins.rcbuffer = &__pyx_pybuffer_mins;
      __pyx_pybuffer_maxs.pybuffer.buf = NULL;
      __pyx_pybuffer_maxs.refcount = 0;
      __pyx_pybuffernd_maxs.data = NULL;
      __pyx_pybuffernd_maxs.rcbuffer = &__pyx_pybuffer_maxs;

      /* "xutils.pyx":34
     * ctypedef numpy.float64_t DTYPE_float64_t
     *
     * def boundingBox(data):             # <<<<<<<<<<<<<<
     *     """
     *     Calculate bounding box around
     */
      __pyx_k_tuple_15 = PyTuple_New(9); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_k_tuple_15);
      __Pyx_INCREF(((PyObject *)__pyx_n_s__data));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_n_s__data));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__data));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__shape));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 1, ((PyObject *)__pyx_n_s__shape));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__shape));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__ndims));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 2, ((PyObject *)__pyx_n_s__ndims));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ndims));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__mins));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 3, ((PyObject *)__pyx_n_s__mins));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mins));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__maxs));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 4, ((PyObject *)__pyx_n_s__maxs));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__maxs));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 5, ((PyObject *)__pyx_n_s__i));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__j));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 6, ((PyObject *)__pyx_n_s__j));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__j));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__k));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 7, ((PyObject *)__pyx_n_s__k));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__k));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__l));
      PyTuple_SET_ITEM(__pyx_k_tuple_15, 8, ((PyObject *)__pyx_n_s__l));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l));
      __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15));

      /* "xutils.pyx":34
     * ctypedef numpy.float64_t DTYPE_float64_t
     *
     * def boundingBox(data):             # <<<<<<<<<<<<<<
     *     """
     *     Calculate bounding box around
     */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6xutils_1boundingBox, NULL, __pyx_n_s__xutils); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__boundingBox, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     35:     """

     36:     Calculate bounding box around

     37:

     38:     @param img: 2D array like

     39:     @return: 4-typle (d0_min, d1_min, d0_max, d1_max)

     40:

     41:

     42:     NOTA: Does not work :(

     43:

     44:     """

     45:     cdef numpy.ndarray[long, ndim = 1] shape = numpy.array(data.shape)

      /* "xutils.pyx":45
     *
     *     """
     *     cdef numpy.ndarray[long, ndim = 1] shape = numpy.array(data.shape)             # <<<<<<<<<<<<<<
     *     cdef long ndims = data.ndim
     *
     */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_shape.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_shape = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_shape.diminfo[0].strides = __pyx_pybuffernd_shape.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_shape.diminfo[0].shape = __pyx_pybuffernd_shape.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_4 = 0;
      __pyx_v_shape = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     46:     cdef long ndims = data.ndim

      /* "xutils.pyx":46
     *     """
     *     cdef numpy.ndarray[long, ndim = 1] shape = numpy.array(data.shape)
     *     cdef long ndims = data.ndim             # <<<<<<<<<<<<<<
     *
     * #    cdef numpy.ndarray[float, ndim = ndims] fdata = data.astype(float)
     */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_t_1); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_ndims = __pyx_t_5;

     47:

     48: #    cdef numpy.ndarray[float, ndim = ndims] fdata = data.astype(float)

     49:     cdef numpy.ndarray[long, ndim = 1] mins = numpy.array(shape)

      /* "xutils.pyx":49
     *
     * #    cdef numpy.ndarray[float, ndim = ndims] fdata = data.astype(float)
     *     cdef numpy.ndarray[long, ndim = 1] mins = numpy.array(shape)             # <<<<<<<<<<<<<<
     *     cdef numpy.ndarray[long, ndim = 1] maxs = numpy.zeros(ndims, dtype=int)
     *
     */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_shape));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_shape));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_shape));
      __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mins.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_mins = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_mins.diminfo[0].strides = __pyx_pybuffernd_mins.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mins.diminfo[0].shape = __pyx_pybuffernd_mins.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_mins = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

     50:     cdef numpy.ndarray[long, ndim = 1] maxs = numpy.zeros(ndims, dtype=int)

      /* "xutils.pyx":50
     * #    cdef numpy.ndarray[float, ndim = ndims] fdata = data.astype(float)
     *     cdef numpy.ndarray[long, ndim = 1] mins = numpy.array(shape)
     *     cdef numpy.ndarray[long, ndim = 1] maxs = numpy.zeros(ndims, dtype=int)             # <<<<<<<<<<<<<<
     *
     *
     */
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromLong(__pyx_v_ndims); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)((PyObject*)(&PyInt_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_7);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_maxs.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_maxs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_maxs.diminfo[0].strides = __pyx_pybuffernd_maxs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_maxs.diminfo[0].shape = __pyx_pybuffernd_maxs.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_8 = 0;
      __pyx_v_maxs = ((PyArrayObject *)__pyx_t_7);
      __pyx_t_7 = 0;

     51:

     52:

     53:     cdef long  i = 0

      /* "xutils.pyx":53
     *
     *
     *     cdef long  i = 0             # <<<<<<<<<<<<<<
     *     cdef long  j = 0
     *     cdef long  k = 0
     */
      __pyx_v_i = 0;

     54:     cdef long  j = 0

      /* "xutils.pyx":54
     *
     *     cdef long  i = 0
     *     cdef long  j = 0             # <<<<<<<<<<<<<<
     *     cdef long  k = 0
     *     cdef long  l = 0
     */
      __pyx_v_j = 0;

     55:     cdef long  k = 0

      /* "xutils.pyx":55
     *     cdef long  i = 0
     *     cdef long  j = 0
     *     cdef long  k = 0             # <<<<<<<<<<<<<<
     *     cdef long  l = 0
     * #    cdef DTYPE_float64_t x = 0.0
     */
      __pyx_v_k = 0;

     56:     cdef long  l = 0

      /* "xutils.pyx":56
     *     cdef long  j = 0
     *     cdef long  k = 0
     *     cdef long  l = 0             # <<<<<<<<<<<<<<
     * #    cdef DTYPE_float64_t x = 0.0
     * #    cdef DTYPE_float64_t zero64 = 0.0
     */
      __pyx_v_l = 0;

     57: #    cdef DTYPE_float64_t x = 0.0

     58: #    cdef DTYPE_float64_t zero64 = 0.0

     59:     if ndims == 1:

        /* "xutils.pyx":59
     * #    cdef DTYPE_float64_t x = 0.0
     * #    cdef DTYPE_float64_t zero64 = 0.0
     *     if ndims == 1:             # <<<<<<<<<<<<<<
     * #        with nogil:
     *             for i in range(shape[0]):
     */
        case 1:

     60: #        with nogil:

     61:             for i in range(shape[0]):

        /* "xutils.pyx":61
     *     if ndims == 1:
     * #        with nogil:
     *             for i in range(shape[0]):             # <<<<<<<<<<<<<<
     *                 if data[i] > 0.0:
     *                     if i < mins[0]:
     */
        __pyx_t_5 = 0;
        __pyx_t_9 = -1;
        if (__pyx_t_5 < 0) {
          __pyx_t_5 += __pyx_pybuffernd_shape.diminfo[0].shape;
          if (unlikely(__pyx_t_5 < 0)) __pyx_t_9 = 0;
        } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
        if (unlikely(__pyx_t_9 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_9);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_10 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_shape.diminfo[0].strides));
        for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
          __pyx_v_i = __pyx_t_11;

     62:                 if data[i] > 0.0:

          /* "xutils.pyx":62
     * #        with nogil:
     *             for i in range(shape[0]):
     *                 if data[i] > 0.0:             # <<<<<<<<<<<<<<
     *                     if i < mins[0]:
     *                         mins[0] = i
     */
          __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_data, __pyx_v_i, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_2 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyObject_RichCompare(__pyx_t_7, __pyx_t_2, Py_GT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (__pyx_t_12) {

     63:                     if i < mins[0]:

            /* "xutils.pyx":63
     *             for i in range(shape[0]):
     *                 if data[i] > 0.0:
     *                     if i < mins[0]:             # <<<<<<<<<<<<<<
     *                         mins[0] = i
     *                     if i > maxs[0]:
     */
            __pyx_t_13 = 0;
            __pyx_t_9 = -1;
            if (__pyx_t_13 < 0) {
              __pyx_t_13 += __pyx_pybuffernd_mins.diminfo[0].shape;
              if (unlikely(__pyx_t_13 < 0)) __pyx_t_9 = 0;
            } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
            if (unlikely(__pyx_t_9 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_9);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_12 = (__pyx_v_i < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_mins.diminfo[0].strides)));
            if (__pyx_t_12) {

     64:                         mins[0] = i

              /* "xutils.pyx":64
     *                 if data[i] > 0.0:
     *                     if i < mins[0]:
     *                         mins[0] = i             # <<<<<<<<<<<<<<
     *                     if i > maxs[0]:
     *                         maxs[0] = i
     */
              __pyx_t_14 = 0;
              __pyx_t_9 = -1;
              if (__pyx_t_14 < 0) {
                __pyx_t_14 += __pyx_pybuffernd_mins.diminfo[0].shape;
                if (unlikely(__pyx_t_14 < 0)) __pyx_t_9 = 0;
              } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
              if (unlikely(__pyx_t_9 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_9);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
              goto __pyx_L6;
            }
            __pyx_L6:;

     65:                     if i > maxs[0]:

            /* "xutils.pyx":65
     *                     if i < mins[0]:
     *                         mins[0] = i
     *                     if i > maxs[0]:             # <<<<<<<<<<<<<<
     *                         maxs[0] = i
     *     elif ndims == 2:
     */
            __pyx_t_15 = 0;
            __pyx_t_9 = -1;
            if (__pyx_t_15 < 0) {
              __pyx_t_15 += __pyx_pybuffernd_maxs.diminfo[0].shape;
              if (unlikely(__pyx_t_15 < 0)) __pyx_t_9 = 0;
            } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
            if (unlikely(__pyx_t_9 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_9);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_12 = (__pyx_v_i > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_maxs.diminfo[0].strides)));
            if (__pyx_t_12) {

     66:                         maxs[0] = i

              /* "xutils.pyx":66
     *                         mins[0] = i
     *                     if i > maxs[0]:
     *                         maxs[0] = i             # <<<<<<<<<<<<<<
     *     elif ndims == 2:
     * #        with nogil:
     */
              __pyx_t_16 = 0;
              __pyx_t_9 = -1;
              if (__pyx_t_16 < 0) {
                __pyx_t_16 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                if (unlikely(__pyx_t_16 < 0)) __pyx_t_9 = 0;
              } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
              if (unlikely(__pyx_t_9 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_9);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
              goto __pyx_L7;
            }
            __pyx_L7:;
            goto __pyx_L5;
          }
          __pyx_L5:;
        }
        break;

     67:     elif ndims == 2:

        /* "xutils.pyx":67
     *                     if i > maxs[0]:
     *                         maxs[0] = i
     *     elif ndims == 2:             # <<<<<<<<<<<<<<
     * #        with nogil:
     *             for i in range(shape[0]):
     */
        case 2:

     68: #        with nogil:

     69:             for i in range(shape[0]):

        /* "xutils.pyx":69
     *     elif ndims == 2:
     * #        with nogil:
     *             for i in range(shape[0]):             # <<<<<<<<<<<<<<
     *                 for j in range(shape[1]):
     *                     if data[i, j] > 0.0 :
     */
        __pyx_t_10 = 0;
        __pyx_t_9 = -1;
        if (__pyx_t_10 < 0) {
          __pyx_t_10 += __pyx_pybuffernd_shape.diminfo[0].shape;
          if (unlikely(__pyx_t_10 < 0)) __pyx_t_9 = 0;
        } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
        if (unlikely(__pyx_t_9 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_9);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_11 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_shape.diminfo[0].strides));
        for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_11; __pyx_t_17+=1) {
          __pyx_v_i = __pyx_t_17;

     70:                 for j in range(shape[1]):

          /* "xutils.pyx":70
     * #        with nogil:
     *             for i in range(shape[0]):
     *                 for j in range(shape[1]):             # <<<<<<<<<<<<<<
     *                     if data[i, j] > 0.0 :
     *                         if i < mins[0]:
     */
          __pyx_t_18 = 1;
          __pyx_t_9 = -1;
          if (__pyx_t_18 < 0) {
            __pyx_t_18 += __pyx_pybuffernd_shape.diminfo[0].shape;
            if (unlikely(__pyx_t_18 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_19 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_shape.diminfo[0].strides));
          for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
            __pyx_v_j = __pyx_t_20;

     71:                     if data[i, j] > 0.0 :

            /* "xutils.pyx":71
     *             for i in range(shape[0]):
     *                 for j in range(shape[1]):
     *                     if data[i, j] > 0.0 :             # <<<<<<<<<<<<<<
     *                         if i < mins[0]:
     *                             mins[0] = i
     */
            __pyx_t_3 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_2 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_7);
            PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_2);
            __pyx_t_3 = 0;
            __pyx_t_2 = 0;
            __pyx_t_2 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_t_7)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
            __pyx_t_7 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_7, Py_GT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (__pyx_t_12) {

     72:                         if i < mins[0]:

              /* "xutils.pyx":72
     *                 for j in range(shape[1]):
     *                     if data[i, j] > 0.0 :
     *                         if i < mins[0]:             # <<<<<<<<<<<<<<
     *                             mins[0] = i
     *                         if i > maxs[0]:
     */
              __pyx_t_21 = 0;
              __pyx_t_9 = -1;
              if (__pyx_t_21 < 0) {
                __pyx_t_21 += __pyx_pybuffernd_mins.diminfo[0].shape;
                if (unlikely(__pyx_t_21 < 0)) __pyx_t_9 = 0;
              } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
              if (unlikely(__pyx_t_9 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_9);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_12 = (__pyx_v_i < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_mins.diminfo[0].strides)));
              if (__pyx_t_12) {

     73:                             mins[0] = i

                /* "xutils.pyx":73
     *                     if data[i, j] > 0.0 :
     *                         if i < mins[0]:
     *                             mins[0] = i             # <<<<<<<<<<<<<<
     *                         if i > maxs[0]:
     *                             maxs[0] = i
     */
                __pyx_t_22 = 0;
                __pyx_t_9 = -1;
                if (__pyx_t_22 < 0) {
                  __pyx_t_22 += __pyx_pybuffernd_mins.diminfo[0].shape;
                  if (unlikely(__pyx_t_22 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                goto __pyx_L13;
              }
              __pyx_L13:;

     74:                         if i > maxs[0]:

              /* "xutils.pyx":74
     *                         if i < mins[0]:
     *                             mins[0] = i
     *                         if i > maxs[0]:             # <<<<<<<<<<<<<<
     *                             maxs[0] = i
     *                         if j < mins[1]:
     */
              __pyx_t_23 = 0;
              __pyx_t_9 = -1;
              if (__pyx_t_23 < 0) {
                __pyx_t_23 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                if (unlikely(__pyx_t_23 < 0)) __pyx_t_9 = 0;
              } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
              if (unlikely(__pyx_t_9 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_9);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_12 = (__pyx_v_i > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_maxs.diminfo[0].strides)));
              if (__pyx_t_12) {

     75:                             maxs[0] = i

                /* "xutils.pyx":75
     *                             mins[0] = i
     *                         if i > maxs[0]:
     *                             maxs[0] = i             # <<<<<<<<<<<<<<
     *                         if j < mins[1]:
     *                             mins[1] = i
     */
                __pyx_t_24 = 0;
                __pyx_t_9 = -1;
                if (__pyx_t_24 < 0) {
                  __pyx_t_24 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                  if (unlikely(__pyx_t_24 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                goto __pyx_L14;
              }
              __pyx_L14:;

     76:                         if j < mins[1]:

              /* "xutils.pyx":76
     *                         if i > maxs[0]:
     *                             maxs[0] = i
     *                         if j < mins[1]:             # <<<<<<<<<<<<<<
     *                             mins[1] = i
     *                         if j > maxs[1]:
     */
              __pyx_t_25 = 1;
              __pyx_t_9 = -1;
              if (__pyx_t_25 < 0) {
                __pyx_t_25 += __pyx_pybuffernd_mins.diminfo[0].shape;
                if (unlikely(__pyx_t_25 < 0)) __pyx_t_9 = 0;
              } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
              if (unlikely(__pyx_t_9 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_9);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_12 = (__pyx_v_j < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_mins.diminfo[0].strides)));
              if (__pyx_t_12) {

     77:                             mins[1] = i

                /* "xutils.pyx":77
     *                             maxs[0] = i
     *                         if j < mins[1]:
     *                             mins[1] = i             # <<<<<<<<<<<<<<
     *                         if j > maxs[1]:
     *                             maxs[1] = i
     */
                __pyx_t_26 = 1;
                __pyx_t_9 = -1;
                if (__pyx_t_26 < 0) {
                  __pyx_t_26 += __pyx_pybuffernd_mins.diminfo[0].shape;
                  if (unlikely(__pyx_t_26 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                goto __pyx_L15;
              }
              __pyx_L15:;

     78:                         if j > maxs[1]:

              /* "xutils.pyx":78
     *                         if j < mins[1]:
     *                             mins[1] = i
     *                         if j > maxs[1]:             # <<<<<<<<<<<<<<
     *                             maxs[1] = i
     *     elif ndims == 3:
     */
              __pyx_t_27 = 1;
              __pyx_t_9 = -1;
              if (__pyx_t_27 < 0) {
                __pyx_t_27 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                if (unlikely(__pyx_t_27 < 0)) __pyx_t_9 = 0;
              } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
              if (unlikely(__pyx_t_9 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_9);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_12 = (__pyx_v_j > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_maxs.diminfo[0].strides)));
              if (__pyx_t_12) {

     79:                             maxs[1] = i

                /* "xutils.pyx":79
     *                             mins[1] = i
     *                         if j > maxs[1]:
     *                             maxs[1] = i             # <<<<<<<<<<<<<<
     *     elif ndims == 3:
     * #        with nogil:
     */
                __pyx_t_28 = 1;
                __pyx_t_9 = -1;
                if (__pyx_t_28 < 0) {
                  __pyx_t_28 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                  if (unlikely(__pyx_t_28 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                goto __pyx_L16;
              }
              __pyx_L16:;
              goto __pyx_L12;
            }
            __pyx_L12:;
          }
        }
        break;

     80:     elif ndims == 3:

        /* "xutils.pyx":80
     *                         if j > maxs[1]:
     *                             maxs[1] = i
     *     elif ndims == 3:             # <<<<<<<<<<<<<<
     * #        with nogil:
     *             for i in range(shape[0]):
     */
        case 3:

     81: #        with nogil:

     82:             for i in range(shape[0]):

        /* "xutils.pyx":82
     *     elif ndims == 3:
     * #        with nogil:
     *             for i in range(shape[0]):             # <<<<<<<<<<<<<<
     *                 for j in range(shape[1]):
     *                     for k in range(shape[2]):
     */
        __pyx_t_11 = 0;
        __pyx_t_9 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_pybuffernd_shape.diminfo[0].shape;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_9 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
        if (unlikely(__pyx_t_9 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_9);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_17 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_shape.diminfo[0].strides));
        for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_17; __pyx_t_19+=1) {
          __pyx_v_i = __pyx_t_19;

     83:                 for j in range(shape[1]):

          /* "xutils.pyx":83
     * #        with nogil:
     *             for i in range(shape[0]):
     *                 for j in range(shape[1]):             # <<<<<<<<<<<<<<
     *                     for k in range(shape[2]):
     *                         if  data[i, j, k] > 0.0:
     */
          __pyx_t_20 = 1;
          __pyx_t_9 = -1;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_pybuffernd_shape.diminfo[0].shape;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_29 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_shape.diminfo[0].strides));
          for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) {
            __pyx_v_j = __pyx_t_30;

     84:                     for k in range(shape[2]):

            /* "xutils.pyx":84
     *             for i in range(shape[0]):
     *                 for j in range(shape[1]):
     *                     for k in range(shape[2]):             # <<<<<<<<<<<<<<
     *                         if  data[i, j, k] > 0.0:
     *                             if i < mins[0]:
     */
            __pyx_t_31 = 2;
            __pyx_t_9 = -1;
            if (__pyx_t_31 < 0) {
              __pyx_t_31 += __pyx_pybuffernd_shape.diminfo[0].shape;
              if (unlikely(__pyx_t_31 < 0)) __pyx_t_9 = 0;
            } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
            if (unlikely(__pyx_t_9 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_9);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_32 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_shape.diminfo[0].strides));
            for (__pyx_t_33 = 0; __pyx_t_33 < __pyx_t_32; __pyx_t_33+=1) {
              __pyx_v_k = __pyx_t_33;

     85:                         if  data[i, j, k] > 0.0:

              /* "xutils.pyx":85
     *                 for j in range(shape[1]):
     *                     for k in range(shape[2]):
     *                         if  data[i, j, k] > 0.0:             # <<<<<<<<<<<<<<
     *                             if i < mins[0]:
     *                                 mins[0] = i
     */
              __pyx_t_3 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_7 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_1);
              PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
              __Pyx_GIVEREF(__pyx_t_7);
              PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_2);
              __pyx_t_3 = 0;
              __pyx_t_7 = 0;
              __pyx_t_2 = 0;
              __pyx_t_2 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_t_1)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
              __pyx_t_1 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (__pyx_t_12) {

     86:                             if i < mins[0]:

                /* "xutils.pyx":86
     *                     for k in range(shape[2]):
     *                         if  data[i, j, k] > 0.0:
     *                             if i < mins[0]:             # <<<<<<<<<<<<<<
     *                                 mins[0] = i
     *                             if i > maxs[0]:
     */
                __pyx_t_34 = 0;
                __pyx_t_9 = -1;
                if (__pyx_t_34 < 0) {
                  __pyx_t_34 += __pyx_pybuffernd_mins.diminfo[0].shape;
                  if (unlikely(__pyx_t_34 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_34 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_12 = (__pyx_v_i < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_mins.diminfo[0].strides)));
                if (__pyx_t_12) {

     87:                                 mins[0] = i

                  /* "xutils.pyx":87
     *                         if  data[i, j, k] > 0.0:
     *                             if i < mins[0]:
     *                                 mins[0] = i             # <<<<<<<<<<<<<<
     *                             if i > maxs[0]:
     *                                 maxs[0] = i
     */
                  __pyx_t_35 = 0;
                  __pyx_t_9 = -1;
                  if (__pyx_t_35 < 0) {
                    __pyx_t_35 += __pyx_pybuffernd_mins.diminfo[0].shape;
                    if (unlikely(__pyx_t_35 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_35 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                  goto __pyx_L24;
                }
                __pyx_L24:;

     88:                             if i > maxs[0]:

                /* "xutils.pyx":88
     *                             if i < mins[0]:
     *                                 mins[0] = i
     *                             if i > maxs[0]:             # <<<<<<<<<<<<<<
     *                                 maxs[0] = i
     *                             if j < mins[1]:
     */
                __pyx_t_36 = 0;
                __pyx_t_9 = -1;
                if (__pyx_t_36 < 0) {
                  __pyx_t_36 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                  if (unlikely(__pyx_t_36 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_36 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_12 = (__pyx_v_i > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_maxs.diminfo[0].strides)));
                if (__pyx_t_12) {

     89:                                 maxs[0] = i

                  /* "xutils.pyx":89
     *                                 mins[0] = i
     *                             if i > maxs[0]:
     *                                 maxs[0] = i             # <<<<<<<<<<<<<<
     *                             if j < mins[1]:
     *                                 mins[1] = i
     */
                  __pyx_t_37 = 0;
                  __pyx_t_9 = -1;
                  if (__pyx_t_37 < 0) {
                    __pyx_t_37 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                    if (unlikely(__pyx_t_37 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_37 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                  goto __pyx_L25;
                }
                __pyx_L25:;

     90:                             if j < mins[1]:

                /* "xutils.pyx":90
     *                             if i > maxs[0]:
     *                                 maxs[0] = i
     *                             if j < mins[1]:             # <<<<<<<<<<<<<<
     *                                 mins[1] = i
     *                             if j > maxs[1]:
     */
                __pyx_t_38 = 1;
                __pyx_t_9 = -1;
                if (__pyx_t_38 < 0) {
                  __pyx_t_38 += __pyx_pybuffernd_mins.diminfo[0].shape;
                  if (unlikely(__pyx_t_38 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_38 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_12 = (__pyx_v_j < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_mins.diminfo[0].strides)));
                if (__pyx_t_12) {

     91:                                 mins[1] = i

                  /* "xutils.pyx":91
     *                                 maxs[0] = i
     *                             if j < mins[1]:
     *                                 mins[1] = i             # <<<<<<<<<<<<<<
     *                             if j > maxs[1]:
     *                                 maxs[1] = i
     */
                  __pyx_t_39 = 1;
                  __pyx_t_9 = -1;
                  if (__pyx_t_39 < 0) {
                    __pyx_t_39 += __pyx_pybuffernd_mins.diminfo[0].shape;
                    if (unlikely(__pyx_t_39 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_39 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                  goto __pyx_L26;
                }
                __pyx_L26:;

     92:                             if j > maxs[1]:

                /* "xutils.pyx":92
     *                             if j < mins[1]:
     *                                 mins[1] = i
     *                             if j > maxs[1]:             # <<<<<<<<<<<<<<
     *                                 maxs[1] = i
     *                             if k < mins[2]:
     */
                __pyx_t_40 = 1;
                __pyx_t_9 = -1;
                if (__pyx_t_40 < 0) {
                  __pyx_t_40 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                  if (unlikely(__pyx_t_40 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_40 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_12 = (__pyx_v_j > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_maxs.diminfo[0].strides)));
                if (__pyx_t_12) {

     93:                                 maxs[1] = i

                  /* "xutils.pyx":93
     *                                 mins[1] = i
     *                             if j > maxs[1]:
     *                                 maxs[1] = i             # <<<<<<<<<<<<<<
     *                             if k < mins[2]:
     *                                 mins[2] = i
     */
                  __pyx_t_41 = 1;
                  __pyx_t_9 = -1;
                  if (__pyx_t_41 < 0) {
                    __pyx_t_41 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                    if (unlikely(__pyx_t_41 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_41 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                  goto __pyx_L27;
                }
                __pyx_L27:;

     94:                             if k < mins[2]:

                /* "xutils.pyx":94
     *                             if j > maxs[1]:
     *                                 maxs[1] = i
     *                             if k < mins[2]:             # <<<<<<<<<<<<<<
     *                                 mins[2] = i
     *                             if k > maxs[2]:
     */
                __pyx_t_42 = 2;
                __pyx_t_9 = -1;
                if (__pyx_t_42 < 0) {
                  __pyx_t_42 += __pyx_pybuffernd_mins.diminfo[0].shape;
                  if (unlikely(__pyx_t_42 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_42 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_12 = (__pyx_v_k < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_mins.diminfo[0].strides)));
                if (__pyx_t_12) {

     95:                                 mins[2] = i

                  /* "xutils.pyx":95
     *                                 maxs[1] = i
     *                             if k < mins[2]:
     *                                 mins[2] = i             # <<<<<<<<<<<<<<
     *                             if k > maxs[2]:
     *                                 maxs[2] = i
     */
                  __pyx_t_43 = 2;
                  __pyx_t_9 = -1;
                  if (__pyx_t_43 < 0) {
                    __pyx_t_43 += __pyx_pybuffernd_mins.diminfo[0].shape;
                    if (unlikely(__pyx_t_43 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_43 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_43, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                  goto __pyx_L28;
                }
                __pyx_L28:;

     96:                             if k > maxs[2]:

                /* "xutils.pyx":96
     *                             if k < mins[2]:
     *                                 mins[2] = i
     *                             if k > maxs[2]:             # <<<<<<<<<<<<<<
     *                                 maxs[2] = i
     *     elif ndims == 4:
     */
                __pyx_t_44 = 2;
                __pyx_t_9 = -1;
                if (__pyx_t_44 < 0) {
                  __pyx_t_44 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                  if (unlikely(__pyx_t_44 < 0)) __pyx_t_9 = 0;
                } else if (unlikely(__pyx_t_44 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                if (unlikely(__pyx_t_9 != -1)) {
                  __Pyx_RaiseBufferIndexError(__pyx_t_9);
                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                __pyx_t_12 = (__pyx_v_k > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_maxs.diminfo[0].strides)));
                if (__pyx_t_12) {

     97:                                 maxs[2] = i

                  /* "xutils.pyx":97
     *                                 mins[2] = i
     *                             if k > maxs[2]:
     *                                 maxs[2] = i             # <<<<<<<<<<<<<<
     *     elif ndims == 4:
     * #        with nogil:
     */
                  __pyx_t_45 = 2;
                  __pyx_t_9 = -1;
                  if (__pyx_t_45 < 0) {
                    __pyx_t_45 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                    if (unlikely(__pyx_t_45 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_45 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_45, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                  goto __pyx_L29;
                }
                __pyx_L29:;
                goto __pyx_L23;
              }
              __pyx_L23:;
            }
          }
        }
        break;

     98:     elif ndims == 4:

      /* "xutils.pyx":98
     *                             if k > maxs[2]:
     *                                 maxs[2] = i
     *     elif ndims == 4:             # <<<<<<<<<<<<<<
     * #        with nogil:
     *             for i in range(shape[0]):
     */
      switch (__pyx_v_ndims) {

        /* "xutils.pyx":98
     *                             if k > maxs[2]:
     *                                 maxs[2] = i
     *     elif ndims == 4:             # <<<<<<<<<<<<<<
     * #        with nogil:
     *             for i in range(shape[0]):
     */
        case 4:

     99: #        with nogil:

     100:             for i in range(shape[0]):

        /* "xutils.pyx":100
     *     elif ndims == 4:
     * #        with nogil:
     *             for i in range(shape[0]):             # <<<<<<<<<<<<<<
     *                 for j in range(shape[1]):
     *                     for k in range(shape[2]):
     */
        __pyx_t_17 = 0;
        __pyx_t_9 = -1;
        if (__pyx_t_17 < 0) {
          __pyx_t_17 += __pyx_pybuffernd_shape.diminfo[0].shape;
          if (unlikely(__pyx_t_17 < 0)) __pyx_t_9 = 0;
        } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
        if (unlikely(__pyx_t_9 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_9);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_19 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_shape.diminfo[0].strides));
        for (__pyx_t_29 = 0; __pyx_t_29 < __pyx_t_19; __pyx_t_29+=1) {
          __pyx_v_i = __pyx_t_29;

     101:                 for j in range(shape[1]):

          /* "xutils.pyx":101
     * #        with nogil:
     *             for i in range(shape[0]):
     *                 for j in range(shape[1]):             # <<<<<<<<<<<<<<
     *                     for k in range(shape[2]):
     *                         for l in range(shape[3]):
     */
          __pyx_t_30 = 1;
          __pyx_t_9 = -1;
          if (__pyx_t_30 < 0) {
            __pyx_t_30 += __pyx_pybuffernd_shape.diminfo[0].shape;
            if (unlikely(__pyx_t_30 < 0)) __pyx_t_9 = 0;
          } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
          if (unlikely(__pyx_t_9 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_9);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_32 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_shape.diminfo[0].strides));
          for (__pyx_t_33 = 0; __pyx_t_33 < __pyx_t_32; __pyx_t_33+=1) {
            __pyx_v_j = __pyx_t_33;

     102:                     for k in range(shape[2]):

            /* "xutils.pyx":102
     *             for i in range(shape[0]):
     *                 for j in range(shape[1]):
     *                     for k in range(shape[2]):             # <<<<<<<<<<<<<<
     *                         for l in range(shape[3]):
     *                             if  data[i, j, k, l] > 0.0:
     */
            __pyx_t_46 = 2;
            __pyx_t_9 = -1;
            if (__pyx_t_46 < 0) {
              __pyx_t_46 += __pyx_pybuffernd_shape.diminfo[0].shape;
              if (unlikely(__pyx_t_46 < 0)) __pyx_t_9 = 0;
            } else if (unlikely(__pyx_t_46 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
            if (unlikely(__pyx_t_9 != -1)) {
              __Pyx_RaiseBufferIndexError(__pyx_t_9);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_47 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_46, __pyx_pybuffernd_shape.diminfo[0].strides));
            for (__pyx_t_48 = 0; __pyx_t_48 < __pyx_t_47; __pyx_t_48+=1) {
              __pyx_v_k = __pyx_t_48;

     103:                         for l in range(shape[3]):

              /* "xutils.pyx":103
     *                 for j in range(shape[1]):
     *                     for k in range(shape[2]):
     *                         for l in range(shape[3]):             # <<<<<<<<<<<<<<
     *                             if  data[i, j, k, l] > 0.0:
     *                                 if i < mins[0]:
     */
              __pyx_t_49 = 3;
              __pyx_t_9 = -1;
              if (__pyx_t_49 < 0) {
                __pyx_t_49 += __pyx_pybuffernd_shape.diminfo[0].shape;
                if (unlikely(__pyx_t_49 < 0)) __pyx_t_9 = 0;
              } else if (unlikely(__pyx_t_49 >= __pyx_pybuffernd_shape.diminfo[0].shape)) __pyx_t_9 = 0;
              if (unlikely(__pyx_t_9 != -1)) {
                __Pyx_RaiseBufferIndexError(__pyx_t_9);
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              __pyx_t_50 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_shape.rcbuffer->pybuffer.buf, __pyx_t_49, __pyx_pybuffernd_shape.diminfo[0].strides));
              for (__pyx_t_51 = 0; __pyx_t_51 < __pyx_t_50; __pyx_t_51+=1) {
                __pyx_v_l = __pyx_t_51;

     104:                             if  data[i, j, k, l] > 0.0:

                /* "xutils.pyx":104
     *                     for k in range(shape[2]):
     *                         for l in range(shape[3]):
     *                             if  data[i, j, k, l] > 0.0:             # <<<<<<<<<<<<<<
     *                                 if i < mins[0]:
     *                                     mins[0] = i
     */
                __pyx_t_7 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_t_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_3 = PyInt_FromLong(__pyx_v_l); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_52 = PyTuple_New(4); if (unlikely(!__pyx_t_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_52);
                PyTuple_SET_ITEM(__pyx_t_52, 0, __pyx_t_7);
                __Pyx_GIVEREF(__pyx_t_7);
                PyTuple_SET_ITEM(__pyx_t_52, 1, __pyx_t_1);
                __Pyx_GIVEREF(__pyx_t_1);
                PyTuple_SET_ITEM(__pyx_t_52, 2, __pyx_t_2);
                __Pyx_GIVEREF(__pyx_t_2);
                PyTuple_SET_ITEM(__pyx_t_52, 3, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_t_7 = 0;
                __pyx_t_1 = 0;
                __pyx_t_2 = 0;
                __pyx_t_3 = 0;
                __pyx_t_3 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_t_52)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(((PyObject *)__pyx_t_52)); __pyx_t_52 = 0;
                __pyx_t_52 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_52);
                __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_52, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (__pyx_t_12) {

     105:                                 if i < mins[0]:

                  /* "xutils.pyx":105
     *                         for l in range(shape[3]):
     *                             if  data[i, j, k, l] > 0.0:
     *                                 if i < mins[0]:             # <<<<<<<<<<<<<<
     *                                     mins[0] = i
     *                                 if i > maxs[0]:
     */
                  __pyx_t_53 = 0;
                  __pyx_t_9 = -1;
                  if (__pyx_t_53 < 0) {
                    __pyx_t_53 += __pyx_pybuffernd_mins.diminfo[0].shape;
                    if (unlikely(__pyx_t_53 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_53 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_i < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_53, __pyx_pybuffernd_mins.diminfo[0].strides)));
                  if (__pyx_t_12) {

     106:                                     mins[0] = i

                    /* "xutils.pyx":106
     *                             if  data[i, j, k, l] > 0.0:
     *                                 if i < mins[0]:
     *                                     mins[0] = i             # <<<<<<<<<<<<<<
     *                                 if i > maxs[0]:
     *                                     maxs[0] = i
     */
                    __pyx_t_54 = 0;
                    __pyx_t_9 = -1;
                    if (__pyx_t_54 < 0) {
                      __pyx_t_54 += __pyx_pybuffernd_mins.diminfo[0].shape;
                      if (unlikely(__pyx_t_54 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_54 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_54, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L39;
                  }
                  __pyx_L39:;

     107:                                 if i > maxs[0]:

                  /* "xutils.pyx":107
     *                                 if i < mins[0]:
     *                                     mins[0] = i
     *                                 if i > maxs[0]:             # <<<<<<<<<<<<<<
     *                                     maxs[0] = i
     *                                 if j < mins[1]:
     */
                  __pyx_t_55 = 0;
                  __pyx_t_9 = -1;
                  if (__pyx_t_55 < 0) {
                    __pyx_t_55 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                    if (unlikely(__pyx_t_55 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_55 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_i > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_55, __pyx_pybuffernd_maxs.diminfo[0].strides)));
                  if (__pyx_t_12) {

     108:                                     maxs[0] = i

                    /* "xutils.pyx":108
     *                                     mins[0] = i
     *                                 if i > maxs[0]:
     *                                     maxs[0] = i             # <<<<<<<<<<<<<<
     *                                 if j < mins[1]:
     *                                     mins[1] = i
     */
                    __pyx_t_56 = 0;
                    __pyx_t_9 = -1;
                    if (__pyx_t_56 < 0) {
                      __pyx_t_56 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                      if (unlikely(__pyx_t_56 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_56 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_56, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L40;
                  }
                  __pyx_L40:;

     109:                                 if j < mins[1]:

                  /* "xutils.pyx":109
     *                                 if i > maxs[0]:
     *                                     maxs[0] = i
     *                                 if j < mins[1]:             # <<<<<<<<<<<<<<
     *                                     mins[1] = i
     *                                 if j > maxs[1]:
     */
                  __pyx_t_57 = 1;
                  __pyx_t_9 = -1;
                  if (__pyx_t_57 < 0) {
                    __pyx_t_57 += __pyx_pybuffernd_mins.diminfo[0].shape;
                    if (unlikely(__pyx_t_57 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_57 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_j < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_57, __pyx_pybuffernd_mins.diminfo[0].strides)));
                  if (__pyx_t_12) {

     110:                                     mins[1] = i

                    /* "xutils.pyx":110
     *                                     maxs[0] = i
     *                                 if j < mins[1]:
     *                                     mins[1] = i             # <<<<<<<<<<<<<<
     *                                 if j > maxs[1]:
     *                                     maxs[1] = i
     */
                    __pyx_t_58 = 1;
                    __pyx_t_9 = -1;
                    if (__pyx_t_58 < 0) {
                      __pyx_t_58 += __pyx_pybuffernd_mins.diminfo[0].shape;
                      if (unlikely(__pyx_t_58 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_58 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_58, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L41;
                  }
                  __pyx_L41:;

     111:                                 if j > maxs[1]:

                  /* "xutils.pyx":111
     *                                 if j < mins[1]:
     *                                     mins[1] = i
     *                                 if j > maxs[1]:             # <<<<<<<<<<<<<<
     *                                     maxs[1] = i
     *                                 if k < mins[2]:
     */
                  __pyx_t_59 = 1;
                  __pyx_t_9 = -1;
                  if (__pyx_t_59 < 0) {
                    __pyx_t_59 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                    if (unlikely(__pyx_t_59 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_59 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_j > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_59, __pyx_pybuffernd_maxs.diminfo[0].strides)));
                  if (__pyx_t_12) {

     112:                                     maxs[1] = i

                    /* "xutils.pyx":112
     *                                     mins[1] = i
     *                                 if j > maxs[1]:
     *                                     maxs[1] = i             # <<<<<<<<<<<<<<
     *                                 if k < mins[2]:
     *                                     mins[2] = i
     */
                    __pyx_t_60 = 1;
                    __pyx_t_9 = -1;
                    if (__pyx_t_60 < 0) {
                      __pyx_t_60 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                      if (unlikely(__pyx_t_60 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_60 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_60, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L42;
                  }
                  __pyx_L42:;

     113:                                 if k < mins[2]:

                  /* "xutils.pyx":113
     *                                 if j > maxs[1]:
     *                                     maxs[1] = i
     *                                 if k < mins[2]:             # <<<<<<<<<<<<<<
     *                                     mins[2] = i
     *                                 if k > maxs[2]:
     */
                  __pyx_t_61 = 2;
                  __pyx_t_9 = -1;
                  if (__pyx_t_61 < 0) {
                    __pyx_t_61 += __pyx_pybuffernd_mins.diminfo[0].shape;
                    if (unlikely(__pyx_t_61 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_61 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_k < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_61, __pyx_pybuffernd_mins.diminfo[0].strides)));
                  if (__pyx_t_12) {

     114:                                     mins[2] = i

                    /* "xutils.pyx":114
     *                                     maxs[1] = i
     *                                 if k < mins[2]:
     *                                     mins[2] = i             # <<<<<<<<<<<<<<
     *                                 if k > maxs[2]:
     *                                     maxs[2] = i
     */
                    __pyx_t_62 = 2;
                    __pyx_t_9 = -1;
                    if (__pyx_t_62 < 0) {
                      __pyx_t_62 += __pyx_pybuffernd_mins.diminfo[0].shape;
                      if (unlikely(__pyx_t_62 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_62 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_62, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L43;
                  }
                  __pyx_L43:;

     115:                                 if k > maxs[2]:

                  /* "xutils.pyx":115
     *                                 if k < mins[2]:
     *                                     mins[2] = i
     *                                 if k > maxs[2]:             # <<<<<<<<<<<<<<
     *                                     maxs[2] = i
     *                                 if l < mins[3]:
     */
                  __pyx_t_63 = 2;
                  __pyx_t_9 = -1;
                  if (__pyx_t_63 < 0) {
                    __pyx_t_63 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                    if (unlikely(__pyx_t_63 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_63 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_k > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_63, __pyx_pybuffernd_maxs.diminfo[0].strides)));
                  if (__pyx_t_12) {

     116:                                     maxs[2] = i

                    /* "xutils.pyx":116
     *                                     mins[2] = i
     *                                 if k > maxs[2]:
     *                                     maxs[2] = i             # <<<<<<<<<<<<<<
     *                                 if l < mins[3]:
     *                                     mins[3] = i
     */
                    __pyx_t_64 = 2;
                    __pyx_t_9 = -1;
                    if (__pyx_t_64 < 0) {
                      __pyx_t_64 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                      if (unlikely(__pyx_t_64 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_64 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_64, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L44;
                  }
                  __pyx_L44:;

     117:                                 if l < mins[3]:

                  /* "xutils.pyx":117
     *                                 if k > maxs[2]:
     *                                     maxs[2] = i
     *                                 if l < mins[3]:             # <<<<<<<<<<<<<<
     *                                     mins[3] = i
     *                                 if l > maxs[3]:
     */
                  __pyx_t_65 = 3;
                  __pyx_t_9 = -1;
                  if (__pyx_t_65 < 0) {
                    __pyx_t_65 += __pyx_pybuffernd_mins.diminfo[0].shape;
                    if (unlikely(__pyx_t_65 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_65 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_l < (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_65, __pyx_pybuffernd_mins.diminfo[0].strides)));
                  if (__pyx_t_12) {

     118:                                     mins[3] = i

                    /* "xutils.pyx":118
     *                                     maxs[2] = i
     *                                 if l < mins[3]:
     *                                     mins[3] = i             # <<<<<<<<<<<<<<
     *                                 if l > maxs[3]:
     *                                     maxs[3] = i
     */
                    __pyx_t_66 = 3;
                    __pyx_t_9 = -1;
                    if (__pyx_t_66 < 0) {
                      __pyx_t_66 += __pyx_pybuffernd_mins.diminfo[0].shape;
                      if (unlikely(__pyx_t_66 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_66 >= __pyx_pybuffernd_mins.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_mins.rcbuffer->pybuffer.buf, __pyx_t_66, __pyx_pybuffernd_mins.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L45;
                  }
                  __pyx_L45:;

     119:                                 if l > maxs[3]:

                  /* "xutils.pyx":119
     *                                 if l < mins[3]:
     *                                     mins[3] = i
     *                                 if l > maxs[3]:             # <<<<<<<<<<<<<<
     *                                     maxs[3] = i
     *     else:
     */
                  __pyx_t_67 = 3;
                  __pyx_t_9 = -1;
                  if (__pyx_t_67 < 0) {
                    __pyx_t_67 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                    if (unlikely(__pyx_t_67 < 0)) __pyx_t_9 = 0;
                  } else if (unlikely(__pyx_t_67 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                  if (unlikely(__pyx_t_9 != -1)) {
                    __Pyx_RaiseBufferIndexError(__pyx_t_9);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  }
                  __pyx_t_12 = (__pyx_v_l > (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_67, __pyx_pybuffernd_maxs.diminfo[0].strides)));
                  if (__pyx_t_12) {

     120:                                     maxs[3] = i

                    /* "xutils.pyx":120
     *                                     mins[3] = i
     *                                 if l > maxs[3]:
     *                                     maxs[3] = i             # <<<<<<<<<<<<<<
     *     else:
     *         raise RuntimeError("Dimensions > 4 not implemented")
     */
                    __pyx_t_68 = 3;
                    __pyx_t_9 = -1;
                    if (__pyx_t_68 < 0) {
                      __pyx_t_68 += __pyx_pybuffernd_maxs.diminfo[0].shape;
                      if (unlikely(__pyx_t_68 < 0)) __pyx_t_9 = 0;
                    } else if (unlikely(__pyx_t_68 >= __pyx_pybuffernd_maxs.diminfo[0].shape)) __pyx_t_9 = 0;
                    if (unlikely(__pyx_t_9 != -1)) {
                      __Pyx_RaiseBufferIndexError(__pyx_t_9);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    }
                    *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_maxs.rcbuffer->pybuffer.buf, __pyx_t_68, __pyx_pybuffernd_maxs.diminfo[0].strides) = __pyx_v_i;
                    goto __pyx_L46;
                  }
                  __pyx_L46:;
                  goto __pyx_L38;
                }
                __pyx_L38:;
              }
            }
          }
        }
        break;
        default:

     121:     else:

     122:         raise RuntimeError("Dimensions > 4 not implemented")

        /* "xutils.pyx":122
     *                                     maxs[3] = i
     *     else:
     *         raise RuntimeError("Dimensions > 4 not implemented")             # <<<<<<<<<<<<<<
     *     return tuple(mins) + tuple(maxs)
     *
     */
        __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }

      /* "xutils.pyx":122
     *                                     maxs[3] = i
     *     else:
     *         raise RuntimeError("Dimensions > 4 not implemented")             # <<<<<<<<<<<<<<
     *     return tuple(mins) + tuple(maxs)
     *
     */
      __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_k_tuple_2);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
      PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
      __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));

     123:     return tuple(mins) + tuple(maxs)

      /* "xutils.pyx":123
     *     else:
     *         raise RuntimeError("Dimensions > 4 not implemented")
     *     return tuple(mins) + tuple(maxs)             # <<<<<<<<<<<<<<
     *
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_mins));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_mins));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_mins));
      __pyx_t_52 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_52);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_maxs));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_maxs));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_maxs));
      __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Add(__pyx_t_52, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = ((PyObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L0;

      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_XDECREF(__pyx_t_52);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxs.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mins.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_shape.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("xutils.boundingBox", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_maxs.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mins.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_shape.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_shape);
      __Pyx_XDECREF((PyObject *)__pyx_v_mins);
      __Pyx_XDECREF((PyObject *)__pyx_v_maxs);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
    static int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
      __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     124: