diff --git a/sklearn/linear_model/least_angle.py b/sklearn/linear_model/least_angle.py
index 6b79659d2da7490f59e08b8e180f1789f10891ce..9cfa313371d02ce2a1cbf972942da63c49f3d685 100644
--- a/sklearn/linear_model/least_angle.py
+++ b/sklearn/linear_model/least_angle.py
@@ -489,7 +489,7 @@ class LassoLars(Lars):
     LassoLars(alpha=0.01, eps=..., fit_intercept=True,
          max_iter=500, normalize=True, overwrite_X=False, precompute='auto',
          verbose=False)
-    >>> print clf.coef_ # doctest: +ELLIPSIS
+    >>> print clf.coef_ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
     [ 0.         -0.963257...]
 
     References
diff --git a/sklearn/neighbors/ball_tree.c b/sklearn/neighbors/ball_tree.c
index 4dcc80dc696efe0749c3c227d072ed99408860de..93a4ab7f47824aba5088179547d1eb072ee7b563 100644
--- a/sklearn/neighbors/ball_tree.c
+++ b/sklearn/neighbors/ball_tree.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.14.1 on Mon Sep  5 21:05:24 2011 */
+/* Generated by Cython 0.15 on Mon Sep 19 16:05:30 2011 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -46,7 +46,7 @@
   #define PY_SSIZE_T_MIN INT_MIN
   #define PY_FORMAT_SIZE_T ""
   #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
-  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
+  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
   #define PyNumber_Index(o)    PyNumber_Int(o)
   #define PyIndex_Check(o)     PyNumber_Check(o)
   #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
@@ -159,6 +159,15 @@
   #define PyBoolObject                 PyLongObject
 #endif
 
+#if PY_VERSION_HEX < 0x03020000
+  typedef long Py_hash_t;
+  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
+#else
+  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
+#endif
+
 
 #if PY_MAJOR_VERSION >= 3
   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
@@ -209,21 +218,27 @@
   #define __Pyx_DOCSTR(n)  (n)
 #endif
 
-#ifdef __cplusplus
-#define __PYX_EXTERN_C extern "C"
-#else
-#define __PYX_EXTERN_C extern
+#ifndef __PYX_EXTERN_C
+  #ifdef __cplusplus
+    #define __PYX_EXTERN_C extern "C"
+  #else
+    #define __PYX_EXTERN_C extern
+  #endif
 #endif
 
 #if defined(WIN32) || defined(MS_WINDOWS)
 #define _USE_MATH_DEFINES
 #endif
 #include <math.h>
+#define __PYX_HAVE__sklearn__neighbors__ball_tree
 #define __PYX_HAVE_API__sklearn__neighbors__ball_tree
 #include "stdio.h"
 #include "stdlib.h"
 #include "numpy/arrayobject.h"
 #include "numpy/ufuncobject.h"
+#ifdef _OPENMP
+#include <omp.h>
+#endif /* _OPENMP */
 
 #ifdef PYREX_WITHOUT_ASSERTIONS
 #define CYTHON_WITHOUT_ASSERTIONS
@@ -266,6 +281,7 @@ typedef struct {PyObject **p; char *s; const long n; const char* encoding; const
 #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
 #define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
 
+#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
@@ -278,17 +294,17 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
 
 
 #ifdef __GNUC__
-/* Test for GCC > 2.95 */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
-#define likely(x)   __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* __GNUC__ > 2 ... */
-#define likely(x)   (x)
-#define unlikely(x) (x)
-#endif /* __GNUC__ > 2 ... */
+  /* Test for GCC > 2.95 */
+  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
+    #define likely(x)   __builtin_expect(!!(x), 1)
+    #define unlikely(x) __builtin_expect(!!(x), 0)
+  #else /* __GNUC__ > 2 ... */
+    #define likely(x)   (x)
+    #define unlikely(x) (x)
+  #endif /* __GNUC__ > 2 ... */
 #else /* __GNUC__ */
-#define likely(x)   (x)
-#define unlikely(x) (x)
+  #define likely(x)   (x)
+  #define unlikely(x) (x)
 #endif /* __GNUC__ */
     
 static PyObject *__pyx_m;
@@ -329,46 +345,211 @@ static const char *__pyx_f[] = {
   "numpy.pxd",
 };
 
+/* "numpy.pxd":719
+ * # in Cython to enable them only on the right systems.
+ * 
+ * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_int16      int16_t
+ * ctypedef npy_int32      int32_t
+ */
 typedef npy_int8 __pyx_t_5numpy_int8_t;
 
+/* "numpy.pxd":720
+ * 
+ * ctypedef npy_int8       int8_t
+ * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_int32      int32_t
+ * ctypedef npy_int64      int64_t
+ */
 typedef npy_int16 __pyx_t_5numpy_int16_t;
 
+/* "numpy.pxd":721
+ * ctypedef npy_int8       int8_t
+ * ctypedef npy_int16      int16_t
+ * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_int64      int64_t
+ * #ctypedef npy_int96      int96_t
+ */
 typedef npy_int32 __pyx_t_5numpy_int32_t;
 
+/* "numpy.pxd":722
+ * ctypedef npy_int16      int16_t
+ * ctypedef npy_int32      int32_t
+ * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
+ * #ctypedef npy_int96      int96_t
+ * #ctypedef npy_int128     int128_t
+ */
 typedef npy_int64 __pyx_t_5numpy_int64_t;
 
+/* "numpy.pxd":726
+ * #ctypedef npy_int128     int128_t
+ * 
+ * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_uint16     uint16_t
+ * ctypedef npy_uint32     uint32_t
+ */
 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
 
+/* "numpy.pxd":727
+ * 
+ * ctypedef npy_uint8      uint8_t
+ * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_uint32     uint32_t
+ * ctypedef npy_uint64     uint64_t
+ */
 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
 
+/* "numpy.pxd":728
+ * ctypedef npy_uint8      uint8_t
+ * ctypedef npy_uint16     uint16_t
+ * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_uint64     uint64_t
+ * #ctypedef npy_uint96     uint96_t
+ */
 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
 
+/* "numpy.pxd":729
+ * ctypedef npy_uint16     uint16_t
+ * ctypedef npy_uint32     uint32_t
+ * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
+ * #ctypedef npy_uint96     uint96_t
+ * #ctypedef npy_uint128    uint128_t
+ */
 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
 
+/* "numpy.pxd":733
+ * #ctypedef npy_uint128    uint128_t
+ * 
+ * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_float64    float64_t
+ * #ctypedef npy_float80    float80_t
+ */
 typedef npy_float32 __pyx_t_5numpy_float32_t;
 
+/* "numpy.pxd":734
+ * 
+ * ctypedef npy_float32    float32_t
+ * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
+ * #ctypedef npy_float80    float80_t
+ * #ctypedef npy_float128   float128_t
+ */
 typedef npy_float64 __pyx_t_5numpy_float64_t;
 
+/* "numpy.pxd":743
+ * # The int types are mapped a bit surprising --
+ * # numpy.int corresponds to 'l' and numpy.long to 'q'
+ * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_longlong   long_t
+ * ctypedef npy_longlong   longlong_t
+ */
 typedef npy_long __pyx_t_5numpy_int_t;
 
+/* "numpy.pxd":744
+ * # numpy.int corresponds to 'l' and numpy.long to 'q'
+ * ctypedef npy_long       int_t
+ * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_longlong   longlong_t
+ * 
+ */
 typedef npy_longlong __pyx_t_5numpy_long_t;
 
-typedef npy_intp __pyx_t_5numpy_intp_t;
-
-typedef npy_uintp __pyx_t_5numpy_uintp_t;
+/* "numpy.pxd":745
+ * ctypedef npy_long       int_t
+ * ctypedef npy_longlong   long_t
+ * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
+ * 
+ * ctypedef npy_ulong      uint_t
+ */
+typedef npy_longlong __pyx_t_5numpy_longlong_t;
 
+/* "numpy.pxd":747
+ * ctypedef npy_longlong   longlong_t
+ * 
+ * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_ulonglong  ulong_t
+ * ctypedef npy_ulonglong  ulonglong_t
+ */
 typedef npy_ulong __pyx_t_5numpy_uint_t;
 
+/* "numpy.pxd":748
+ * 
+ * ctypedef npy_ulong      uint_t
+ * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_ulonglong  ulonglong_t
+ * 
+ */
 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
 
+/* "numpy.pxd":749
+ * ctypedef npy_ulong      uint_t
+ * ctypedef npy_ulonglong  ulong_t
+ * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
+ * 
+ * ctypedef npy_intp       intp_t
+ */
+typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
+
+/* "numpy.pxd":751
+ * ctypedef npy_ulonglong  ulonglong_t
+ * 
+ * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_uintp      uintp_t
+ * 
+ */
+typedef npy_intp __pyx_t_5numpy_intp_t;
+
+/* "numpy.pxd":752
+ * 
+ * ctypedef npy_intp       intp_t
+ * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
+ * 
+ * ctypedef npy_double     float_t
+ */
+typedef npy_uintp __pyx_t_5numpy_uintp_t;
+
+/* "numpy.pxd":754
+ * ctypedef npy_uintp      uintp_t
+ * 
+ * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_double     double_t
+ * ctypedef npy_longdouble longdouble_t
+ */
 typedef npy_double __pyx_t_5numpy_float_t;
 
+/* "numpy.pxd":755
+ * 
+ * ctypedef npy_double     float_t
+ * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_longdouble longdouble_t
+ * 
+ */
 typedef npy_double __pyx_t_5numpy_double_t;
 
+/* "numpy.pxd":756
+ * ctypedef npy_double     float_t
+ * ctypedef npy_double     double_t
+ * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
+ * 
+ * ctypedef npy_cfloat      cfloat_t
+ */
 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
 
+/* "sklearn/neighbors/ball_tree.pyx":201
+ * # type used for data
+ * DTYPE = np.float64
+ * ctypedef np.float64_t DTYPE_t             # <<<<<<<<<<<<<<
+ * 
+ * # type used for indices & counts
+ */
 typedef __pyx_t_5numpy_float64_t __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t;
 
+/* "sklearn/neighbors/ball_tree.pyx":205
+ * # type used for indices & counts
+ * ITYPE = np.int32
+ * ctypedef np.int32_t ITYPE_t             # <<<<<<<<<<<<<<
+ * 
+ * # infinity
+ */
 typedef __pyx_t_5numpy_int32_t __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t;
 
 #if CYTHON_CCOMPLEX
@@ -391,15 +572,47 @@ typedef __pyx_t_5numpy_int32_t __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t;
     typedef struct { double real, imag; } __pyx_t_double_complex;
 #endif
 
-/* Type declarations */
+/*--- Type declarations ---*/
+struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree;
 
+/* "numpy.pxd":758
+ * ctypedef npy_longdouble longdouble_t
+ * 
+ * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_cdouble     cdouble_t
+ * ctypedef npy_clongdouble clongdouble_t
+ */
 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
 
+/* "numpy.pxd":759
+ * 
+ * ctypedef npy_cfloat      cfloat_t
+ * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
+ * ctypedef npy_clongdouble clongdouble_t
+ * 
+ */
 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
 
+/* "numpy.pxd":760
+ * ctypedef npy_cfloat      cfloat_t
+ * ctypedef npy_cdouble     cdouble_t
+ * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
+ * 
+ * ctypedef npy_cdouble     complex_t
+ */
 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
 
+/* "numpy.pxd":762
+ * ctypedef npy_clongdouble clongdouble_t
+ * 
+ * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
+ * 
+ * cdef inline object PyArray_MultiIterNew1(a):
+ */
 typedef npy_cdouble __pyx_t_5numpy_complex_t;
+struct __pyx_t_7sklearn_9neighbors_9ball_tree_NodeInfo;
+struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item;
+struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack;
 
 /* "sklearn/neighbors/ball_tree.pyx":323
  * #  array for efficiency.  This is a hybrid of the "Array of Structures"
@@ -408,7 +621,6 @@ typedef npy_cdouble __pyx_t_5numpy_complex_t;
  *     ITYPE_t idx_start
  *     ITYPE_t idx_end
  */
-
 struct __pyx_t_7sklearn_9neighbors_9ball_tree_NodeInfo {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t idx_start;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t idx_end;
@@ -423,7 +635,6 @@ struct __pyx_t_7sklearn_9neighbors_9ball_tree_NodeInfo {
  *     ITYPE_t i_node
  *     DTYPE_t dist_p_LB
  */
-
 struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t i_node;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t dist_p_LB;
@@ -436,7 +647,6 @@ struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item {
  *     int n
  *     stack_item* heap
  */
-
 struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack {
   int n;
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item *heap;
@@ -450,7 +660,6 @@ struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack {
  *     """
  *     Ball Tree for fast nearest-neighbor searches :
  */
-
 struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree {
   PyObject_HEAD
   struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_vtab;
@@ -465,6 +674,7 @@ struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree {
 };
 
 
+
 struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree {
   void (*build_tree_)(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *);
   void (*query_one_)(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t);
@@ -474,6 +684,7 @@ struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree {
 };
 static struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_vtabptr_7sklearn_9neighbors_9ball_tree_BallTree;
 
+
 #ifndef CYTHON_REFNANNY
   #define CYTHON_REFNANNY 0
 #endif
@@ -488,44 +699,38 @@ static struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_vt
     void (*FinishContext)(void**);
   } __Pyx_RefNannyAPIStruct;
   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
-  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
-    PyObject *m = NULL, *p = NULL;
-    void *r = NULL;
-    m = PyImport_ImportModule((char *)modname);
-    if (!m) goto end;
-    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
-    if (!p) goto end;
-    r = PyLong_AsVoidPtr(p);
-  end:
-    Py_XDECREF(p);
-    Py_XDECREF(m);
-    return (__Pyx_RefNannyAPIStruct *)r;
-  }
-  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
+  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
+  #define __Pyx_RefNannySetupContext(name)           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
   #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
-  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
-  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
-  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
-  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
+  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
+  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
+  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
+  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
 #else
+  #define __Pyx_RefNannyDeclarations
   #define __Pyx_RefNannySetupContext(name)
   #define __Pyx_RefNannyFinishContext()
   #define __Pyx_INCREF(r) Py_INCREF(r)
   #define __Pyx_DECREF(r) Py_DECREF(r)
   #define __Pyx_GOTREF(r)
   #define __Pyx_GIVEREF(r)
+  #define __Pyx_XINCREF(r) Py_XINCREF(r)
   #define __Pyx_XDECREF(r) Py_XDECREF(r)
+  #define __Pyx_XGOTREF(r)
+  #define __Pyx_XGIVEREF(r)
 #endif /* CYTHON_REFNANNY */
-#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
-#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
 
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
 
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
 
 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
@@ -542,7 +747,7 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],
 
 static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */
 
-#define UNARY_NEG_WOULD_OVERFLOW(x)		(((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
+#define UNARY_NEG_WOULD_OVERFLOW(x)            (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
 
 
 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
@@ -618,15 +823,17 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i)
     return r;
 }
 
-static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
+static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
 
 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
 
 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
 
+static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
+
 static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/
 
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
 
 static CYTHON_INLINE npy_int32 __Pyx_PyInt_from_py_npy_int32(PyObject *);
 
@@ -767,31 +974,35 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
 
 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
 
-static void __Pyx_WriteUnraisable(const char *name); /*proto*/
+static void __Pyx_WriteUnraisable(const char *name, int clineno,
+                                  int lineno, const char *filename); /*proto*/
+
+static int __Pyx_check_binary_version(void);
 
 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
 
-static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/
 
 static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
 
-static void __Pyx_AddTraceback(const char *funcname); /*proto*/
+static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
+                               int __pyx_lineno, const char *__pyx_filename); /*proto*/
 
 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
-/* Module declarations from cpython.buffer */
 
-/* Module declarations from cpython.ref */
+/* Module declarations from 'cpython.buffer' */
 
-/* Module declarations from libc.stdio */
+/* Module declarations from 'cpython.ref' */
 
-/* Module declarations from cpython.object */
+/* Module declarations from 'libc.stdio' */
 
-/* Module declarations from libc.stdlib */
+/* Module declarations from 'cpython.object' */
 
-/* Module declarations from numpy */
+/* Module declarations from 'libc.stdlib' */
 
-/* Module declarations from numpy */
+/* Module declarations from 'numpy' */
 
+/* Module declarations from 'numpy' */
 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
@@ -805,12 +1016,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *,
 static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *, PyObject *); /*proto*/
 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *); /*proto*/
-/* Module declarations from cython */
 
-/* Module declarations from libc */
+/* Module declarations from 'cython.cython.view' */
 
-/* Module declarations from sklearn.neighbors.ball_tree */
+/* Module declarations from 'cython' */
 
+/* Module declarations from 'libc' */
+
+/* Module declarations from 'sklearn.neighbors.ball_tree' */
 static PyTypeObject *__pyx_ptype_7sklearn_9neighbors_9ball_tree_BallTree = 0;
 static __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_7sklearn_9neighbors_9ball_tree_infinity;
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dmax(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t); /*proto*/
@@ -840,9 +1053,9 @@ static void __pyx_f_7sklearn_9neighbors_9ball_tree_max_heap_insert(__pyx_t_7skle
 static void __pyx_f_7sklearn_9neighbors_9ball_tree_sort_dist_idx(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t); /*proto*/
 static __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_partition_dist_idx(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t); /*proto*/
 #define __Pyx_MODULE_NAME "sklearn.neighbors.ball_tree"
-static int __pyx_module_is_main_sklearn__neighbors__ball_tree = 0;
+int __pyx_module_is_main_sklearn__neighbors__ball_tree = 0;
 
-/* Implementation of sklearn.neighbors.ball_tree */
+/* Implementation of 'sklearn.neighbors.ball_tree' */
 static PyObject *__pyx_builtin_ValueError;
 static PyObject *__pyx_builtin_enumerate;
 static PyObject *__pyx_builtin_range;
@@ -858,22 +1071,20 @@ static char __pyx_k_22[] = "k must be less than or equal to the number of traini
 static char __pyx_k_27[] = "count_only and return_distance cannot both be true";
 static char __pyx_k_29[] = "return_distance must be True if sort_distances is True";
 static char __pyx_k_33[] = "r must be broadcastable to X.shape";
-static char __pyx_k_36[] = "query_radius_idx_only_";
-static char __pyx_k_37[] = "query_radius_distances_";
-static char __pyx_k_38[] = "Fatal: parent is a leaf. Memory allocation is flawed";
-static char __pyx_k_40[] = "zero-sized node";
-static char __pyx_k_42[] = "ndarray is not C contiguous";
-static char __pyx_k_44[] = "ndarray is not Fortran contiguous";
-static char __pyx_k_46[] = "Non-native byte order not supported";
-static char __pyx_k_48[] = "unknown dtype code in numpy.pxd (%d)";
-static char __pyx_k_49[] = "Format string allocated too short, see comment in numpy.pxd";
-static char __pyx_k_52[] = "Format string allocated too short.";
-static char __pyx_k_54[] = "\n=========\nBall Tree\n=========\nA ball tree is a data object which speeds up nearest neighbor\nsearches in high dimensions (see scikit-learn neighbors module\ndocumentation for an overview of neighbor trees). There are many\ntypes of ball trees.  This package provides a basic implementation\nin cython.\n\nImplementation Notes\n--------------------\n\nA ball tree can be thought of as a collection of nodes.  Each node\nstores a centroid, a radius, and the pointers to two child nodes.\n\n* centroid : the centroid of a node is the mean of all the locations\n    of points within the node\n* radius : the radius of a node is the distance from the centroid\n    to the furthest point in the node.\n* subnodes : each node has a maximum of 2 child nodes.  The data within\n    the parent node is divided between the two child nodes.\n\nIn a typical tree implementation, nodes may be classes or structures which\nare dynamically allocated as needed.  This offers flexibility in the number\nof nodes, and leads to very straightforward and readable code.  It also means\nthat the tree can be dynamically augmented or pruned with new data, in an\nin-line fashion.  This approach generally leads to recursive code: upon\nconstruction, the head node constructs its child nodes, the child nodes\nconstruct their child nodes, and so-on.\n\nThe current package uses a different approach: all node data is stored in\na set of numpy arrays which are pre-allocated.  The main advantage of this\napproach is that the whole object can be quickly and easily saved to disk\nand reconstructed from disk.  This also allows for an iterative interface\nwhich gives more control over the heap, and leads to speed.  There are a\nfew disadvantages, however: once the tree is built, augmenting or pruning it\nis not as straightforward.  Also, the size of the tree must be known from the\nstart, so there is not as much flexibility in building it.\n\nBallTree Pseudo-code\n~~~~~~~~~~~~~~~~~~~~\nBecause understanding a ball ""tree is simpler with recursive code, here is some\npseudo-code to show the structure of the main functionality\n\n    # Ball Tree pseudo code\n\n    class Node:\n        #class data:\n        centroid\n        radius\n        child1, child2\n\n        #class methods:\n        def construct(data):\n            centroid = compute_centroid(data)\n            radius = compute_radius(centroid, data)\n\n            # Divide the data into two approximately equal sets.\n            # This is often done by splitting along a single dimension.\n            data1, data2 = divide(data)\n\n            if number_of_points(data1) > 0:\n                child1.construct(data1)\n\n            if number_of_points(data2) > 0:\n                child2.construct(data2)\n\n        def query(pt, neighbors_heap):\n            # compute the minimum distance from pt to any point in this node\n            d = distance(point, centroid)\n            if d < radius:\n                min_distance = 0\n            else:\n                min_distance = d - radius\n\n            if min_distance > max_distance_in(neighbors_heap):\n                # all these points are too far away.  cut off the search here\n                return\n            elif node_size > 1:\n                child1.query(pt, neighbors_heap)\n                child2.query(pt, neighbors_heap)\n\n\n    object BallTree:\n        #class data:\n        data\n        root_node\n\n        #class methods\n        def construct(data, num_leaves):\n            root_node.construct(data)\n\n        def query(point, num_neighbors):\n            neighbors_heap = empty_heap_of_size(num_neighbors)\n            root_node.query(point, neighbors_heap)\n\nThis certainly is not a complete description, but should give the basic idea\nof the form of the algorithm.  The implementation below is much faster than\nanything mirroring the pseudo-code above, but for that reason is much more\nopaque.  Here's the basic idea:\n\nBallTree Storage\n~~~~~~~~~~~~~~~~""\nThe BallTree information is stored using a combination of\n\"Array of Structures\" and \"Structure of Arrays\" to maximize speed.\nGiven input data of size ``(n_samples, n_features)``, BallTree computes the\nexpected number of nodes ``n_nodes`` (see below), and allocates the\nfollowing arrays:\n\n* ``data`` : a float array of shape ``(n_samples, n_features)``\n    This is simply the input data.  If the input matrix is well-formed\n    (contiguous, c-ordered, correct data type) then no copy is needed\n* ``idx_array`` : an integer array of size ``n_samples``\n    This can be thought of as an array of pointers to the data in ``data``.\n    Rather than shuffling around the data itself, we shuffle around pointers\n    to the rows in data.\n* ``node_centroid_arr`` : a float array of shape ``(n_nodes, n_features)``\n    This stores the centroid of the data in each node.\n* ``node_info_arr`` : a size-``n_nodes`` array of ``NodeInfo`` structures.\n    This stores information associated with each node.  Each ``NodeInfo``\n    instance has the following attributes:\n    - ``idx_start``\n    - ``idx_end`` : ``idx_start`` and ``idx_end`` reference the part of\n      ``idx_array`` which point to the data associated with the node.\n      The data in node with index ``i_node`` is given by\n      ``data[idx_array[idx_start:idx_end]]``\n    - ``is_leaf`` : a boolean value which tells whether this node is a leaf:\n      that is, whether or not it has children.\n    - ``radius`` : a floating-point value which gives the distance from\n      the node centroid to the furthest point in the node.\n\nOne feature here is that there are no stored pointers from parent nodes to\nchild nodes and vice-versa.  These pointers are implemented implicitly:\nFor a node with index ``i``, the two children are found at indices\n``2 * i + 1`` and ``2 * i + 2``, while the parent is found at index\n``floor((i - 1) / 2)``.  The root node has no parent.\n\nWith this data structure in place, the functionality ""of the above BallTree\npseudo-code can be implemented in a much more efficient manner.\nMost of the data passing done in this code uses raw data pointers.\nUsing numpy arrays would be preferable for safety, but the\noverhead of array slicing and sub-array construction leads to execution\ntime which is several orders of magnitude slower than the current\nimplementation.\n\nPriority Queue vs Max-heap\n~~~~~~~~~~~~~~~~~~~~~~~~~~\nWhen querying for more than one neighbor, the code must maintain a list of\nthe current k nearest points.  The BallTree code implements this in two ways.\n\n- A priority queue: this is just a sorted list.  When an item is added,\n  it is inserted in the appropriate location.  The cost of the search plus\n  insert averages O[k].\n- A max-heap: this is a binary tree structure arranged such that each node is\n  greater than its children.  The cost of adding an item is O[log(k)].\n  At the end of the iterations, the results must be sorted: a quicksort is\n  used, which averages O[k log(k)].  Quicksort has worst-case O[k^2]\n  performance, but because the input is already structured in a max-heap,\n  the worst case will not be realized.  Thus the sort is a one-time operation\n  with cost O[k log(k)].\n\nEach insert is performed an average of log(N) times per query, where N is\nthe number of training points.  Because of this, for a single query, the\npriority-queue approach costs O[k log(N)], and the max-heap approach costs\nO[log(k)log(N)] + O[k log(k)].  Tests show that for sufficiently large k,\nthe max-heap approach out-performs the priority queue approach by a factor\nof a few.  In light of these tests, the code uses a priority queue for\nk < 5, and a max-heap otherwise.\n\nMemory Allocation\n~~~~~~~~~~~~~~~~~\nIt is desirable to construct a tree in as balanced a way as possible.\nGiven a training set with n_samples and a user-supplied leaf_size, if\nthe points in each node are divided as evenly as possible between the\ntwo children, the maximu""m depth needed so that leaf nodes satisfy\n``leaf_size <= n_points <= 2 * leaf_size`` is given by\n``n_levels = 1 + max(0, floor(log2((n_samples - 1) / leaf_size)))``\n(with the exception of the special case where ``n_samples < leaf_size``)\nFor a given number of levels, the number of points in a tree is given by\n``n_nodes = 2 ** n_levels - 1``.  Both of these results can be shown\nby induction.  Using them, the correct amount of memory can be pre-allocated\nfor a given ``n_samples`` and ``leaf_size``.\n";
-static char __pyx_k_55[] = "sklearn.neighbors.ball_tree";
-static char __pyx_k_56[] = "BallTree.query (line 544)";
-static char __pyx_k_57[] = "\n        query(X, k=1, return_distance=True)\n\n        query the Ball Tree for the k nearest neighbors\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        k : integer  (default = 1)\n            The number of nearest neighbors to return\n        return_distance : boolean (default = True)\n            if True, return a tuple (d,i)\n            if False, return array i\n\n        Returns\n        -------\n        i    : if return_distance == False\n        (d,i) : if return_distance == True\n\n        d : array of doubles - shape: x.shape[:-1] + (k,)\n            each entry gives the list of distances to the\n            neighbors of the corresponding point\n            (note that distances are not sorted)\n\n        i : array of integers - shape: x.shape[:-1] + (k,)\n            each entry gives the list of indices of\n            neighbors of the corresponding point\n            (note that neighbors are not sorted)\n\n        Examples\n        --------\n        Query for k-nearest neighbors\n\n            >>> import numpy as np\n            >>> np.random.seed(0)\n            >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            >>> ball_tree = BallTree(X, leaf_size=2)\n            >>> dist, ind = ball_tree.query(X[0], k=3)\n            >>> print ind  # indices of 3 closest neighbors\n            [0 3 1]\n            >>> print dist  # distances to 3 closest neighbors\n            [ 0.          0.19662693  0.29473397]\n        ";
-static char __pyx_k_58[] = "BallTree.query_radius (line 644)";
-static char __pyx_k_59[] = "\n        query_radius(self, X, r, count_only = False):\n\n        query the Ball Tree for neighbors within a ball of size r\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        r : distance within which neighbors are returned\n            r can be a single value, or an array of values of shape\n            x.shape[:-1] if different radii are desired for each point.\n        return_distance : boolean (default = False)\n            if True,  return distances to neighbors of each point\n            if False, return only neighbors\n            Note that unlike BallTree.query(), setting return_distance=True\n            adds to the computation time.  Not all distances need to be\n            calculated explicitly for return_distance=False.  Results are\n            not sorted by default: see ``sort_results`` keyword.\n        count_only : boolean (default = False)\n            if True,  return only the count of points within distance r\n            if False, return the indices of all points within distance r\n            If return_distance==True, setting count_only=True will\n            result in an error.\n        sort_results : boolean (default = False)\n            if True, the distances and indices will be sorted before being\n            returned.  If False, the results will not be sorted.  If\n            return_distance == False, settinng sort_results = True will\n            result in an error.\n\n        Returns\n        -------\n        count       : if count_only == True\n        ind         : if count_only == False and return_distance == False\n        (ind, dist) : if count_only == False and return_distance == True\n\n        count : array of integers, shape = X.shape[:-1]\n            each entry gives the number of neighbors within\n            a distance r of the corresponding point.\n\n        ind : array of objects, shape = X.shape[:-1]\n            each element is ""a numpy integer array listing the indices of\n            neighbors of the corresponding point.  Note that unlike\n            the results of BallTree.query(), the returned neighbors\n            are not sorted by distance\n\n        dist : array of objects, shape = X.shape[:-1]\n            each element is a numpy double array\n            listing the distances corresponding to indices in i.\n\n        Examples\n        --------\n        Query for neighbors in a given radius\n\n            >>> import numpy as np\n            >>> np.random.seed(0)\n            >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            >>> ball_tree = BallTree(X, leaf_size=2)\n            >>> print ball_tree.query_radius(X[0], r=0.3, count_only=True)\n            3\n            >>> ind = ball_tree.query_radius(X[0], r=0.3)\n            >>> print ind  # indices of neighbors within distance 0.3\n            [3 0 1]\n        ";
+static char __pyx_k_36[] = "Fatal: parent is a leaf. Memory allocation is flawed";
+static char __pyx_k_38[] = "zero-sized node";
+static char __pyx_k_40[] = "ndarray is not C contiguous";
+static char __pyx_k_42[] = "ndarray is not Fortran contiguous";
+static char __pyx_k_44[] = "Non-native byte order not supported";
+static char __pyx_k_46[] = "unknown dtype code in numpy.pxd (%d)";
+static char __pyx_k_47[] = "Format string allocated too short, see comment in numpy.pxd";
+static char __pyx_k_50[] = "Format string allocated too short.";
+static char __pyx_k_52[] = "\n=========\nBall Tree\n=========\nA ball tree is a data object which speeds up nearest neighbor\nsearches in high dimensions (see scikit-learn neighbors module\ndocumentation for an overview of neighbor trees). There are many\ntypes of ball trees.  This package provides a basic implementation\nin cython.\n\nImplementation Notes\n--------------------\n\nA ball tree can be thought of as a collection of nodes.  Each node\nstores a centroid, a radius, and the pointers to two child nodes.\n\n* centroid : the centroid of a node is the mean of all the locations\n    of points within the node\n* radius : the radius of a node is the distance from the centroid\n    to the furthest point in the node.\n* subnodes : each node has a maximum of 2 child nodes.  The data within\n    the parent node is divided between the two child nodes.\n\nIn a typical tree implementation, nodes may be classes or structures which\nare dynamically allocated as needed.  This offers flexibility in the number\nof nodes, and leads to very straightforward and readable code.  It also means\nthat the tree can be dynamically augmented or pruned with new data, in an\nin-line fashion.  This approach generally leads to recursive code: upon\nconstruction, the head node constructs its child nodes, the child nodes\nconstruct their child nodes, and so-on.\n\nThe current package uses a different approach: all node data is stored in\na set of numpy arrays which are pre-allocated.  The main advantage of this\napproach is that the whole object can be quickly and easily saved to disk\nand reconstructed from disk.  This also allows for an iterative interface\nwhich gives more control over the heap, and leads to speed.  There are a\nfew disadvantages, however: once the tree is built, augmenting or pruning it\nis not as straightforward.  Also, the size of the tree must be known from the\nstart, so there is not as much flexibility in building it.\n\nBallTree Pseudo-code\n~~~~~~~~~~~~~~~~~~~~\nBecause understanding a ball ""tree is simpler with recursive code, here is some\npseudo-code to show the structure of the main functionality\n\n    # Ball Tree pseudo code\n\n    class Node:\n        #class data:\n        centroid\n        radius\n        child1, child2\n\n        #class methods:\n        def construct(data):\n            centroid = compute_centroid(data)\n            radius = compute_radius(centroid, data)\n\n            # Divide the data into two approximately equal sets.\n            # This is often done by splitting along a single dimension.\n            data1, data2 = divide(data)\n\n            if number_of_points(data1) > 0:\n                child1.construct(data1)\n\n            if number_of_points(data2) > 0:\n                child2.construct(data2)\n\n        def query(pt, neighbors_heap):\n            # compute the minimum distance from pt to any point in this node\n            d = distance(point, centroid)\n            if d < radius:\n                min_distance = 0\n            else:\n                min_distance = d - radius\n\n            if min_distance > max_distance_in(neighbors_heap):\n                # all these points are too far away.  cut off the search here\n                return\n            elif node_size > 1:\n                child1.query(pt, neighbors_heap)\n                child2.query(pt, neighbors_heap)\n\n\n    object BallTree:\n        #class data:\n        data\n        root_node\n\n        #class methods\n        def construct(data, num_leaves):\n            root_node.construct(data)\n\n        def query(point, num_neighbors):\n            neighbors_heap = empty_heap_of_size(num_neighbors)\n            root_node.query(point, neighbors_heap)\n\nThis certainly is not a complete description, but should give the basic idea\nof the form of the algorithm.  The implementation below is much faster than\nanything mirroring the pseudo-code above, but for that reason is much more\nopaque.  Here's the basic idea:\n\nBallTree Storage\n~~~~~~~~~~~~~~~~""\nThe BallTree information is stored using a combination of\n\"Array of Structures\" and \"Structure of Arrays\" to maximize speed.\nGiven input data of size ``(n_samples, n_features)``, BallTree computes the\nexpected number of nodes ``n_nodes`` (see below), and allocates the\nfollowing arrays:\n\n* ``data`` : a float array of shape ``(n_samples, n_features)``\n    This is simply the input data.  If the input matrix is well-formed\n    (contiguous, c-ordered, correct data type) then no copy is needed\n* ``idx_array`` : an integer array of size ``n_samples``\n    This can be thought of as an array of pointers to the data in ``data``.\n    Rather than shuffling around the data itself, we shuffle around pointers\n    to the rows in data.\n* ``node_centroid_arr`` : a float array of shape ``(n_nodes, n_features)``\n    This stores the centroid of the data in each node.\n* ``node_info_arr`` : a size-``n_nodes`` array of ``NodeInfo`` structures.\n    This stores information associated with each node.  Each ``NodeInfo``\n    instance has the following attributes:\n    - ``idx_start``\n    - ``idx_end`` : ``idx_start`` and ``idx_end`` reference the part of\n      ``idx_array`` which point to the data associated with the node.\n      The data in node with index ``i_node`` is given by\n      ``data[idx_array[idx_start:idx_end]]``\n    - ``is_leaf`` : a boolean value which tells whether this node is a leaf:\n      that is, whether or not it has children.\n    - ``radius`` : a floating-point value which gives the distance from\n      the node centroid to the furthest point in the node.\n\nOne feature here is that there are no stored pointers from parent nodes to\nchild nodes and vice-versa.  These pointers are implemented implicitly:\nFor a node with index ``i``, the two children are found at indices\n``2 * i + 1`` and ``2 * i + 2``, while the parent is found at index\n``floor((i - 1) / 2)``.  The root node has no parent.\n\nWith this data structure in place, the functionality ""of the above BallTree\npseudo-code can be implemented in a much more efficient manner.\nMost of the data passing done in this code uses raw data pointers.\nUsing numpy arrays would be preferable for safety, but the\noverhead of array slicing and sub-array construction leads to execution\ntime which is several orders of magnitude slower than the current\nimplementation.\n\nPriority Queue vs Max-heap\n~~~~~~~~~~~~~~~~~~~~~~~~~~\nWhen querying for more than one neighbor, the code must maintain a list of\nthe current k nearest points.  The BallTree code implements this in two ways.\n\n- A priority queue: this is just a sorted list.  When an item is added,\n  it is inserted in the appropriate location.  The cost of the search plus\n  insert averages O[k].\n- A max-heap: this is a binary tree structure arranged such that each node is\n  greater than its children.  The cost of adding an item is O[log(k)].\n  At the end of the iterations, the results must be sorted: a quicksort is\n  used, which averages O[k log(k)].  Quicksort has worst-case O[k^2]\n  performance, but because the input is already structured in a max-heap,\n  the worst case will not be realized.  Thus the sort is a one-time operation\n  with cost O[k log(k)].\n\nEach insert is performed an average of log(N) times per query, where N is\nthe number of training points.  Because of this, for a single query, the\npriority-queue approach costs O[k log(N)], and the max-heap approach costs\nO[log(k)log(N)] + O[k log(k)].  Tests show that for sufficiently large k,\nthe max-heap approach out-performs the priority queue approach by a factor\nof a few.  In light of these tests, the code uses a priority queue for\nk < 5, and a max-heap otherwise.\n\nMemory Allocation\n~~~~~~~~~~~~~~~~~\nIt is desirable to construct a tree in as balanced a way as possible.\nGiven a training set with n_samples and a user-supplied leaf_size, if\nthe points in each node are divided as evenly as possible between the\ntwo children, the maximu""m depth needed so that leaf nodes satisfy\n``leaf_size <= n_points <= 2 * leaf_size`` is given by\n``n_levels = 1 + max(0, floor(log2((n_samples - 1) / leaf_size)))``\n(with the exception of the special case where ``n_samples < leaf_size``)\nFor a given number of levels, the number of points in a tree is given by\n``n_nodes = 2 ** n_levels - 1``.  Both of these results can be shown\nby induction.  Using them, the correct amount of memory can be pre-allocated\nfor a given ``n_samples`` and ``leaf_size``.\n";
+static char __pyx_k_53[] = "sklearn.neighbors.ball_tree";
+static char __pyx_k_54[] = "BallTree.query (line 544)";
+static char __pyx_k_55[] = "\n        query(X, k=1, return_distance=True)\n\n        query the Ball Tree for the k nearest neighbors\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        k : integer  (default = 1)\n            The number of nearest neighbors to return\n        return_distance : boolean (default = True)\n            if True, return a tuple (d,i)\n            if False, return array i\n\n        Returns\n        -------\n        i    : if return_distance == False\n        (d,i) : if return_distance == True\n\n        d : array of doubles - shape: x.shape[:-1] + (k,)\n            each entry gives the list of distances to the\n            neighbors of the corresponding point\n            (note that distances are not sorted)\n\n        i : array of integers - shape: x.shape[:-1] + (k,)\n            each entry gives the list of indices of\n            neighbors of the corresponding point\n            (note that neighbors are not sorted)\n\n        Examples\n        --------\n        Query for k-nearest neighbors\n\n            # >>> import numpy as np\n            # >>> np.random.seed(0)\n            # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            # >>> ball_tree = BallTree(X, leaf_size=2)\n            # >>> dist, ind = ball_tree.query(X[0], k=3)\n            # >>> print ind  # indices of 3 closest neighbors\n            # [0 3 1]\n            # >>> print dist  # distances to 3 closest neighbors\n            # [ 0.          0.19662693  0.29473397]\n        ";
+static char __pyx_k_56[] = "BallTree.query_radius (line 644)";
+static char __pyx_k_57[] = "\n        query_radius(self, X, r, count_only = False):\n\n        query the Ball Tree for neighbors within a ball of size r\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        r : distance within which neighbors are returned\n            r can be a single value, or an array of values of shape\n            x.shape[:-1] if different radii are desired for each point.\n        return_distance : boolean (default = False)\n            if True,  return distances to neighbors of each point\n            if False, return only neighbors\n            Note that unlike BallTree.query(), setting return_distance=True\n            adds to the computation time.  Not all distances need to be\n            calculated explicitly for return_distance=False.  Results are\n            not sorted by default: see ``sort_results`` keyword.\n        count_only : boolean (default = False)\n            if True,  return only the count of points within distance r\n            if False, return the indices of all points within distance r\n            If return_distance==True, setting count_only=True will\n            result in an error.\n        sort_results : boolean (default = False)\n            if True, the distances and indices will be sorted before being\n            returned.  If False, the results will not be sorted.  If\n            return_distance == False, settinng sort_results = True will\n            result in an error.\n\n        Returns\n        -------\n        count       : if count_only == True\n        ind         : if count_only == False and return_distance == False\n        (ind, dist) : if count_only == False and return_distance == True\n\n        count : array of integers, shape = X.shape[:-1]\n            each entry gives the number of neighbors within\n            a distance r of the corresponding point.\n\n        ind : array of objects, shape = X.shape[:-1]\n            each element is ""a numpy integer array listing the indices of\n            neighbors of the corresponding point.  Note that unlike\n            the results of BallTree.query(), the returned neighbors\n            are not sorted by distance\n\n        dist : array of objects, shape = X.shape[:-1]\n            each element is a numpy double array\n            listing the distances corresponding to indices in i.\n\n        Examples\n        --------\n        Query for neighbors in a given radius\n\n            # >>> import numpy as np\n            # >>> np.random.seed(0)\n            # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            # >>> ball_tree = BallTree(X, leaf_size=2)\n            # >>> print ball_tree.query_radius(X[0], r=0.3, count_only=True)\n            # 3\n            # >>> ind = ball_tree.query_radius(X[0], r=0.3)\n            # >>> print ind  # indices of neighbors within distance 0.3\n            # [3 0 1]\n        ";
 static char __pyx_k__B[] = "B";
 static char __pyx_k__C[] = "C";
 static char __pyx_k__H[] = "H";
@@ -891,7 +1102,6 @@ static char __pyx_k__h[] = "h";
 static char __pyx_k__i[] = "i";
 static char __pyx_k__k[] = "k";
 static char __pyx_k__l[] = "l";
-static char __pyx_k__n[] = "n";
 static char __pyx_k__p[] = "p";
 static char __pyx_k__q[] = "q";
 static char __pyx_k__r[] = "r";
@@ -899,24 +1109,16 @@ static char __pyx_k__Zd[] = "Zd";
 static char __pyx_k__Zf[] = "Zf";
 static char __pyx_k__Zg[] = "Zg";
 static char __pyx_k__np[] = "np";
-static char __pyx_k__buf[] = "buf";
 static char __pyx_k__inf[] = "inf";
-static char __pyx_k__obj[] = "obj";
-static char __pyx_k__base[] = "base";
 static char __pyx_k__copy[] = "copy";
-static char __pyx_k__data[] = "data";
-static char __pyx_k__heap[] = "heap";
 static char __pyx_k__log2[] = "log2";
-static char __pyx_k__ndim[] = "ndim";
 static char __pyx_k__ones[] = "ones";
 static char __pyx_k__size[] = "size";
 static char __pyx_k__DTYPE[] = "DTYPE";
 static char __pyx_k__ITYPE[] = "ITYPE";
-static char __pyx_k__descr[] = "descr";
 static char __pyx_k__dtype[] = "dtype";
 static char __pyx_k__empty[] = "empty";
 static char __pyx_k__int32[] = "int32";
-static char __pyx_k__names[] = "names";
 static char __pyx_k__numpy[] = "numpy";
 static char __pyx_k__order[] = "order";
 static char __pyx_k__range[] = "range";
@@ -924,46 +1126,24 @@ static char __pyx_k__shape[] = "shape";
 static char __pyx_k__zeros[] = "zeros";
 static char __pyx_k__arange[] = "arange";
 static char __pyx_k__double[] = "double";
-static char __pyx_k__fields[] = "fields";
-static char __pyx_k__format[] = "format";
-static char __pyx_k__i_node[] = "i_node";
 static char __pyx_k__newObj[] = "newObj";
 static char __pyx_k__object[] = "object";
-static char __pyx_k__radius[] = "radius";
 static char __pyx_k____new__[] = "__new__";
 static char __pyx_k__asarray[] = "asarray";
 static char __pyx_k__float64[] = "float64";
-static char __pyx_k__idx_end[] = "idx_end";
-static char __pyx_k__is_leaf[] = "is_leaf";
-static char __pyx_k__n_nodes[] = "n_nodes";
 static char __pyx_k__reshape[] = "reshape";
-static char __pyx_k__strides[] = "strides";
 static char __pyx_k____main__[] = "__main__";
 static char __pyx_k____test__[] = "__test__";
-static char __pyx_k__itemsize[] = "itemsize";
-static char __pyx_k__n_levels[] = "n_levels";
-static char __pyx_k__readonly[] = "readonly";
-static char __pyx_k__type_num[] = "type_num";
-static char __pyx_k__byteorder[] = "byteorder";
-static char __pyx_k__dist_p_LB[] = "dist_p_LB";
 static char __pyx_k__enumerate[] = "enumerate";
-static char __pyx_k__idx_array[] = "idx_array";
-static char __pyx_k__idx_start[] = "idx_start";
 static char __pyx_k__leaf_size[] = "leaf_size";
 static char __pyx_k__ValueError[] = "ValueError";
 static char __pyx_k__atleast_1d[] = "atleast_1d";
 static char __pyx_k__atleast_2d[] = "atleast_2d";
 static char __pyx_k__count_only[] = "count_only";
-static char __pyx_k__query_one_[] = "query_one_";
-static char __pyx_k__suboffsets[] = "suboffsets";
-static char __pyx_k__build_tree_[] = "build_tree_";
 static char __pyx_k__RuntimeError[] = "RuntimeError";
 static char __pyx_k____getstate__[] = "__getstate__";
 static char __pyx_k__sort_results[] = "sort_results";
-static char __pyx_k__node_info_arr[] = "node_info_arr";
 static char __pyx_k__return_distance[] = "return_distance";
-static char __pyx_k__node_centroid_arr[] = "node_centroid_arr";
-static char __pyx_k__query_radius_count_[] = "query_radius_count_";
 static PyObject *__pyx_kp_s_1;
 static PyObject *__pyx_kp_s_11;
 static PyObject *__pyx_kp_s_13;
@@ -975,21 +1155,19 @@ static PyObject *__pyx_kp_s_27;
 static PyObject *__pyx_kp_s_29;
 static PyObject *__pyx_kp_s_3;
 static PyObject *__pyx_kp_s_33;
-static PyObject *__pyx_n_s_36;
-static PyObject *__pyx_n_s_37;
+static PyObject *__pyx_kp_s_36;
 static PyObject *__pyx_kp_s_38;
-static PyObject *__pyx_kp_s_40;
+static PyObject *__pyx_kp_u_40;
 static PyObject *__pyx_kp_u_42;
 static PyObject *__pyx_kp_u_44;
 static PyObject *__pyx_kp_u_46;
-static PyObject *__pyx_kp_u_48;
-static PyObject *__pyx_kp_u_49;
-static PyObject *__pyx_kp_u_52;
-static PyObject *__pyx_n_s_55;
+static PyObject *__pyx_kp_u_47;
+static PyObject *__pyx_kp_u_50;
+static PyObject *__pyx_n_s_53;
+static PyObject *__pyx_kp_u_54;
+static PyObject *__pyx_kp_u_55;
 static PyObject *__pyx_kp_u_56;
 static PyObject *__pyx_kp_u_57;
-static PyObject *__pyx_kp_u_58;
-static PyObject *__pyx_kp_u_59;
 static PyObject *__pyx_n_s__C;
 static PyObject *__pyx_n_s__DTYPE;
 static PyObject *__pyx_n_s__ITYPE;
@@ -1004,64 +1182,33 @@ static PyObject *__pyx_n_s__arange;
 static PyObject *__pyx_n_s__asarray;
 static PyObject *__pyx_n_s__atleast_1d;
 static PyObject *__pyx_n_s__atleast_2d;
-static PyObject *__pyx_n_s__base;
-static PyObject *__pyx_n_s__buf;
-static PyObject *__pyx_n_s__build_tree_;
-static PyObject *__pyx_n_s__byteorder;
 static PyObject *__pyx_n_s__c;
 static PyObject *__pyx_n_s__copy;
 static PyObject *__pyx_n_s__count_only;
-static PyObject *__pyx_n_s__data;
-static PyObject *__pyx_n_s__descr;
-static PyObject *__pyx_n_s__dist_p_LB;
 static PyObject *__pyx_n_s__double;
 static PyObject *__pyx_n_s__dtype;
 static PyObject *__pyx_n_s__empty;
 static PyObject *__pyx_n_s__enumerate;
-static PyObject *__pyx_n_s__fields;
 static PyObject *__pyx_n_s__float64;
-static PyObject *__pyx_n_s__format;
-static PyObject *__pyx_n_s__heap;
-static PyObject *__pyx_n_s__i_node;
-static PyObject *__pyx_n_s__idx_array;
-static PyObject *__pyx_n_s__idx_end;
-static PyObject *__pyx_n_s__idx_start;
 static PyObject *__pyx_n_s__inf;
 static PyObject *__pyx_n_s__int32;
-static PyObject *__pyx_n_s__is_leaf;
-static PyObject *__pyx_n_s__itemsize;
 static PyObject *__pyx_n_s__k;
 static PyObject *__pyx_n_s__leaf_size;
 static PyObject *__pyx_n_s__log2;
-static PyObject *__pyx_n_s__n;
-static PyObject *__pyx_n_s__n_levels;
-static PyObject *__pyx_n_s__n_nodes;
-static PyObject *__pyx_n_s__names;
-static PyObject *__pyx_n_s__ndim;
 static PyObject *__pyx_n_s__newObj;
-static PyObject *__pyx_n_s__node_centroid_arr;
-static PyObject *__pyx_n_s__node_info_arr;
 static PyObject *__pyx_n_s__np;
 static PyObject *__pyx_n_s__numpy;
-static PyObject *__pyx_n_s__obj;
 static PyObject *__pyx_n_s__object;
 static PyObject *__pyx_n_s__ones;
 static PyObject *__pyx_n_s__order;
 static PyObject *__pyx_n_s__p;
-static PyObject *__pyx_n_s__query_one_;
-static PyObject *__pyx_n_s__query_radius_count_;
 static PyObject *__pyx_n_s__r;
-static PyObject *__pyx_n_s__radius;
 static PyObject *__pyx_n_s__range;
-static PyObject *__pyx_n_s__readonly;
 static PyObject *__pyx_n_s__reshape;
 static PyObject *__pyx_n_s__return_distance;
 static PyObject *__pyx_n_s__shape;
 static PyObject *__pyx_n_s__size;
 static PyObject *__pyx_n_s__sort_results;
-static PyObject *__pyx_n_s__strides;
-static PyObject *__pyx_n_s__suboffsets;
-static PyObject *__pyx_n_s__type_num;
 static PyObject *__pyx_n_s__zeros;
 static PyObject *__pyx_int_0;
 static PyObject *__pyx_int_1;
@@ -1092,14 +1239,14 @@ static PyObject *__pyx_k_tuple_31;
 static PyObject *__pyx_k_tuple_32;
 static PyObject *__pyx_k_tuple_34;
 static PyObject *__pyx_k_tuple_35;
+static PyObject *__pyx_k_tuple_37;
 static PyObject *__pyx_k_tuple_39;
 static PyObject *__pyx_k_tuple_41;
 static PyObject *__pyx_k_tuple_43;
 static PyObject *__pyx_k_tuple_45;
-static PyObject *__pyx_k_tuple_47;
-static PyObject *__pyx_k_tuple_50;
+static PyObject *__pyx_k_tuple_48;
+static PyObject *__pyx_k_tuple_49;
 static PyObject *__pyx_k_tuple_51;
-static PyObject *__pyx_k_tuple_53;
 
 /* "sklearn/neighbors/ball_tree.pyx":215
  * #
@@ -1111,6 +1258,7 @@ static PyObject *__pyx_k_tuple_53;
 
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dmax(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_x, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_y) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("dmax");
 
@@ -1165,6 +1313,7 @@ static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7skl
 
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dmin(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_x, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_y) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("dmin");
 
@@ -1219,6 +1368,7 @@ static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7skl
 
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dabs(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_x) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("dabs");
 
@@ -1271,11 +1421,12 @@ static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7skl
  *     cdef DTYPE_t r, d
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x1, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x2, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x1, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x2, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_d;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   __Pyx_RefNannySetupContext("dist");
@@ -1468,11 +1619,12 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbo
  *     cdef DTYPE_t r, d
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist_p(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x1, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x2, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist_p(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x1, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x2, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_d;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   __Pyx_RefNannySetupContext("dist_p");
@@ -1647,8 +1799,9 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbo
  *         return r ** 0.5
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist_from_dist_p(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist_from_dist_p(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("dist_from_dist_p");
 
@@ -1745,8 +1898,9 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbo
  *         return r ** 2
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist_p_from_dist(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_dist_p_from_dist(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("dist_p_from_dist");
 
@@ -1844,6 +1998,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbo
  */
 
 static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_create(struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_self, int __pyx_v_size) {
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("stack_create");
 
   /* "sklearn/neighbors/ball_tree.pyx":346
@@ -1885,6 +2040,7 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_create(st
  */
 
 static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_destroy(struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_self) {
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("stack_destroy");
 
   /* "sklearn/neighbors/ball_tree.pyx":353
@@ -1908,8 +2064,12 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_destroy(s
  */
 
 static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_resize(struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_self, int __pyx_v_new_size) {
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("stack_resize");
 
   /* "sklearn/neighbors/ball_tree.pyx":359
@@ -1931,7 +2091,7 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_resize(st
  */
     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
@@ -1959,7 +2119,7 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_resize(st
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_WriteUnraisable("sklearn.neighbors.ball_tree.stack_resize");
+  __Pyx_WriteUnraisable("sklearn.neighbors.ball_tree.stack_resize", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_L0:;
   __Pyx_RefNannyFinishContext();
 }
@@ -1973,6 +2133,7 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_resize(st
  */
 
 static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_push(struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_self, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __pyx_v_item) {
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("stack_push");
 
@@ -2029,8 +2190,12 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_stack_push(stru
 
 static CYTHON_INLINE struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __pyx_f_7sklearn_9neighbors_9ball_tree_stack_pop(struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_self) {
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("stack_pop");
 
   /* "sklearn/neighbors/ball_tree.pyx":378
@@ -2052,7 +2217,7 @@ static CYTHON_INLINE struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __
  */
     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
@@ -2081,7 +2246,7 @@ static CYTHON_INLINE struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_WriteUnraisable("sklearn.neighbors.ball_tree.stack_pop");
+  __Pyx_WriteUnraisable("sklearn.neighbors.ball_tree.stack_pop", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_L0:;
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
@@ -2099,9 +2264,13 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_newObj(PyObject *__pyx_
 static PyMethodDef __pyx_mdef_7sklearn_9neighbors_9ball_tree_newObj = {__Pyx_NAMESTR("newObj"), (PyCFunction)__pyx_pf_7sklearn_9neighbors_9ball_tree_newObj, METH_O, __Pyx_DOCSTR(0)};
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_newObj(PyObject *__pyx_self, PyObject *__pyx_v_obj) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("newObj");
   __pyx_self = __pyx_self;
 
@@ -2134,7 +2303,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_newObj(PyObject *__pyx_
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.newObj");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.newObj", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -2153,9 +2322,13 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_newObj(PyObject *__pyx_
 static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   int __pyx_r;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("__cinit__");
   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
     __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
@@ -2280,7 +2453,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree___cinit__(PyObject
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__cinit__");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_RefNannyFinishContext();
@@ -2303,6 +2476,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_samples;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features;
   int __pyx_r;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
@@ -2312,6 +2486,9 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
   long __pyx_t_7;
   long __pyx_t_8;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_9;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__leaf_size,&__pyx_n_s__p,0};
   __Pyx_RefNannySetupContext("__init__");
   if (unlikely(__pyx_kwds)) {
@@ -2369,7 +2546,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
   __pyx_L5_argtuple_error:;
   __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__init__");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
@@ -2435,7 +2612,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
  */
     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
@@ -2461,7 +2638,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
  */
     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
@@ -2487,7 +2664,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
  */
     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_16), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L8;
@@ -2522,7 +2699,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
  */
     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L9;
@@ -2763,7 +2940,7 @@ static int __pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_1__init__(PyObject
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
   __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__init__");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_RefNannyFinishContext();
@@ -2782,10 +2959,14 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_2__reduce__(P
 static char __pyx_doc_7sklearn_9neighbors_9ball_tree_8BallTree_2__reduce__[] = "\n        reduce method used for pickling\n        ";
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_2__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
   PyObject *__pyx_t_4 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("__reduce__");
 
   /* "sklearn/neighbors/ball_tree.pyx":516
@@ -2830,7 +3011,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_2__reduce__(P
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
   __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__reduce__");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -2850,11 +3031,15 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_3__getstate__
 static char __pyx_doc_7sklearn_9neighbors_9ball_tree_8BallTree_3__getstate__[] = "\n        get state for pickling\n        ";
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_3__getstate__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
   PyObject *__pyx_t_4 = NULL;
   PyObject *__pyx_t_5 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("__getstate__");
 
   /* "sklearn/neighbors/ball_tree.pyx":522
@@ -2943,7 +3128,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_3__getstate__
   __Pyx_XDECREF(__pyx_t_3);
   __Pyx_XDECREF(__pyx_t_4);
   __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__getstate__");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__getstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -2963,9 +3148,13 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_4__setstate__
 static char __pyx_doc_7sklearn_9neighbors_9ball_tree_8BallTree_4__setstate__[] = "\n        set state for pickling\n        ";
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_4__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_t_2;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_3;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("__setstate__");
 
   /* "sklearn/neighbors/ball_tree.pyx":535
@@ -3088,7 +3277,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_4__setstate__
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__setstate__");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -3105,22 +3294,23 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_4__setstate__
  */
 
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_7sklearn_9neighbors_9ball_tree_8BallTree_5query[] = "\n        query(X, k=1, return_distance=True)\n\n        query the Ball Tree for the k nearest neighbors\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        k : integer  (default = 1)\n            The number of nearest neighbors to return\n        return_distance : boolean (default = True)\n            if True, return a tuple (d,i)\n            if False, return array i\n\n        Returns\n        -------\n        i    : if return_distance == False\n        (d,i) : if return_distance == True\n\n        d : array of doubles - shape: x.shape[:-1] + (k,)\n            each entry gives the list of distances to the\n            neighbors of the corresponding point\n            (note that distances are not sorted)\n\n        i : array of integers - shape: x.shape[:-1] + (k,)\n            each entry gives the list of indices of\n            neighbors of the corresponding point\n            (note that neighbors are not sorted)\n\n        Examples\n        --------\n        Query for k-nearest neighbors\n\n            >>> import numpy as np\n            >>> np.random.seed(0)\n            >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            >>> ball_tree = BallTree(X, leaf_size=2)\n            >>> dist, ind = ball_tree.query(X[0], k=3)\n            >>> print ind  # indices of 3 closest neighbors\n            [0 3 1]\n            >>> print dist  # distances to 3 closest neighbors\n            [ 0.          0.19662693  0.29473397]\n        ";
+static char __pyx_doc_7sklearn_9neighbors_9ball_tree_8BallTree_5query[] = "\n        query(X, k=1, return_distance=True)\n\n        query the Ball Tree for the k nearest neighbors\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        k : integer  (default = 1)\n            The number of nearest neighbors to return\n        return_distance : boolean (default = True)\n            if True, return a tuple (d,i)\n            if False, return array i\n\n        Returns\n        -------\n        i    : if return_distance == False\n        (d,i) : if return_distance == True\n\n        d : array of doubles - shape: x.shape[:-1] + (k,)\n            each entry gives the list of distances to the\n            neighbors of the corresponding point\n            (note that distances are not sorted)\n\n        i : array of integers - shape: x.shape[:-1] + (k,)\n            each entry gives the list of indices of\n            neighbors of the corresponding point\n            (note that neighbors are not sorted)\n\n        Examples\n        --------\n        Query for k-nearest neighbors\n\n            # >>> import numpy as np\n            # >>> np.random.seed(0)\n            # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            # >>> ball_tree = BallTree(X, leaf_size=2)\n            # >>> dist, ind = ball_tree.query(X[0], k=3)\n            # >>> print ind  # indices of 3 closest neighbors\n            # [0 3 1]\n            # >>> print dist  # distances to 3 closest neighbors\n            # [ 0.          0.19662693  0.29473397]\n        ";
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_X = 0;
   PyObject *__pyx_v_k = 0;
   PyObject *__pyx_v_return_distance = 0;
-  PyObject *__pyx_v_orig_shape;
+  PyObject *__pyx_v_orig_shape = NULL;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_use_max_heap;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_neighbors;
   PyArrayObject *__pyx_v_distances = 0;
   PyArrayObject *__pyx_v_idx_array = 0;
-  PyArrayObject *__pyx_v_Xi;
+  PyArrayObject *__pyx_v_Xi = 0;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_dist_ptr;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_ptr;
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack __pyx_v_node_stack;
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
@@ -3128,7 +3318,11 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
   int __pyx_t_5;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_6;
   Py_ssize_t __pyx_t_7;
-  PyObject *__pyx_t_8 = NULL;
+  PyObject *(*__pyx_t_8)(PyObject *);
+  PyObject *__pyx_t_9 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__k,&__pyx_n_s__return_distance,0};
   __Pyx_RefNannySetupContext("query");
   if (unlikely(__pyx_kwds)) {
@@ -3180,16 +3374,14 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
   __pyx_L5_argtuple_error:;
   __Pyx_RaiseArgtupleInvalid("query", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
   __Pyx_INCREF(__pyx_v_X);
-  __pyx_v_orig_shape = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_Xi = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
 
   /* "sklearn/neighbors/ball_tree.pyx":589
- *             [ 0.          0.19662693  0.29473397]
+ *             # [ 0.          0.19662693  0.29473397]
  *         """
  *         X = np.asarray(X, dtype=DTYPE, order='C')             # <<<<<<<<<<<<<<
  *         X = np.atleast_2d(X)
@@ -3277,7 +3469,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
  */
     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
@@ -3309,7 +3501,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
  */
     __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
@@ -3325,7 +3517,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
  */
   __pyx_t_1 = PyObject_GetAttr(__pyx_v_X, __pyx_n_s__shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_v_orig_shape);
   __pyx_v_orig_shape = __pyx_t_1;
   __pyx_t_1 = 0;
 
@@ -3509,7 +3700,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
   __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__inf); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (__Pyx_PySequence_SetSlice(((PyObject *)__pyx_v_distances), 0, PY_SSIZE_T_MAX, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__pyx_v_distances)) { __Pyx_RaiseUnboundLocalError("distances"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }if (__Pyx_PySequence_SetSlice(((PyObject *)__pyx_v_distances), 0, PY_SSIZE_T_MAX, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
   /* "sklearn/neighbors/ball_tree.pyx":618
@@ -3548,28 +3739,33 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
  */
   __pyx_t_6 = 0;
   if (PyList_CheckExact(__pyx_v_X) || PyTuple_CheckExact(__pyx_v_X)) {
-    __pyx_t_7 = 0; __pyx_t_4 = __pyx_v_X; __Pyx_INCREF(__pyx_t_4);
+    __pyx_t_4 = __pyx_v_X; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
+    __pyx_t_8 = NULL;
   } else {
     __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_X); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext;
   }
   for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_4))) {
+    if (PyList_CheckExact(__pyx_t_4)) {
       if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
       __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
+    } else if (PyTuple_CheckExact(__pyx_t_4)) {
       if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
       __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++;
     } else {
-      __pyx_t_3 = PyIter_Next(__pyx_t_4);
-      if (!__pyx_t_3) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __pyx_t_8(__pyx_t_4);
+      if (unlikely(!__pyx_t_3)) {
+        if (PyErr_Occurred()) {
+          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
         break;
       }
       __Pyx_GOTREF(__pyx_t_3);
     }
     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_Xi));
+    __Pyx_XDECREF(((PyObject *)__pyx_v_Xi));
     __pyx_v_Xi = ((PyArrayObject *)__pyx_t_3);
     __pyx_t_3 = 0;
     __pyx_v_i = __pyx_t_6;
@@ -3691,27 +3887,27 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
     __Pyx_INCREF(__pyx_v_k);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_k);
     __Pyx_GIVEREF(__pyx_v_k);
-    __pyx_t_8 = PyNumber_Add(__pyx_t_4, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_9 = PyNumber_Add(__pyx_t_4, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
-    __Pyx_GIVEREF(__pyx_t_8);
-    __pyx_t_8 = 0;
-    __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_8);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
+    __Pyx_GIVEREF(__pyx_t_9);
+    __pyx_t_9 = 0;
+    __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
-    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8);
-    __Pyx_GIVEREF(__pyx_t_8);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_9);
+    __Pyx_GIVEREF(__pyx_t_9);
     __pyx_t_2 = 0;
-    __pyx_t_8 = 0;
+    __pyx_t_9 = 0;
     __pyx_r = ((PyObject *)__pyx_t_3);
     __pyx_t_3 = 0;
     goto __pyx_L0;
@@ -3729,16 +3925,16 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
     __Pyx_XDECREF(__pyx_r);
     __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_idx_array), __pyx_n_s__reshape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_v_orig_shape, 0, -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_9 = __Pyx_PySequence_GetSlice(__pyx_v_orig_shape, 0, -1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __Pyx_INCREF(__pyx_v_k);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_k);
     __Pyx_GIVEREF(__pyx_v_k);
-    __pyx_t_1 = PyNumber_Add(__pyx_t_8, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Add(__pyx_t_9, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
     __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 = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
@@ -3762,15 +3958,15 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
   __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_8);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query");
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_orig_shape);
+  __Pyx_XDECREF(__pyx_v_orig_shape);
   __Pyx_XDECREF((PyObject *)__pyx_v_distances);
   __Pyx_XDECREF((PyObject *)__pyx_v_idx_array);
-  __Pyx_DECREF((PyObject *)__pyx_v_Xi);
-  __Pyx_DECREF(__pyx_v_X);
+  __Pyx_XDECREF((PyObject *)__pyx_v_Xi);
+  __Pyx_XDECREF(__pyx_v_X);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
@@ -3785,24 +3981,25 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_5query(PyObje
  */
 
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius[] = "\n        query_radius(self, X, r, count_only = False):\n\n        query the Ball Tree for neighbors within a ball of size r\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        r : distance within which neighbors are returned\n            r can be a single value, or an array of values of shape\n            x.shape[:-1] if different radii are desired for each point.\n        return_distance : boolean (default = False)\n            if True,  return distances to neighbors of each point\n            if False, return only neighbors\n            Note that unlike BallTree.query(), setting return_distance=True\n            adds to the computation time.  Not all distances need to be\n            calculated explicitly for return_distance=False.  Results are\n            not sorted by default: see ``sort_results`` keyword.\n        count_only : boolean (default = False)\n            if True,  return only the count of points within distance r\n            if False, return the indices of all points within distance r\n            If return_distance==True, setting count_only=True will\n            result in an error.\n        sort_results : boolean (default = False)\n            if True, the distances and indices will be sorted before being\n            returned.  If False, the results will not be sorted.  If\n            return_distance == False, settinng sort_results = True will\n            result in an error.\n\n        Returns\n        -------\n        count       : if count_only == True\n        ind         : if count_only == False and return_distance == False\n        (ind, dist) : if count_only == False and return_distance == True\n\n        count : array of integers, shape = X.shape[:-1]\n            each entry gives the number of neighbors within\n            a distance r of the corresponding point.\n\n        ind : array of objects, shape = X.shape[:-1]\n            each element is ""a numpy integer array listing the indices of\n            neighbors of the corresponding point.  Note that unlike\n            the results of BallTree.query(), the returned neighbors\n            are not sorted by distance\n\n        dist : array of objects, shape = X.shape[:-1]\n            each element is a numpy double array\n            listing the distances corresponding to indices in i.\n\n        Examples\n        --------\n        Query for neighbors in a given radius\n\n            >>> import numpy as np\n            >>> np.random.seed(0)\n            >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            >>> ball_tree = BallTree(X, leaf_size=2)\n            >>> print ball_tree.query_radius(X[0], r=0.3, count_only=True)\n            3\n            >>> ind = ball_tree.query_radius(X[0], r=0.3)\n            >>> print ind  # indices of neighbors within distance 0.3\n            [3 0 1]\n        ";
+static char __pyx_doc_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius[] = "\n        query_radius(self, X, r, count_only = False):\n\n        query the Ball Tree for neighbors within a ball of size r\n\n        Parameters\n        ----------\n        X : array-like, last dimension self.dim\n            An array of points to query\n        r : distance within which neighbors are returned\n            r can be a single value, or an array of values of shape\n            x.shape[:-1] if different radii are desired for each point.\n        return_distance : boolean (default = False)\n            if True,  return distances to neighbors of each point\n            if False, return only neighbors\n            Note that unlike BallTree.query(), setting return_distance=True\n            adds to the computation time.  Not all distances need to be\n            calculated explicitly for return_distance=False.  Results are\n            not sorted by default: see ``sort_results`` keyword.\n        count_only : boolean (default = False)\n            if True,  return only the count of points within distance r\n            if False, return the indices of all points within distance r\n            If return_distance==True, setting count_only=True will\n            result in an error.\n        sort_results : boolean (default = False)\n            if True, the distances and indices will be sorted before being\n            returned.  If False, the results will not be sorted.  If\n            return_distance == False, settinng sort_results = True will\n            result in an error.\n\n        Returns\n        -------\n        count       : if count_only == True\n        ind         : if count_only == False and return_distance == False\n        (ind, dist) : if count_only == False and return_distance == True\n\n        count : array of integers, shape = X.shape[:-1]\n            each entry gives the number of neighbors within\n            a distance r of the corresponding point.\n\n        ind : array of objects, shape = X.shape[:-1]\n            each element is ""a numpy integer array listing the indices of\n            neighbors of the corresponding point.  Note that unlike\n            the results of BallTree.query(), the returned neighbors\n            are not sorted by distance\n\n        dist : array of objects, shape = X.shape[:-1]\n            each element is a numpy double array\n            listing the distances corresponding to indices in i.\n\n        Examples\n        --------\n        Query for neighbors in a given radius\n\n            # >>> import numpy as np\n            # >>> np.random.seed(0)\n            # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n            # >>> ball_tree = BallTree(X, leaf_size=2)\n            # >>> print ball_tree.query_radius(X[0], r=0.3, count_only=True)\n            # 3\n            # >>> ind = ball_tree.query_radius(X[0], r=0.3)\n            # >>> print ind  # indices of neighbors within distance 0.3\n            # [3 0 1]\n        ";
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_X = 0;
   PyObject *__pyx_v_r = 0;
   PyObject *__pyx_v_return_distance = 0;
   PyObject *__pyx_v_count_only = 0;
   PyObject *__pyx_v_sort_results = 0;
-  PyArrayObject *__pyx_v_idx_array;
-  PyArrayObject *__pyx_v_idx_array_i;
-  PyArrayObject *__pyx_v_distances;
-  PyArrayObject *__pyx_v_distances_i;
-  PyArrayObject *__pyx_v_pt;
-  PyArrayObject *__pyx_v_count;
+  PyArrayObject *__pyx_v_idx_array = 0;
+  PyArrayObject *__pyx_v_idx_array_i = 0;
+  PyArrayObject *__pyx_v_distances = 0;
+  PyArrayObject *__pyx_v_distances_i = 0;
+  PyArrayObject *__pyx_v_pt = 0;
+  PyArrayObject *__pyx_v_count = 0;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_count_i;
-  PyObject *__pyx_v_orig_shape;
+  PyObject *__pyx_v_orig_shape = NULL;
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack __pyx_v_node_stack;
-  PyObject *__pyx_v_pt_idx;
+  PyObject *__pyx_v_pt_idx = NULL;
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   int __pyx_t_2;
   int __pyx_t_3;
@@ -3813,13 +4010,11 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
   PyObject *__pyx_t_8 = NULL;
   PyObject *__pyx_t_9 = NULL;
   Py_ssize_t __pyx_t_10;
-  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_t_11;
+  PyObject *(*__pyx_t_11)(PyObject *);
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_t_12;
-  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_t_13;
-  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_t_14;
-  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_t_15;
-  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_t_16;
-  __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_t_17;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__r,&__pyx_n_s__return_distance,&__pyx_n_s__count_only,&__pyx_n_s__sort_results,0};
   __Pyx_RefNannySetupContext("query_radius");
   if (unlikely(__pyx_kwds)) {
@@ -3894,23 +4089,15 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
   __pyx_L5_argtuple_error:;
   __Pyx_RaiseArgtupleInvalid("query_radius", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query_radius");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query_radius", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
   __Pyx_INCREF(__pyx_v_X);
   __Pyx_INCREF(__pyx_v_r);
-  __pyx_v_idx_array = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_idx_array_i = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_distances = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_distances_i = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_pt = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_count = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_orig_shape = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_pt_idx = Py_None; __Pyx_INCREF(Py_None);
 
   /* "sklearn/neighbors/ball_tree.pyx":710
- *             [3 0 1]
+ *             # [3 0 1]
  *         """
  *         if count_only and return_distance:             # <<<<<<<<<<<<<<
  *             raise ValueError("count_only and return_distance "
@@ -3934,7 +4121,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  */
     __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_28), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
@@ -3967,7 +4154,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  */
     __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_30), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
@@ -4063,7 +4250,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  */
     __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_31), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __Pyx_Raise(__pyx_t_6, 0, 0);
+    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L8;
@@ -4224,7 +4411,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  */
       __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
-      __Pyx_Raise(__pyx_t_9, 0, 0);
+      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L10;
@@ -4242,7 +4429,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  */
   __pyx_t_9 = PyObject_GetAttr(__pyx_v_X, __pyx_n_s__shape); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
-  __Pyx_DECREF(__pyx_v_orig_shape);
   __pyx_v_orig_shape = __pyx_t_9;
   __pyx_t_9 = 0;
 
@@ -4348,7 +4534,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_count));
     __pyx_v_count = ((PyArrayObject *)__pyx_t_4);
     __pyx_t_4 = 0;
 
@@ -4362,32 +4547,37 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_INCREF(__pyx_int_0);
     __pyx_t_4 = __pyx_int_0;
     if (PyList_CheckExact(__pyx_v_X) || PyTuple_CheckExact(__pyx_v_X)) {
-      __pyx_t_10 = 0; __pyx_t_6 = __pyx_v_X; __Pyx_INCREF(__pyx_t_6);
+      __pyx_t_6 = __pyx_v_X; __Pyx_INCREF(__pyx_t_6); __pyx_t_10 = 0;
+      __pyx_t_11 = NULL;
     } else {
       __pyx_t_10 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_X); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext;
     }
     for (;;) {
-      if (likely(PyList_CheckExact(__pyx_t_6))) {
+      if (PyList_CheckExact(__pyx_t_6)) {
         if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_6)) break;
         __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++;
-      } else if (likely(PyTuple_CheckExact(__pyx_t_6))) {
+      } else if (PyTuple_CheckExact(__pyx_t_6)) {
         if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
         __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++;
       } else {
-        __pyx_t_5 = PyIter_Next(__pyx_t_6);
-        if (!__pyx_t_5) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = __pyx_t_11(__pyx_t_6);
+        if (unlikely(!__pyx_t_5)) {
+          if (PyErr_Occurred()) {
+            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          }
           break;
         }
         __Pyx_GOTREF(__pyx_t_5);
       }
       if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(((PyObject *)__pyx_v_pt));
+      __Pyx_XDECREF(((PyObject *)__pyx_v_pt));
       __pyx_v_pt = ((PyArrayObject *)__pyx_t_5);
       __pyx_t_5 = 0;
       __Pyx_INCREF(__pyx_t_4);
-      __Pyx_DECREF(__pyx_v_pt_idx);
+      __Pyx_XDECREF(__pyx_v_pt_idx);
       __pyx_v_pt_idx = __pyx_t_4;
       __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
@@ -4395,15 +4585,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
       __pyx_t_4 = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "sklearn/neighbors/ball_tree.pyx":749
- *             count = np.zeros(X.shape[0], ITYPE)
- *             for pt_idx, pt in enumerate(X):
- *                 count[pt_idx] = self.query_radius_count_(<DTYPE_t*>pt.data,             # <<<<<<<<<<<<<<
- *                                                          r[pt_idx],
- *                                                          &node_stack)
- */
-      __pyx_t_11 = ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_pt->data);
-
       /* "sklearn/neighbors/ball_tree.pyx":750
  *             for pt_idx, pt in enumerate(X):
  *                 count[pt_idx] = self.query_radius_count_(<DTYPE_t*>pt.data,
@@ -4423,7 +4604,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *         elif not return_distance:
  *             idx_array = np.empty(X.shape[0], dtype='object')
  */
-      __pyx_t_5 = __Pyx_PyInt_to_py_npy_int32(((struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *)((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self)->__pyx_vtab)->query_radius_count_(((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self), __pyx_t_11, __pyx_t_12, (&__pyx_v_node_stack))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = __Pyx_PyInt_to_py_npy_int32(((struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *)((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self)->__pyx_vtab)->query_radius_count_(((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self), ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_pt->data), __pyx_t_12, (&__pyx_v_node_stack))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
 
       /* "sklearn/neighbors/ball_tree.pyx":749
@@ -4483,7 +4664,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
     if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_idx_array));
     __pyx_v_idx_array = ((PyArrayObject *)__pyx_t_9);
     __pyx_t_9 = 0;
 
@@ -4518,7 +4698,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_idx_array_i));
     __pyx_v_idx_array_i = ((PyArrayObject *)__pyx_t_6);
     __pyx_t_6 = 0;
 
@@ -4532,32 +4711,37 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_INCREF(__pyx_int_0);
     __pyx_t_6 = __pyx_int_0;
     if (PyList_CheckExact(__pyx_v_X) || PyTuple_CheckExact(__pyx_v_X)) {
-      __pyx_t_10 = 0; __pyx_t_9 = __pyx_v_X; __Pyx_INCREF(__pyx_t_9);
+      __pyx_t_9 = __pyx_v_X; __Pyx_INCREF(__pyx_t_9); __pyx_t_10 = 0;
+      __pyx_t_11 = NULL;
     } else {
       __pyx_t_10 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_X); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext;
     }
     for (;;) {
-      if (likely(PyList_CheckExact(__pyx_t_9))) {
+      if (PyList_CheckExact(__pyx_t_9)) {
         if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_9)) break;
         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++;
-      } else if (likely(PyTuple_CheckExact(__pyx_t_9))) {
+      } else if (PyTuple_CheckExact(__pyx_t_9)) {
         if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++;
       } else {
-        __pyx_t_4 = PyIter_Next(__pyx_t_9);
-        if (!__pyx_t_4) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = __pyx_t_11(__pyx_t_9);
+        if (unlikely(!__pyx_t_4)) {
+          if (PyErr_Occurred()) {
+            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          }
           break;
         }
         __Pyx_GOTREF(__pyx_t_4);
       }
       if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(((PyObject *)__pyx_v_pt));
+      __Pyx_XDECREF(((PyObject *)__pyx_v_pt));
       __pyx_v_pt = ((PyArrayObject *)__pyx_t_4);
       __pyx_t_4 = 0;
       __Pyx_INCREF(__pyx_t_6);
-      __Pyx_DECREF(__pyx_v_pt_idx);
+      __Pyx_XDECREF(__pyx_v_pt_idx);
       __pyx_v_pt_idx = __pyx_t_6;
       __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
@@ -4565,15 +4749,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
       __pyx_t_6 = __pyx_t_4;
       __pyx_t_4 = 0;
 
-      /* "sklearn/neighbors/ball_tree.pyx":757
- *             for pt_idx, pt in enumerate(X):
- *                 count_i = self.query_radius_idx_only_(
- *                     <DTYPE_t*>pt.data,             # <<<<<<<<<<<<<<
- *                     r[pt_idx],
- *                     <ITYPE_t*>idx_array_i.data,
- */
-      __pyx_t_13 = ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_pt->data);
-
       /* "sklearn/neighbors/ball_tree.pyx":758
  *                 count_i = self.query_radius_idx_only_(
  *                     <DTYPE_t*>pt.data,
@@ -4586,15 +4761,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
       __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_12 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-      /* "sklearn/neighbors/ball_tree.pyx":759
- *                     <DTYPE_t*>pt.data,
- *                     r[pt_idx],
- *                     <ITYPE_t*>idx_array_i.data,             # <<<<<<<<<<<<<<
- *                     &node_stack)
- *                 idx_array[pt_idx] = idx_array_i[:count_i].copy()
- */
-      __pyx_t_14 = ((__pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *)__pyx_v_idx_array_i->data);
-
       /* "sklearn/neighbors/ball_tree.pyx":760
  *                     r[pt_idx],
  *                     <ITYPE_t*>idx_array_i.data,
@@ -4602,7 +4768,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *                 idx_array[pt_idx] = idx_array_i[:count_i].copy()
  * 
  */
-      __pyx_v_count_i = ((struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *)((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self)->__pyx_vtab)->query_radius_idx_only_(((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self), __pyx_t_13, __pyx_t_12, __pyx_t_14, (&__pyx_v_node_stack));
+      __pyx_v_count_i = ((struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *)((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self)->__pyx_vtab)->query_radius_idx_only_(((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self), ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_pt->data), __pyx_t_12, ((__pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *)__pyx_v_idx_array_i->data), (&__pyx_v_node_stack));
 
       /* "sklearn/neighbors/ball_tree.pyx":761
  *                     <ITYPE_t*>idx_array_i.data,
@@ -4659,7 +4825,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
     if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_idx_array));
     __pyx_v_idx_array = ((PyArrayObject *)__pyx_t_5);
     __pyx_t_5 = 0;
 
@@ -4694,7 +4859,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
     if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_distances));
     __pyx_v_distances = ((PyArrayObject *)__pyx_t_9);
     __pyx_t_9 = 0;
 
@@ -4729,7 +4893,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_idx_array_i));
     __pyx_v_idx_array_i = ((PyArrayObject *)__pyx_t_4);
     __pyx_t_4 = 0;
 
@@ -4764,7 +4927,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
     if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_distances_i));
     __pyx_v_distances_i = ((PyArrayObject *)__pyx_t_6);
     __pyx_t_6 = 0;
 
@@ -4778,32 +4940,37 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_INCREF(__pyx_int_0);
     __pyx_t_6 = __pyx_int_0;
     if (PyList_CheckExact(__pyx_v_X) || PyTuple_CheckExact(__pyx_v_X)) {
-      __pyx_t_10 = 0; __pyx_t_4 = __pyx_v_X; __Pyx_INCREF(__pyx_t_4);
+      __pyx_t_4 = __pyx_v_X; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
+      __pyx_t_11 = NULL;
     } else {
       __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_X); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext;
     }
     for (;;) {
-      if (likely(PyList_CheckExact(__pyx_t_4))) {
+      if (PyList_CheckExact(__pyx_t_4)) {
         if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
         __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++;
-      } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
+      } else if (PyTuple_CheckExact(__pyx_t_4)) {
         if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
         __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++;
       } else {
-        __pyx_t_5 = PyIter_Next(__pyx_t_4);
-        if (!__pyx_t_5) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = __pyx_t_11(__pyx_t_4);
+        if (unlikely(!__pyx_t_5)) {
+          if (PyErr_Occurred()) {
+            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          }
           break;
         }
         __Pyx_GOTREF(__pyx_t_5);
       }
       if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(((PyObject *)__pyx_v_pt));
+      __Pyx_XDECREF(((PyObject *)__pyx_v_pt));
       __pyx_v_pt = ((PyArrayObject *)__pyx_t_5);
       __pyx_t_5 = 0;
       __Pyx_INCREF(__pyx_t_6);
-      __Pyx_DECREF(__pyx_v_pt_idx);
+      __Pyx_XDECREF(__pyx_v_pt_idx);
       __pyx_v_pt_idx = __pyx_t_6;
       __pyx_t_5 = PyNumber_Add(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
@@ -4811,15 +4978,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
       __pyx_t_6 = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "sklearn/neighbors/ball_tree.pyx":770
- *             for pt_idx, pt in enumerate(X):
- *                 count_i = self.query_radius_distances_(
- *                     <DTYPE_t*>pt.data,             # <<<<<<<<<<<<<<
- *                     r[pt_idx],
- *                     <ITYPE_t*>idx_array_i.data,
- */
-      __pyx_t_15 = ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_pt->data);
-
       /* "sklearn/neighbors/ball_tree.pyx":771
  *                 count_i = self.query_radius_distances_(
  *                     <DTYPE_t*>pt.data,
@@ -4832,24 +4990,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
       __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_12 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-      /* "sklearn/neighbors/ball_tree.pyx":772
- *                     <DTYPE_t*>pt.data,
- *                     r[pt_idx],
- *                     <ITYPE_t*>idx_array_i.data,             # <<<<<<<<<<<<<<
- *                     <DTYPE_t*>distances_i.data,
- *                     &node_stack)
- */
-      __pyx_t_16 = ((__pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *)__pyx_v_idx_array_i->data);
-
-      /* "sklearn/neighbors/ball_tree.pyx":773
- *                     r[pt_idx],
- *                     <ITYPE_t*>idx_array_i.data,
- *                     <DTYPE_t*>distances_i.data,             # <<<<<<<<<<<<<<
- *                     &node_stack)
- *                 if sort_results:
- */
-      __pyx_t_17 = ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_distances_i->data);
-
       /* "sklearn/neighbors/ball_tree.pyx":774
  *                     <ITYPE_t*>idx_array_i.data,
  *                     <DTYPE_t*>distances_i.data,
@@ -4857,7 +4997,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *                 if sort_results:
  *                     sort_dist_idx(<DTYPE_t*>distances_i.data,
  */
-      __pyx_v_count_i = ((struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *)((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self)->__pyx_vtab)->query_radius_distances_(((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self), __pyx_t_15, __pyx_t_12, __pyx_t_16, __pyx_t_17, (&__pyx_v_node_stack));
+      __pyx_v_count_i = ((struct __pyx_vtabstruct_7sklearn_9neighbors_9ball_tree_BallTree *)((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self)->__pyx_vtab)->query_radius_distances_(((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self), ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_pt->data), __pyx_t_12, ((__pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *)__pyx_v_idx_array_i->data), ((__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *)__pyx_v_distances_i->data), (&__pyx_v_node_stack));
 
       /* "sklearn/neighbors/ball_tree.pyx":775
  *                     <DTYPE_t*>distances_i.data,
@@ -4949,7 +5089,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *             return (idx_array.reshape(orig_shape[:-1]),
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_count), __pyx_n_s__reshape); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(!__pyx_v_count)) { __Pyx_RaiseUnboundLocalError("count"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }__pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_count), __pyx_n_s__reshape); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __pyx_t_4 = __Pyx_PySequence_GetSlice(__pyx_v_orig_shape, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
@@ -4986,7 +5126,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *         else:
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_idx_array), __pyx_n_s__reshape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(!__pyx_v_idx_array)) { __Pyx_RaiseUnboundLocalError("idx_array"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }__pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_idx_array), __pyx_n_s__reshape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __pyx_t_5 = __Pyx_PySequence_GetSlice(__pyx_v_orig_shape, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
@@ -4999,6 +5139,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+    if (unlikely(!__pyx_v_distances)) { __Pyx_RaiseUnboundLocalError("distances"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }__pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_distances), __pyx_n_s__reshape); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
     /* "sklearn/neighbors/ball_tree.pyx":790
  *         elif return_distance:
@@ -5007,7 +5148,6 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *         else:
  *             return idx_array.reshape(orig_shape[:-1])
  */
-    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_distances), __pyx_n_s__reshape); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __pyx_t_4 = __Pyx_PySequence_GetSlice(__pyx_v_orig_shape, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
@@ -5043,7 +5183,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *     @cython.cdivision(True)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_idx_array), __pyx_n_s__reshape); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(!__pyx_v_idx_array)) { __Pyx_RaiseUnboundLocalError("idx_array"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }__pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_idx_array), __pyx_n_s__reshape); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __pyx_t_4 = __Pyx_PySequence_GetSlice(__pyx_v_orig_shape, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
@@ -5071,19 +5211,19 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
   __Pyx_XDECREF(__pyx_t_7);
   __Pyx_XDECREF(__pyx_t_8);
   __Pyx_XDECREF(__pyx_t_9);
-  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query_radius");
+  __Pyx_AddTraceback("sklearn.neighbors.ball_tree.BallTree.query_radius", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF((PyObject *)__pyx_v_idx_array);
-  __Pyx_DECREF((PyObject *)__pyx_v_idx_array_i);
-  __Pyx_DECREF((PyObject *)__pyx_v_distances);
-  __Pyx_DECREF((PyObject *)__pyx_v_distances_i);
-  __Pyx_DECREF((PyObject *)__pyx_v_pt);
-  __Pyx_DECREF((PyObject *)__pyx_v_count);
-  __Pyx_DECREF(__pyx_v_orig_shape);
-  __Pyx_DECREF(__pyx_v_pt_idx);
-  __Pyx_DECREF(__pyx_v_X);
-  __Pyx_DECREF(__pyx_v_r);
+  __Pyx_XDECREF((PyObject *)__pyx_v_idx_array);
+  __Pyx_XDECREF((PyObject *)__pyx_v_idx_array_i);
+  __Pyx_XDECREF((PyObject *)__pyx_v_distances);
+  __Pyx_XDECREF((PyObject *)__pyx_v_distances_i);
+  __Pyx_XDECREF((PyObject *)__pyx_v_pt);
+  __Pyx_XDECREF((PyObject *)__pyx_v_count);
+  __Pyx_XDECREF(__pyx_v_orig_shape);
+  __Pyx_XDECREF(__pyx_v_pt_idx);
+  __Pyx_XDECREF(__pyx_v_X);
+  __Pyx_XDECREF(__pyx_v_r);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
@@ -5097,7 +5237,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_6query_radius
  *         cdef ITYPE_t* idx_array = <ITYPE_t*> self.idx_array.data
  */
 
-static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_build_tree_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self) {
+static void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_build_tree_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_array;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_node_centroid_arr;
@@ -5116,10 +5256,14 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_build_tree_(struct
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_NodeInfo *__pyx_v_node_info;
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_NodeInfo *__pyx_v_parent_info;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i_max;
+  __Pyx_RefNannyDeclarations
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_1;
   int __pyx_t_2;
   PyObject *__pyx_t_3 = NULL;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_4;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("build_tree_");
 
   /* "sklearn/neighbors/ball_tree.pyx":796
@@ -5381,9 +5525,9 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_build_tree_(struct
  *                                  "allocation is flawed")
  * 
  */
-      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_37), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_Raise(__pyx_t_3, 0, 0);
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
@@ -5535,9 +5679,9 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_build_tree_(struct
  * 
  *             elif n_points == 1:
  */
-      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_Raise(__pyx_t_3, 0, 0);
+      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       break;
@@ -5664,7 +5808,7 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_build_tree_(struct
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_WriteUnraisable("sklearn.neighbors.ball_tree.BallTree.build_tree_");
+  __Pyx_WriteUnraisable("sklearn.neighbors.ball_tree.BallTree.build_tree_", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_L0:;
   __Pyx_RefNannyFinishContext();
 }
@@ -5677,7 +5821,7 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_build_tree_(struct
  *                          ITYPE_t k,
  */
 
-static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_one_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_k, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_near_set_dist, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_near_set_indx, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_use_max_heap) {
+static void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_one_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_k, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_near_set_dist, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_near_set_indx, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_use_max_heap) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_array;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_node_centroid_arr;
@@ -5696,6 +5840,7 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_one_(struct
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __pyx_v_item;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t (*__pyx_v_heapqueue_largest)(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t);
   void (*__pyx_v_heapqueue_insert)(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t);
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   __Pyx_RefNannySetupContext("query_one_");
@@ -6156,7 +6301,7 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_one_(struct
  *                                      stack* node_stack):
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_radius_count_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_radius_count_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_array;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_node_centroid_arr;
@@ -6171,6 +6316,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_dist_pt;
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __pyx_v_item;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   long __pyx_t_3;
@@ -6484,7 +6630,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
  *                                         ITYPE_t* indices,
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_radius_idx_only_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_indices, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_radius_idx_only_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_indices, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_array;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_node_centroid_arr;
@@ -6499,6 +6645,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_dist_pt;
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __pyx_v_item;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   long __pyx_t_3;
@@ -6841,7 +6988,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
  *                                          ITYPE_t* indices,
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_radius_distances_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_distances, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_8BallTree_query_radius_distances_(struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *__pyx_v_self, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_r, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_distances, struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack *__pyx_v_node_stack) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_array;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_node_centroid_arr;
@@ -6856,6 +7003,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_dist_pt;
   struct __pyx_t_7sklearn_9neighbors_9ball_tree_stack_item __pyx_v_item;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   long __pyx_t_3;
@@ -7218,7 +7366,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
 }
 
 /* "sklearn/neighbors/ball_tree.pyx":459
- *         [ 0.          0.19662693  0.29473397]
+ *         # [ 0.          0.19662693  0.29473397]
  *     """
  *     cdef readonly np.ndarray data             # <<<<<<<<<<<<<<
  *     cdef np.ndarray idx_array
@@ -7228,6 +7376,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_4data___get__(PyObject *__pyx_v_self); /*proto*/
 static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_4data___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("__get__");
   __Pyx_XDECREF(__pyx_r);
   __Pyx_INCREF(((PyObject *)((struct __pyx_obj_7sklearn_9neighbors_9ball_tree_BallTree *)__pyx_v_self)->data));
@@ -7251,6 +7400,7 @@ static PyObject *__pyx_pf_7sklearn_9neighbors_9ball_tree_8BallTree_4data___get__
 
 static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_copy_array(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_x, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_y, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
+  __Pyx_RefNannyDeclarations
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_1;
   __Pyx_RefNannySetupContext("copy_array");
 
@@ -7285,10 +7435,11 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_copy_array(__py
  *                            ITYPE_t* node_indices,
  */
 
-static  void __pyx_f_7sklearn_9neighbors_9ball_tree_compute_centroid(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_centroid, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_node_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_points) {
+static void __pyx_f_7sklearn_9neighbors_9ball_tree_compute_centroid(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_centroid, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_node_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_points) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_this_pt;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_j;
+  __Pyx_RefNannyDeclarations
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_3;
@@ -7387,7 +7538,7 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_compute_centroid(__pyx_t_7sk
  *                             ITYPE_t n_features,
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_find_split_dim(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_node_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_points) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_find_split_dim(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_node_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_points) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_min_val;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_max_val;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_val;
@@ -7397,6 +7548,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_j;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_j_max;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   int __pyx_t_3;
@@ -7553,6 +7705,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
 
 static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_iswap(__pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_arr, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i1, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i2) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_tmp;
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("iswap");
 
   /* "sklearn/neighbors/ball_tree.pyx":1294
@@ -7595,6 +7748,7 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_iswap(__pyx_t_7
 
 static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_dswap(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_arr, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i1, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i2) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_tmp;
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("dswap");
 
   /* "sklearn/neighbors/ball_tree.pyx":1301
@@ -7635,13 +7789,14 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_dswap(__pyx_t_7
  *                             ITYPE_t split_dim,
  */
 
-static  void __pyx_f_7sklearn_9neighbors_9ball_tree_partition_indices(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_node_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_split_dim, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_split_index, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_points) {
+static void __pyx_f_7sklearn_9neighbors_9ball_tree_partition_indices(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_data, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_node_indices, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_split_dim, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_split_index, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_points) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_left;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_right;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_midindex;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_d1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_d2;
+  __Pyx_RefNannyDeclarations
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_1;
   int __pyx_t_2;
   __Pyx_RefNannySetupContext("partition_indices");
@@ -7821,6 +7976,7 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_partition_indices(__pyx_t_7s
 
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_calc_dist_LB(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_centroid, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_radius, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("calc_dist_LB");
 
   /* "sklearn/neighbors/ball_tree.pyx":1353
@@ -7849,6 +8005,7 @@ static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7skl
 
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_calc_dist_p_LB(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_pt, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_centroid, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_radius, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_n_features, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_p) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("calc_dist_p_LB");
 
   /* "sklearn/neighbors/ball_tree.pyx":1363
@@ -7877,6 +8034,7 @@ static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7skl
 
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_pqueue_largest(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_queue, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_queue_size) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("pqueue_largest");
 
   /* "sklearn/neighbors/ball_tree.pyx":1374
@@ -7908,6 +8066,7 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_pqueue_insert(_
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i_upper;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i_mid;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_t_2;
   __Pyx_RefNannySetupContext("pqueue_insert");
@@ -8154,6 +8313,7 @@ static CYTHON_INLINE void __pyx_f_7sklearn_9neighbors_9ball_tree_pqueue_insert(_
 
 static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_max_heap_largest(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_heap, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_k) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("max_heap_largest");
 
   /* "sklearn/neighbors/ball_tree.pyx":1438
@@ -8180,11 +8340,12 @@ static CYTHON_INLINE __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_f_7skl
  *                           ITYPE_t* idx_array,
  */
 
-static  void __pyx_f_7sklearn_9neighbors_9ball_tree_max_heap_insert(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_val, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i_val, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_heap, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_array, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_heap_size) {
+static void __pyx_f_7sklearn_9neighbors_9ball_tree_max_heap_insert(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_val, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i_val, __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_heap, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx_array, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_heap_size) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_ic1;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_ic2;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i_swap;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("max_heap_insert");
 
@@ -8471,8 +8632,9 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_max_heap_insert(__pyx_t_7skl
  *     if k > 1:
  */
 
-static  void __pyx_f_7sklearn_9neighbors_9ball_tree_sort_dist_idx(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_dist, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_k) {
+static void __pyx_f_7sklearn_9neighbors_9ball_tree_sort_dist_idx(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_dist, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_k) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_pivot_idx;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("sort_dist_idx");
 
@@ -8527,12 +8689,13 @@ static  void __pyx_f_7sklearn_9neighbors_9ball_tree_sort_dist_idx(__pyx_t_7sklea
  *     cdef DTYPE_t pivot_val = dist[pivot_idx]
  */
 
-static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_partition_dist_idx(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_dist, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_k) {
+static __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbors_9ball_tree_partition_dist_idx(__pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t *__pyx_v_dist, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t *__pyx_v_idx, __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_k) {
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_pivot_idx;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_v_pivot_val;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_store_idx;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_v_i;
   __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_r;
+  __Pyx_RefNannyDeclarations
   long __pyx_t_1;
   int __pyx_t_2;
   __Pyx_RefNannySetupContext("partition_dist_idx");
@@ -8664,7 +8827,7 @@ static  __pyx_t_7sklearn_9neighbors_9ball_tree_ITYPE_t __pyx_f_7sklearn_9neighbo
   return __pyx_r;
 }
 
-/* "numpy.pxd":188
+/* "numpy.pxd":190
  *         # experimental exception made for __getbuffer__ and __releasebuffer__
  *         # -- the details of this may change.
  *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
@@ -8685,22 +8848,42 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
   int __pyx_v_offset;
   int __pyx_v_hasfields;
   int __pyx_r;
-  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
   int __pyx_t_2;
   int __pyx_t_3;
-  int __pyx_t_4;
+  PyObject *__pyx_t_4 = NULL;
   int __pyx_t_5;
   int __pyx_t_6;
   int __pyx_t_7;
   PyObject *__pyx_t_8 = NULL;
   char *__pyx_t_9;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("__getbuffer__");
-  if (__pyx_v_info == NULL) return 0;
-  __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
-  __Pyx_GIVEREF(__pyx_v_info->obj);
+  if (__pyx_v_info != NULL) {
+    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
+    __Pyx_GIVEREF(__pyx_v_info->obj);
+  }
 
-  /* "numpy.pxd":194
+  /* "numpy.pxd":196
  *             # of flags
+ * 
+ *             if info == NULL: return             # <<<<<<<<<<<<<<
+ * 
+ *             cdef int copy_shape, i, ndim
+ */
+  __pyx_t_1 = (__pyx_v_info == NULL);
+  if (__pyx_t_1) {
+    __pyx_r = 0;
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "numpy.pxd":199
+ * 
  *             cdef int copy_shape, i, ndim
  *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
  *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
@@ -8708,7 +8891,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
   __pyx_v_endian_detector = 1;
 
-  /* "numpy.pxd":195
+  /* "numpy.pxd":200
  *             cdef int copy_shape, i, ndim
  *             cdef int endian_detector = 1
  *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
@@ -8717,29 +8900,26 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
   __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
 
-  /* "numpy.pxd":197
+  /* "numpy.pxd":202
  *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
  * 
  *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
  * 
  *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
  */
-  __pyx_t_1 = __pyx_v_self;
-  __Pyx_INCREF(__pyx_t_1);
-  __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_t_1));
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self));
 
-  /* "numpy.pxd":199
+  /* "numpy.pxd":204
  *             ndim = PyArray_NDIM(self)
  * 
  *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
  *                 copy_shape = 1
  *             else:
  */
-  __pyx_t_2 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
-  if (__pyx_t_2) {
+  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
+  if (__pyx_t_1) {
 
-    /* "numpy.pxd":200
+    /* "numpy.pxd":205
  * 
  *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
  *                 copy_shape = 1             # <<<<<<<<<<<<<<
@@ -8747,11 +8927,11 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  *                 copy_shape = 0
  */
     __pyx_v_copy_shape = 1;
-    goto __pyx_L5;
+    goto __pyx_L6;
   }
   /*else*/ {
 
-    /* "numpy.pxd":202
+    /* "numpy.pxd":207
  *                 copy_shape = 1
  *             else:
  *                 copy_shape = 0             # <<<<<<<<<<<<<<
@@ -8760,144 +8940,135 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     __pyx_v_copy_shape = 0;
   }
-  __pyx_L5:;
+  __pyx_L6:;
 
-  /* "numpy.pxd":204
+  /* "numpy.pxd":209
  *                 copy_shape = 0
  * 
  *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
  *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  *                 raise ValueError(u"ndarray is not C contiguous")
  */
-  __pyx_t_2 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS);
-  if (__pyx_t_2) {
+  __pyx_t_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS);
+  if (__pyx_t_1) {
 
-    /* "numpy.pxd":205
+    /* "numpy.pxd":210
  * 
  *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
  *                 raise ValueError(u"ndarray is not C contiguous")
  * 
  */
-    __pyx_t_1 = __pyx_v_self;
-    __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_3 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_t_1), NPY_C_CONTIGUOUS));
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_4 = __pyx_t_3;
+    __pyx_t_2 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_C_CONTIGUOUS));
+    __pyx_t_3 = __pyx_t_2;
   } else {
-    __pyx_t_4 = __pyx_t_2;
+    __pyx_t_3 = __pyx_t_1;
   }
-  if (__pyx_t_4) {
+  if (__pyx_t_3) {
 
-    /* "numpy.pxd":206
+    /* "numpy.pxd":211
  *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
  * 
  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_t_1, 0, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L6;
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L7;
   }
-  __pyx_L6:;
+  __pyx_L7:;
 
-  /* "numpy.pxd":208
+  /* "numpy.pxd":213
  *                 raise ValueError(u"ndarray is not C contiguous")
  * 
  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
  *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  *                 raise ValueError(u"ndarray is not Fortran contiguous")
  */
-  __pyx_t_4 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS);
-  if (__pyx_t_4) {
+  __pyx_t_3 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS);
+  if (__pyx_t_3) {
 
-    /* "numpy.pxd":209
+    /* "numpy.pxd":214
  * 
  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
  *                 raise ValueError(u"ndarray is not Fortran contiguous")
  * 
  */
-    __pyx_t_1 = __pyx_v_self;
-    __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_2 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_t_1), NPY_F_CONTIGUOUS));
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_3 = __pyx_t_2;
+    __pyx_t_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_F_CONTIGUOUS));
+    __pyx_t_2 = __pyx_t_1;
   } else {
-    __pyx_t_3 = __pyx_t_4;
+    __pyx_t_2 = __pyx_t_3;
   }
-  if (__pyx_t_3) {
+  if (__pyx_t_2) {
 
-    /* "numpy.pxd":210
+    /* "numpy.pxd":215
  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
  * 
  *             info.buf = PyArray_DATA(self)
  */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_t_1, 0, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L7;
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L8;
   }
-  __pyx_L7:;
+  __pyx_L8:;
 
-  /* "numpy.pxd":212
+  /* "numpy.pxd":217
  *                 raise ValueError(u"ndarray is not Fortran contiguous")
  * 
  *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
  *             info.ndim = ndim
  *             if copy_shape:
  */
-  __pyx_t_1 = __pyx_v_self;
-  __Pyx_INCREF(__pyx_t_1);
-  __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_t_1));
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self));
 
-  /* "numpy.pxd":213
+  /* "numpy.pxd":218
  * 
  *             info.buf = PyArray_DATA(self)
  *             info.ndim = ndim             # <<<<<<<<<<<<<<
  *             if copy_shape:
- *                 # Allocate new buffer for strides and shape info. This is allocated
+ *                 # Allocate new buffer for strides and shape info.
  */
   __pyx_v_info->ndim = __pyx_v_ndim;
 
-  /* "numpy.pxd":214
+  /* "numpy.pxd":219
  *             info.buf = PyArray_DATA(self)
  *             info.ndim = ndim
  *             if copy_shape:             # <<<<<<<<<<<<<<
- *                 # Allocate new buffer for strides and shape info. This is allocated
- *                 # as one block, strides first.
+ *                 # Allocate new buffer for strides and shape info.
+ *                 # This is allocated as one block, strides first.
  */
   if (__pyx_v_copy_shape) {
 
-    /* "numpy.pxd":217
- *                 # Allocate new buffer for strides and shape info. This is allocated
- *                 # as one block, strides first.
- *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)             # <<<<<<<<<<<<<<
+    /* "numpy.pxd":222
+ *                 # Allocate new buffer for strides and shape info.
+ *                 # This is allocated as one block, strides first.
+ *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)             # <<<<<<<<<<<<<<
  *                 info.shape = info.strides + ndim
  *                 for i in range(ndim):
  */
-    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * __pyx_v_ndim) * 2)));
+    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));
 
-    /* "numpy.pxd":218
- *                 # as one block, strides first.
- *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
+    /* "numpy.pxd":223
+ *                 # This is allocated as one block, strides first.
+ *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
  *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
  *                 for i in range(ndim):
  *                     info.strides[i] = PyArray_STRIDES(self)[i]
  */
     __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);
 
-    /* "numpy.pxd":219
- *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
+    /* "numpy.pxd":224
+ *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
  *                 info.shape = info.strides + ndim
  *                 for i in range(ndim):             # <<<<<<<<<<<<<<
  *                     info.strides[i] = PyArray_STRIDES(self)[i]
@@ -8907,61 +9078,49 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
       __pyx_v_i = __pyx_t_6;
 
-      /* "numpy.pxd":220
+      /* "numpy.pxd":225
  *                 info.shape = info.strides + ndim
  *                 for i in range(ndim):
  *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
  *                     info.shape[i] = PyArray_DIMS(self)[i]
  *             else:
  */
-      __pyx_t_1 = __pyx_v_self;
-      __Pyx_INCREF(__pyx_t_1);
-      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_t_1))[__pyx_v_i]);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);
 
-      /* "numpy.pxd":221
+      /* "numpy.pxd":226
  *                 for i in range(ndim):
  *                     info.strides[i] = PyArray_STRIDES(self)[i]
  *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
  *             else:
  *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  */
-      __pyx_t_1 = __pyx_v_self;
-      __Pyx_INCREF(__pyx_t_1);
-      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(((PyArrayObject *)__pyx_t_1))[__pyx_v_i]);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);
     }
-    goto __pyx_L8;
+    goto __pyx_L9;
   }
   /*else*/ {
 
-    /* "numpy.pxd":223
+    /* "numpy.pxd":228
  *                     info.shape[i] = PyArray_DIMS(self)[i]
  *             else:
  *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
  *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  *             info.suboffsets = NULL
  */
-    __pyx_t_1 = __pyx_v_self;
-    __Pyx_INCREF(__pyx_t_1);
-    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_t_1)));
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self)));
 
-    /* "numpy.pxd":224
+    /* "numpy.pxd":229
  *             else:
  *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
  *             info.suboffsets = NULL
  *             info.itemsize = PyArray_ITEMSIZE(self)
  */
-    __pyx_t_1 = __pyx_v_self;
-    __Pyx_INCREF(__pyx_t_1);
-    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_t_1)));
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self)));
   }
-  __pyx_L8:;
+  __pyx_L9:;
 
-  /* "numpy.pxd":225
+  /* "numpy.pxd":230
  *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
@@ -8970,31 +9129,25 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
   __pyx_v_info->suboffsets = NULL;
 
-  /* "numpy.pxd":226
+  /* "numpy.pxd":231
  *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  *             info.suboffsets = NULL
  *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
  *             info.readonly = not PyArray_ISWRITEABLE(self)
  * 
  */
-  __pyx_t_1 = __pyx_v_self;
-  __Pyx_INCREF(__pyx_t_1);
-  __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_t_1));
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self));
 
-  /* "numpy.pxd":227
+  /* "numpy.pxd":232
  *             info.suboffsets = NULL
  *             info.itemsize = PyArray_ITEMSIZE(self)
  *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
  * 
  *             cdef int t
  */
-  __pyx_t_1 = __pyx_v_self;
-  __Pyx_INCREF(__pyx_t_1);
-  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_t_1)));
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self)));
 
-  /* "numpy.pxd":230
+  /* "numpy.pxd":235
  * 
  *             cdef int t
  *             cdef char* f = NULL             # <<<<<<<<<<<<<<
@@ -9003,7 +9156,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
   __pyx_v_f = NULL;
 
-  /* "numpy.pxd":231
+  /* "numpy.pxd":236
  *             cdef int t
  *             cdef char* f = NULL
  *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
@@ -9013,7 +9166,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
   __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr));
   __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr;
 
-  /* "numpy.pxd":235
+  /* "numpy.pxd":240
  *             cdef int offset
  * 
  *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
@@ -9022,23 +9175,23 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
   __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);
 
-  /* "numpy.pxd":237
+  /* "numpy.pxd":242
  *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
  * 
  *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
  *                 # do not call releasebuffer
  *                 info.obj = None
  */
-  __pyx_t_3 = (!__pyx_v_hasfields);
-  if (__pyx_t_3) {
-    __pyx_t_4 = (!__pyx_v_copy_shape);
-    __pyx_t_2 = __pyx_t_4;
+  __pyx_t_2 = (!__pyx_v_hasfields);
+  if (__pyx_t_2) {
+    __pyx_t_3 = (!__pyx_v_copy_shape);
+    __pyx_t_1 = __pyx_t_3;
   } else {
-    __pyx_t_2 = __pyx_t_3;
+    __pyx_t_1 = __pyx_t_2;
   }
-  if (__pyx_t_2) {
+  if (__pyx_t_1) {
 
-    /* "numpy.pxd":239
+    /* "numpy.pxd":244
  *             if not hasfields and not copy_shape:
  *                 # do not call releasebuffer
  *                 info.obj = None             # <<<<<<<<<<<<<<
@@ -9050,11 +9203,11 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
     __Pyx_GOTREF(__pyx_v_info->obj);
     __Pyx_DECREF(__pyx_v_info->obj);
     __pyx_v_info->obj = Py_None;
-    goto __pyx_L11;
+    goto __pyx_L12;
   }
   /*else*/ {
 
-    /* "numpy.pxd":242
+    /* "numpy.pxd":247
  *             else:
  *                 # need to call releasebuffer
  *                 info.obj = self             # <<<<<<<<<<<<<<
@@ -9067,19 +9220,19 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
     __Pyx_DECREF(__pyx_v_info->obj);
     __pyx_v_info->obj = __pyx_v_self;
   }
-  __pyx_L11:;
+  __pyx_L12:;
 
-  /* "numpy.pxd":244
+  /* "numpy.pxd":249
  *                 info.obj = self
  * 
  *             if not hasfields:             # <<<<<<<<<<<<<<
  *                 t = descr.type_num
  *                 if ((descr.byteorder == '>' and little_endian) or
  */
-  __pyx_t_2 = (!__pyx_v_hasfields);
-  if (__pyx_t_2) {
+  __pyx_t_1 = (!__pyx_v_hasfields);
+  if (__pyx_t_1) {
 
-    /* "numpy.pxd":245
+    /* "numpy.pxd":250
  * 
  *             if not hasfields:
  *                 t = descr.type_num             # <<<<<<<<<<<<<<
@@ -9088,306 +9241,306 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     __pyx_v_t = __pyx_v_descr->type_num;
 
-    /* "numpy.pxd":246
+    /* "numpy.pxd":251
  *             if not hasfields:
  *                 t = descr.type_num
  *                 if ((descr.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
  *                     (descr.byteorder == '<' and not little_endian)):
  *                     raise ValueError(u"Non-native byte order not supported")
  */
-    __pyx_t_2 = (__pyx_v_descr->byteorder == '>');
-    if (__pyx_t_2) {
-      __pyx_t_3 = __pyx_v_little_endian;
+    __pyx_t_1 = (__pyx_v_descr->byteorder == '>');
+    if (__pyx_t_1) {
+      __pyx_t_2 = __pyx_v_little_endian;
     } else {
-      __pyx_t_3 = __pyx_t_2;
+      __pyx_t_2 = __pyx_t_1;
     }
-    if (!__pyx_t_3) {
+    if (!__pyx_t_2) {
 
-      /* "numpy.pxd":247
+      /* "numpy.pxd":252
  *                 t = descr.type_num
  *                 if ((descr.byteorder == '>' and little_endian) or
  *                     (descr.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
  *                     raise ValueError(u"Non-native byte order not supported")
  *                 if   t == NPY_BYTE:        f = "b"
  */
-      __pyx_t_2 = (__pyx_v_descr->byteorder == '<');
-      if (__pyx_t_2) {
-        __pyx_t_4 = (!__pyx_v_little_endian);
-        __pyx_t_7 = __pyx_t_4;
+      __pyx_t_1 = (__pyx_v_descr->byteorder == '<');
+      if (__pyx_t_1) {
+        __pyx_t_3 = (!__pyx_v_little_endian);
+        __pyx_t_7 = __pyx_t_3;
       } else {
-        __pyx_t_7 = __pyx_t_2;
+        __pyx_t_7 = __pyx_t_1;
       }
-      __pyx_t_2 = __pyx_t_7;
+      __pyx_t_1 = __pyx_t_7;
     } else {
-      __pyx_t_2 = __pyx_t_3;
+      __pyx_t_1 = __pyx_t_2;
     }
-    if (__pyx_t_2) {
+    if (__pyx_t_1) {
 
-      /* "numpy.pxd":248
+      /* "numpy.pxd":253
  *                 if ((descr.byteorder == '>' and little_endian) or
  *                     (descr.byteorder == '<' and not little_endian)):
  *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
  *                 if   t == NPY_BYTE:        f = "b"
  *                 elif t == NPY_UBYTE:       f = "B"
  */
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_Raise(__pyx_t_1, 0, 0);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L13;
+      __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L14;
     }
-    __pyx_L13:;
+    __pyx_L14:;
 
-    /* "numpy.pxd":249
+    /* "numpy.pxd":254
  *                     (descr.byteorder == '<' and not little_endian)):
  *                     raise ValueError(u"Non-native byte order not supported")
  *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_UBYTE:       f = "B"
  *                 elif t == NPY_SHORT:       f = "h"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_BYTE);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_BYTE);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__b;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":250
+    /* "numpy.pxd":255
  *                     raise ValueError(u"Non-native byte order not supported")
  *                 if   t == NPY_BYTE:        f = "b"
  *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_SHORT:       f = "h"
  *                 elif t == NPY_USHORT:      f = "H"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_UBYTE);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_UBYTE);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__B;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":251
+    /* "numpy.pxd":256
  *                 if   t == NPY_BYTE:        f = "b"
  *                 elif t == NPY_UBYTE:       f = "B"
  *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_USHORT:      f = "H"
  *                 elif t == NPY_INT:         f = "i"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_SHORT);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_SHORT);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__h;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":252
+    /* "numpy.pxd":257
  *                 elif t == NPY_UBYTE:       f = "B"
  *                 elif t == NPY_SHORT:       f = "h"
  *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_INT:         f = "i"
  *                 elif t == NPY_UINT:        f = "I"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_USHORT);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_USHORT);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__H;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":253
+    /* "numpy.pxd":258
  *                 elif t == NPY_SHORT:       f = "h"
  *                 elif t == NPY_USHORT:      f = "H"
  *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_UINT:        f = "I"
  *                 elif t == NPY_LONG:        f = "l"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_INT);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_INT);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__i;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":254
+    /* "numpy.pxd":259
  *                 elif t == NPY_USHORT:      f = "H"
  *                 elif t == NPY_INT:         f = "i"
  *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_LONG:        f = "l"
  *                 elif t == NPY_ULONG:       f = "L"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_UINT);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_UINT);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__I;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":255
+    /* "numpy.pxd":260
  *                 elif t == NPY_INT:         f = "i"
  *                 elif t == NPY_UINT:        f = "I"
  *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_ULONG:       f = "L"
  *                 elif t == NPY_LONGLONG:    f = "q"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_LONG);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_LONG);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__l;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":256
+    /* "numpy.pxd":261
  *                 elif t == NPY_UINT:        f = "I"
  *                 elif t == NPY_LONG:        f = "l"
  *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_LONGLONG:    f = "q"
  *                 elif t == NPY_ULONGLONG:   f = "Q"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_ULONG);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_ULONG);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__L;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":257
+    /* "numpy.pxd":262
  *                 elif t == NPY_LONG:        f = "l"
  *                 elif t == NPY_ULONG:       f = "L"
  *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_ULONGLONG:   f = "Q"
  *                 elif t == NPY_FLOAT:       f = "f"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_LONGLONG);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__q;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":258
+    /* "numpy.pxd":263
  *                 elif t == NPY_ULONG:       f = "L"
  *                 elif t == NPY_LONGLONG:    f = "q"
  *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_FLOAT:       f = "f"
  *                 elif t == NPY_DOUBLE:      f = "d"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_ULONGLONG);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__Q;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":259
+    /* "numpy.pxd":264
  *                 elif t == NPY_LONGLONG:    f = "q"
  *                 elif t == NPY_ULONGLONG:   f = "Q"
  *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_DOUBLE:      f = "d"
  *                 elif t == NPY_LONGDOUBLE:  f = "g"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_FLOAT);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_FLOAT);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__f;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":260
+    /* "numpy.pxd":265
  *                 elif t == NPY_ULONGLONG:   f = "Q"
  *                 elif t == NPY_FLOAT:       f = "f"
  *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_LONGDOUBLE:  f = "g"
  *                 elif t == NPY_CFLOAT:      f = "Zf"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_DOUBLE);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__d;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":261
+    /* "numpy.pxd":266
  *                 elif t == NPY_FLOAT:       f = "f"
  *                 elif t == NPY_DOUBLE:      f = "d"
  *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_CFLOAT:      f = "Zf"
  *                 elif t == NPY_CDOUBLE:     f = "Zd"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_LONGDOUBLE);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__g;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":262
+    /* "numpy.pxd":267
  *                 elif t == NPY_DOUBLE:      f = "d"
  *                 elif t == NPY_LONGDOUBLE:  f = "g"
  *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_CDOUBLE:     f = "Zd"
  *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_CFLOAT);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__Zf;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":263
+    /* "numpy.pxd":268
  *                 elif t == NPY_LONGDOUBLE:  f = "g"
  *                 elif t == NPY_CFLOAT:      f = "Zf"
  *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
  *                 elif t == NPY_OBJECT:      f = "O"
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_CDOUBLE);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__Zd;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":264
+    /* "numpy.pxd":269
  *                 elif t == NPY_CFLOAT:      f = "Zf"
  *                 elif t == NPY_CDOUBLE:     f = "Zd"
  *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
  *                 elif t == NPY_OBJECT:      f = "O"
  *                 else:
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_CLONGDOUBLE);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__Zg;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
 
-    /* "numpy.pxd":265
+    /* "numpy.pxd":270
  *                 elif t == NPY_CDOUBLE:     f = "Zd"
  *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
  *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
  *                 else:
  *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  */
-    __pyx_t_2 = (__pyx_v_t == NPY_OBJECT);
-    if (__pyx_t_2) {
+    __pyx_t_1 = (__pyx_v_t == NPY_OBJECT);
+    if (__pyx_t_1) {
       __pyx_v_f = __pyx_k__O;
-      goto __pyx_L14;
+      goto __pyx_L15;
     }
     /*else*/ {
 
-      /* "numpy.pxd":267
+      /* "numpy.pxd":272
  *                 elif t == NPY_OBJECT:      f = "O"
  *                 else:
  *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
  *                 info.format = f
  *                 return
  */
-      __pyx_t_1 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_48), __pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_46), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_8));
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
       __pyx_t_8 = 0;
-      __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-      __Pyx_Raise(__pyx_t_8, 0, 0);
+      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
-    __pyx_L14:;
+    __pyx_L15:;
 
-    /* "numpy.pxd":268
+    /* "numpy.pxd":273
  *                 else:
  *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  *                 info.format = f             # <<<<<<<<<<<<<<
@@ -9396,7 +9549,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     __pyx_v_info->format = __pyx_v_f;
 
-    /* "numpy.pxd":269
+    /* "numpy.pxd":274
  *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  *                 info.format = f
  *                 return             # <<<<<<<<<<<<<<
@@ -9405,11 +9558,11 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     __pyx_r = 0;
     goto __pyx_L0;
-    goto __pyx_L12;
+    goto __pyx_L13;
   }
   /*else*/ {
 
-    /* "numpy.pxd":271
+    /* "numpy.pxd":276
  *                 return
  *             else:
  *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
@@ -9418,7 +9571,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     __pyx_v_info->format = ((char *)malloc(255));
 
-    /* "numpy.pxd":272
+    /* "numpy.pxd":277
  *             else:
  *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
  *                 info.format[0] = '^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
@@ -9427,7 +9580,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     (__pyx_v_info->format[0]) = '^';
 
-    /* "numpy.pxd":273
+    /* "numpy.pxd":278
  *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
  *                 info.format[0] = '^' # Native data types, manual alignment
  *                 offset = 0             # <<<<<<<<<<<<<<
@@ -9436,17 +9589,17 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     __pyx_v_offset = 0;
 
-    /* "numpy.pxd":276
+    /* "numpy.pxd":281
  *                 f = _util_dtypestring(descr, info.format + 1,
  *                                       info.format + _buffer_format_string_len,
  *                                       &offset)             # <<<<<<<<<<<<<<
  *                 f[0] = 0 # Terminate format string
  * 
  */
-    __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_f = __pyx_t_9;
 
-    /* "numpy.pxd":277
+    /* "numpy.pxd":282
  *                                       info.format + _buffer_format_string_len,
  *                                       &offset)
  *                 f[0] = 0 # Terminate format string             # <<<<<<<<<<<<<<
@@ -9455,20 +9608,22 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
  */
     (__pyx_v_f[0]) = 0;
   }
-  __pyx_L12:;
+  __pyx_L13:;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
   __Pyx_XDECREF(__pyx_t_8);
-  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__");
+  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = -1;
-  __Pyx_GOTREF(__pyx_v_info->obj);
-  __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
+  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
+    __Pyx_GOTREF(__pyx_v_info->obj);
+    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
+  }
   goto __pyx_L2;
   __pyx_L0:;
-  if (__pyx_v_info->obj == Py_None) {
+  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
     __Pyx_GOTREF(Py_None);
     __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
   }
@@ -9478,7 +9633,7 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "numpy.pxd":279
+/* "numpy.pxd":284
  *                 f[0] = 0 # Terminate format string
  * 
  *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
@@ -9488,24 +9643,21 @@ static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_
 
 static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
 static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
-  PyObject *__pyx_t_1 = NULL;
-  int __pyx_t_2;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
   __Pyx_RefNannySetupContext("__releasebuffer__");
 
-  /* "numpy.pxd":280
+  /* "numpy.pxd":285
  * 
  *         def __releasebuffer__(ndarray self, Py_buffer* info):
  *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
  *                 stdlib.free(info.format)
  *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
  */
-  __pyx_t_1 = __pyx_v_self;
-  __Pyx_INCREF(__pyx_t_1);
-  __pyx_t_2 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_t_1));
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (__pyx_t_2) {
+  __pyx_t_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self));
+  if (__pyx_t_1) {
 
-    /* "numpy.pxd":281
+    /* "numpy.pxd":286
  *         def __releasebuffer__(ndarray self, Py_buffer* info):
  *             if PyArray_HASFIELDS(self):
  *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
@@ -9517,17 +9669,17 @@ static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *
   }
   __pyx_L5:;
 
-  /* "numpy.pxd":282
+  /* "numpy.pxd":287
  *             if PyArray_HASFIELDS(self):
  *                 stdlib.free(info.format)
  *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
  *                 stdlib.free(info.strides)
  *                 # info.shape was stored after info.strides in the same block
  */
-  __pyx_t_2 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
-  if (__pyx_t_2) {
+  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
+  if (__pyx_t_1) {
 
-    /* "numpy.pxd":283
+    /* "numpy.pxd":288
  *                 stdlib.free(info.format)
  *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
  *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
@@ -9542,7 +9694,7 @@ static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *
   __Pyx_RefNannyFinishContext();
 }
 
-/* "numpy.pxd":756
+/* "numpy.pxd":764
  * ctypedef npy_cdouble     complex_t
  * 
  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
@@ -9552,10 +9704,14 @@ static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *
 
 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1");
 
-  /* "numpy.pxd":757
+  /* "numpy.pxd":765
  * 
  * cdef inline object PyArray_MultiIterNew1(a):
  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
@@ -9563,7 +9719,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__
  * cdef inline object PyArray_MultiIterNew2(a, b):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -9573,7 +9729,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1");
+  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = 0;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -9581,7 +9737,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__
   return __pyx_r;
 }
 
-/* "numpy.pxd":759
+/* "numpy.pxd":767
  *     return PyArray_MultiIterNew(1, <void*>a)
  * 
  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
@@ -9591,10 +9747,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__
 
 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2");
 
-  /* "numpy.pxd":760
+  /* "numpy.pxd":768
  * 
  * cdef inline object PyArray_MultiIterNew2(a, b):
  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
@@ -9602,7 +9762,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__
  * cdef inline object PyArray_MultiIterNew3(a, b, c):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -9612,7 +9772,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2");
+  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = 0;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -9620,7 +9780,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__
   return __pyx_r;
 }
 
-/* "numpy.pxd":762
+/* "numpy.pxd":770
  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  * 
  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
@@ -9630,10 +9790,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__
 
 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3");
 
-  /* "numpy.pxd":763
+  /* "numpy.pxd":771
  * 
  * cdef inline object PyArray_MultiIterNew3(a, b, c):
  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
@@ -9641,7 +9805,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__
  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -9651,7 +9815,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3");
+  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = 0;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -9659,7 +9823,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__
   return __pyx_r;
 }
 
-/* "numpy.pxd":765
+/* "numpy.pxd":773
  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  * 
  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
@@ -9669,10 +9833,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__
 
 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4");
 
-  /* "numpy.pxd":766
+  /* "numpy.pxd":774
  * 
  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
@@ -9680,7 +9848,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__
  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -9690,7 +9858,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4");
+  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = 0;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -9698,7 +9866,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__
   return __pyx_r;
 }
 
-/* "numpy.pxd":768
+/* "numpy.pxd":776
  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  * 
  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
@@ -9708,10 +9876,14 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__
 
 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5");
 
-  /* "numpy.pxd":769
+  /* "numpy.pxd":777
  * 
  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
@@ -9719,7 +9891,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__
  * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -9729,7 +9901,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5");
+  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = 0;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -9737,7 +9909,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__
   return __pyx_r;
 }
 
-/* "numpy.pxd":771
+/* "numpy.pxd":779
  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  * 
  * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
@@ -9746,16 +9918,17 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__
  */
 
 static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
-  PyArray_Descr *__pyx_v_child;
+  PyArray_Descr *__pyx_v_child = 0;
   int __pyx_v_endian_detector;
   int __pyx_v_little_endian;
-  PyObject *__pyx_v_fields;
-  PyObject *__pyx_v_childname;
-  PyObject *__pyx_v_new_offset;
-  PyObject *__pyx_v_t;
+  PyObject *__pyx_v_fields = 0;
+  PyObject *__pyx_v_childname = NULL;
+  PyObject *__pyx_v_new_offset = NULL;
+  PyObject *__pyx_v_t = NULL;
   char *__pyx_r;
-  Py_ssize_t __pyx_t_1;
-  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
   PyObject *__pyx_t_3 = NULL;
   PyObject *__pyx_t_4 = NULL;
   PyObject *__pyx_t_5 = NULL;
@@ -9765,14 +9938,12 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
   int __pyx_t_9;
   long __pyx_t_10;
   char *__pyx_t_11;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
   __Pyx_RefNannySetupContext("_util_dtypestring");
-  __pyx_v_child = ((PyArray_Descr *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_fields = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_childname = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_new_offset = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "numpy.pxd":778
+  /* "numpy.pxd":786
  *     cdef int delta_offset
  *     cdef tuple i
  *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
@@ -9781,7 +9952,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
  */
   __pyx_v_endian_detector = 1;
 
-  /* "numpy.pxd":779
+  /* "numpy.pxd":787
  *     cdef tuple i
  *     cdef int endian_detector = 1
  *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
@@ -9790,103 +9961,110 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
  */
   __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
 
-  /* "numpy.pxd":782
+  /* "numpy.pxd":790
  *     cdef tuple fields
  * 
  *     for childname in descr.names:             # <<<<<<<<<<<<<<
  *         fields = descr.fields[childname]
  *         child, new_offset = fields
  */
-  if (unlikely(__pyx_v_descr->names == Py_None)) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_1 = 0; __pyx_t_2 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_2);
+  __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
   for (;;) {
-    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
-    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
-    __Pyx_DECREF(__pyx_v_childname);
+    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
+    __Pyx_XDECREF(__pyx_v_childname);
     __pyx_v_childname = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "numpy.pxd":783
+    /* "numpy.pxd":791
  * 
  *     for childname in descr.names:
  *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
  *         child, new_offset = fields
  * 
  */
-    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_v_fields));
+    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_XDECREF(((PyObject *)__pyx_v_fields));
     __pyx_v_fields = ((PyObject*)__pyx_t_3);
     __pyx_t_3 = 0;
 
-    /* "numpy.pxd":784
+    /* "numpy.pxd":792
  *     for childname in descr.names:
  *         fields = descr.fields[childname]
  *         child, new_offset = fields             # <<<<<<<<<<<<<<
  * 
  *         if (end - f) - (new_offset - offset[0]) < 15:
  */
-    if (likely(((PyObject *)__pyx_v_fields) != Py_None) && likely(PyTuple_GET_SIZE(((PyObject *)__pyx_v_fields)) == 2)) {
-      PyObject* tuple = ((PyObject *)__pyx_v_fields);
-      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
-      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_4);
-      __Pyx_DECREF(((PyObject *)__pyx_v_child));
-      __pyx_v_child = ((PyArray_Descr *)__pyx_t_3);
-      __pyx_t_3 = 0;
-      __Pyx_DECREF(__pyx_v_new_offset);
-      __pyx_v_new_offset = __pyx_t_4;
-      __pyx_t_4 = 0;
+    if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) {
+      PyObject* sequence = ((PyObject *)__pyx_v_fields);
+      if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
+        if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
+        else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
+        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
+      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(__pyx_t_4);
     } else {
       __Pyx_UnpackTupleError(((PyObject *)__pyx_v_fields), 2);
-      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
+    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_XDECREF(((PyObject *)__pyx_v_child));
+    __pyx_v_child = ((PyArray_Descr *)__pyx_t_3);
+    __pyx_t_3 = 0;
+    __Pyx_XDECREF(__pyx_v_new_offset);
+    __pyx_v_new_offset = __pyx_t_4;
+    __pyx_t_4 = 0;
 
-    /* "numpy.pxd":786
+    /* "numpy.pxd":794
  *         child, new_offset = fields
  * 
  *         if (end - f) - (new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  * 
  */
-    __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     if (__pyx_t_6) {
 
-      /* "numpy.pxd":787
+      /* "numpy.pxd":795
  * 
  *         if (end - f) - (new_offset - offset[0]) < 15:
  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
  * 
  *         if ((child.byteorder == '>' and little_endian) or
  */
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_48), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L5;
     }
     __pyx_L5:;
 
-    /* "numpy.pxd":789
+    /* "numpy.pxd":797
  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  * 
  *         if ((child.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
@@ -9901,7 +10079,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
     }
     if (!__pyx_t_7) {
 
-      /* "numpy.pxd":790
+      /* "numpy.pxd":798
  * 
  *         if ((child.byteorder == '>' and little_endian) or
  *             (child.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
@@ -9921,23 +10099,23 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
     }
     if (__pyx_t_6) {
 
-      /* "numpy.pxd":791
+      /* "numpy.pxd":799
  *         if ((child.byteorder == '>' and little_endian) or
  *             (child.byteorder == '<' and not little_endian)):
  *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
  *             # One could encode it in the format string and have Cython
  *             # complain instead, BUT: < and > in format strings also imply
  */
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_49), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L6;
     }
     __pyx_L6:;
 
-    /* "numpy.pxd":801
+    /* "numpy.pxd":809
  * 
  *         # Output padding bytes
  *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
@@ -9945,16 +10123,16 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
  *             f += 1
  */
     while (1) {
-      __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (!__pyx_t_6) break;
 
-      /* "numpy.pxd":802
+      /* "numpy.pxd":810
  *         # Output padding bytes
  *         while offset[0] < new_offset:
  *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
@@ -9963,7 +10141,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
  */
       (__pyx_v_f[0]) = 120;
 
-      /* "numpy.pxd":803
+      /* "numpy.pxd":811
  *         while offset[0] < new_offset:
  *             f[0] = 120 # "x"; pad byte
  *             f += 1             # <<<<<<<<<<<<<<
@@ -9972,7 +10150,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
  */
       __pyx_v_f = (__pyx_v_f + 1);
 
-      /* "numpy.pxd":804
+      /* "numpy.pxd":812
  *             f[0] = 120 # "x"; pad byte
  *             f += 1
  *             offset[0] += 1             # <<<<<<<<<<<<<<
@@ -9983,7 +10161,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
       (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + 1);
     }
 
-    /* "numpy.pxd":806
+    /* "numpy.pxd":814
  *             offset[0] += 1
  * 
  *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
@@ -9993,7 +10171,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
     __pyx_t_10 = 0;
     (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + __pyx_v_child->elsize);
 
-    /* "numpy.pxd":808
+    /* "numpy.pxd":816
  *         offset[0] += child.itemsize
  * 
  *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
@@ -10003,20 +10181,20 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
     __pyx_t_6 = (!PyDataType_HASFIELDS(__pyx_v_child));
     if (__pyx_t_6) {
 
-      /* "numpy.pxd":809
+      /* "numpy.pxd":817
  * 
  *         if not PyDataType_HASFIELDS(child):
  *             t = child.type_num             # <<<<<<<<<<<<<<
  *             if end - f < 5:
  *                 raise RuntimeError(u"Format string allocated too short.")
  */
-      __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(__pyx_v_t);
+      __Pyx_XDECREF(__pyx_v_t);
       __pyx_v_t = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "numpy.pxd":810
+      /* "numpy.pxd":818
  *         if not PyDataType_HASFIELDS(child):
  *             t = child.type_num
  *             if end - f < 5:             # <<<<<<<<<<<<<<
@@ -10026,282 +10204,282 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
       __pyx_t_6 = ((__pyx_v_end - __pyx_v_f) < 5);
       if (__pyx_t_6) {
 
-        /* "numpy.pxd":811
+        /* "numpy.pxd":819
  *             t = child.type_num
  *             if end - f < 5:
  *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
  * 
  *             # Until ticket #99 is fixed, use integers to avoid warnings
  */
-        __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_53), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __Pyx_Raise(__pyx_t_3, 0, 0);
+        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L10;
       }
       __pyx_L10:;
 
-      /* "numpy.pxd":814
+      /* "numpy.pxd":822
  * 
  *             # Until ticket #99 is fixed, use integers to avoid warnings
  *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
  *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
  *             elif t == NPY_SHORT:       f[0] = 104 #"h"
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 98;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":815
+      /* "numpy.pxd":823
  *             # Until ticket #99 is fixed, use integers to avoid warnings
  *             if   t == NPY_BYTE:        f[0] =  98 #"b"
  *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
  *             elif t == NPY_SHORT:       f[0] = 104 #"h"
  *             elif t == NPY_USHORT:      f[0] =  72 #"H"
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 66;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":816
+      /* "numpy.pxd":824
  *             if   t == NPY_BYTE:        f[0] =  98 #"b"
  *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
  *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
  *             elif t == NPY_USHORT:      f[0] =  72 #"H"
  *             elif t == NPY_INT:         f[0] = 105 #"i"
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 104;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":817
+      /* "numpy.pxd":825
  *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
  *             elif t == NPY_SHORT:       f[0] = 104 #"h"
  *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
  *             elif t == NPY_INT:         f[0] = 105 #"i"
  *             elif t == NPY_UINT:        f[0] =  73 #"I"
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 72;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":818
+      /* "numpy.pxd":826
  *             elif t == NPY_SHORT:       f[0] = 104 #"h"
  *             elif t == NPY_USHORT:      f[0] =  72 #"H"
  *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
  *             elif t == NPY_UINT:        f[0] =  73 #"I"
  *             elif t == NPY_LONG:        f[0] = 108 #"l"
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 105;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":819
+      /* "numpy.pxd":827
  *             elif t == NPY_USHORT:      f[0] =  72 #"H"
  *             elif t == NPY_INT:         f[0] = 105 #"i"
  *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
  *             elif t == NPY_LONG:        f[0] = 108 #"l"
  *             elif t == NPY_ULONG:       f[0] = 76  #"L"
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 73;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":820
+      /* "numpy.pxd":828
  *             elif t == NPY_INT:         f[0] = 105 #"i"
  *             elif t == NPY_UINT:        f[0] =  73 #"I"
  *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
  *             elif t == NPY_ULONG:       f[0] = 76  #"L"
  *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 108;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":821
+      /* "numpy.pxd":829
  *             elif t == NPY_UINT:        f[0] =  73 #"I"
  *             elif t == NPY_LONG:        f[0] = 108 #"l"
  *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
  *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
  *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 76;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":822
+      /* "numpy.pxd":830
  *             elif t == NPY_LONG:        f[0] = 108 #"l"
  *             elif t == NPY_ULONG:       f[0] = 76  #"L"
  *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
  *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
  *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 113;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":823
+      /* "numpy.pxd":831
  *             elif t == NPY_ULONG:       f[0] = 76  #"L"
  *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
  *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
  *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
  *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 81;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":824
+      /* "numpy.pxd":832
  *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
  *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
  *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
  *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
  *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 102;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":825
+      /* "numpy.pxd":833
  *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
  *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
  *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
  *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
  *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 100;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":826
+      /* "numpy.pxd":834
  *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
  *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
  *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
  *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
  *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 103;
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":827
+      /* "numpy.pxd":835
  *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
  *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
  *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
  *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
  *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 90;
@@ -10310,19 +10488,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":828
+      /* "numpy.pxd":836
  *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
  *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
  *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
  *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 90;
@@ -10331,19 +10509,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":829
+      /* "numpy.pxd":837
  *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
  *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
  *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
  *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
  *             else:
  */
-      __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 90;
@@ -10352,19 +10530,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
         goto __pyx_L11;
       }
 
-      /* "numpy.pxd":830
+      /* "numpy.pxd":838
  *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
  *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
  *             else:
  *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  */
-      __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       if (__pyx_t_6) {
         (__pyx_v_f[0]) = 79;
@@ -10372,30 +10550,30 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
       }
       /*else*/ {
 
-        /* "numpy.pxd":832
+        /* "numpy.pxd":840
  *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
  *             else:
  *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
  *             f += 1
  *         else:
  */
-        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_48), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_46), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
         PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
         __pyx_t_5 = 0;
-        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-        __Pyx_Raise(__pyx_t_5, 0, 0);
+        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       __pyx_L11:;
 
-      /* "numpy.pxd":833
+      /* "numpy.pxd":841
  *             else:
  *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  *             f += 1             # <<<<<<<<<<<<<<
@@ -10407,21 +10585,21 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
     }
     /*else*/ {
 
-      /* "numpy.pxd":837
+      /* "numpy.pxd":845
  *             # Cython ignores struct boundary information ("T{...}"),
  *             # so don't output it
  *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
  *     return f
  * 
  */
-      __pyx_t_11 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_f = __pyx_t_11;
     }
     __pyx_L9:;
   }
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "numpy.pxd":838
+  /* "numpy.pxd":846
  *             # so don't output it
  *             f = _util_dtypestring(child, f, end, offset)
  *     return f             # <<<<<<<<<<<<<<
@@ -10434,23 +10612,23 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_3);
   __Pyx_XDECREF(__pyx_t_4);
   __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_AddTraceback("numpy._util_dtypestring");
+  __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF((PyObject *)__pyx_v_child);
-  __Pyx_DECREF(__pyx_v_fields);
-  __Pyx_DECREF(__pyx_v_childname);
-  __Pyx_DECREF(__pyx_v_new_offset);
-  __Pyx_DECREF(__pyx_v_t);
+  __Pyx_XDECREF((PyObject *)__pyx_v_child);
+  __Pyx_XDECREF(__pyx_v_fields);
+  __Pyx_XDECREF(__pyx_v_childname);
+  __Pyx_XDECREF(__pyx_v_new_offset);
+  __Pyx_XDECREF(__pyx_v_t);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "numpy.pxd":953
+/* "numpy.pxd":961
  * 
  * 
  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
@@ -10460,11 +10638,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
 
 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
   PyObject *__pyx_v_baseptr;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
-  PyObject *__pyx_t_2 = NULL;
   __Pyx_RefNannySetupContext("set_array_base");
 
-  /* "numpy.pxd":955
+  /* "numpy.pxd":963
  * cdef inline void set_array_base(ndarray arr, object base):
  *      cdef PyObject* baseptr
  *      if base is None:             # <<<<<<<<<<<<<<
@@ -10474,7 +10652,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
   __pyx_t_1 = (__pyx_v_base == Py_None);
   if (__pyx_t_1) {
 
-    /* "numpy.pxd":956
+    /* "numpy.pxd":964
  *      cdef PyObject* baseptr
  *      if base is None:
  *          baseptr = NULL             # <<<<<<<<<<<<<<
@@ -10486,19 +10664,16 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
   }
   /*else*/ {
 
-    /* "numpy.pxd":958
+    /* "numpy.pxd":966
  *          baseptr = NULL
  *      else:
  *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
  *          baseptr = <PyObject*>base
  *      Py_XDECREF(arr.base)
  */
-    __pyx_t_2 = __pyx_v_base;
-    __Pyx_INCREF(__pyx_t_2);
-    Py_INCREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    Py_INCREF(__pyx_v_base);
 
-    /* "numpy.pxd":959
+    /* "numpy.pxd":967
  *      else:
  *          Py_INCREF(base) # important to do this before decref below!
  *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
@@ -10509,7 +10684,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
   }
   __pyx_L3:;
 
-  /* "numpy.pxd":960
+  /* "numpy.pxd":968
  *          Py_INCREF(base) # important to do this before decref below!
  *          baseptr = <PyObject*>base
  *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
@@ -10518,7 +10693,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
  */
   Py_XDECREF(__pyx_v_arr->base);
 
-  /* "numpy.pxd":961
+  /* "numpy.pxd":969
  *          baseptr = <PyObject*>base
  *      Py_XDECREF(arr.base)
  *      arr.base = baseptr             # <<<<<<<<<<<<<<
@@ -10530,7 +10705,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
   __Pyx_RefNannyFinishContext();
 }
 
-/* "numpy.pxd":963
+/* "numpy.pxd":971
  *      arr.base = baseptr
  * 
  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
@@ -10540,10 +10715,11 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a
 
 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
   PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("get_array_base");
 
-  /* "numpy.pxd":964
+  /* "numpy.pxd":972
  * 
  * cdef inline object get_array_base(ndarray arr):
  *     if arr.base is NULL:             # <<<<<<<<<<<<<<
@@ -10553,7 +10729,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py
   __pyx_t_1 = (__pyx_v_arr->base == NULL);
   if (__pyx_t_1) {
 
-    /* "numpy.pxd":965
+    /* "numpy.pxd":973
  * cdef inline object get_array_base(ndarray arr):
  *     if arr.base is NULL:
  *         return None             # <<<<<<<<<<<<<<
@@ -10568,7 +10744,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py
   }
   /*else*/ {
 
-    /* "numpy.pxd":967
+    /* "numpy.pxd":975
  *         return None
  *     else:
  *         return <object>arr.base             # <<<<<<<<<<<<<<
@@ -10790,7 +10966,7 @@ static PyTypeObject __pyx_type_7sklearn_9neighbors_9ball_tree_BallTree = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_BallTree, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("\n    Ball Tree for fast nearest-neighbor searches :\n\n    BallTree(X, leaf_size=20, p=2.0)\n\n    Parameters\n    ----------\n    X : array-like, shape = [n_samples, n_features]\n        n_samples is the number of points in the data set, and\n        n_features is the dimension of the parameter space.\n        Note: if X is a C-contiguous array of doubles then data will\n        not be copied. Otherwise, an internal copy will be made.\n\n    leaf_size : positive integer (default = 20)\n        Number of points at which to switch to brute-force. Changing\n        leaf_size will not affect the results of a query, but can\n        significantly impact the speed of a query and the memory required\n        to store the built ball tree.  The amount of memory needed to\n        store the tree scales as\n        2 ** (1 + floor(log2((n_samples - 1) / leaf_size))) - 1\n        For a specified ``leaf_size``, a leaf node is guaranteed to\n        satisfy ``leaf_size <= n_points <= 2 * leaf_size``, except in\n        the case that ``n_samples < leaf_size``.\n\n    p : distance metric for the BallTree.  ``p`` encodes the Minkowski\n        p-distance:\n            D = sum((X[i] - X[j]) ** p) ** (1. / p)\n        p must be greater than or equal to 1, so that the triangle\n        inequality will hold.  If ``p == np.inf``, then the distance is\n        equivalent to\n            D = max(X[i] - X[j])\n\n    Examples\n    --------\n    Query for k-nearest neighbors\n\n        >>> import numpy as np\n        >>> np.random.seed(0)\n        >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n        >>> ball_tree = BallTree(X, leaf_size=2)\n        >>> dist, ind = ball_tree.query(X[0], n_neighbors=3)\n        >>> print ind  # indices of 3 closest neighbors\n        [0 3 1]\n        >>> print dist  # distances to 3 closest neighbors\n        [ 0.          0.19662693  0.29473397]\n\n    Pickle and Unpickle a ball tree (using protocol = 2).  Note that the\n    state of the tree is saved in the pickle operation: the tree is not\n    rebuilt on un-pickling\n\n        >>> import numpy as np\n        >>> import pickle\n        >>> np.random.seed(0)\n        >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n        >>> ball_tree = BallTree(X, leaf_size=2)\n        >>> s = pickle.dumps(ball_tree, protocol=2)\n        >>> ball_tree_copy = pickle.loads(s)\n        >>> dist, ind = ball_tree_copy.query(X[0], k=3)\n        >>> print ind  # indices of 3 closest neighbors\n        [0 3 1]\n        >>> print dist  # distances to 3 closest neighbors\n        [ 0.          0.19662693  0.29473397]\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("\n    Ball Tree for fast nearest-neighbor searches :\n\n    BallTree(X, leaf_size=20, p=2.0)\n\n    Parameters\n    ----------\n    X : array-like, shape = [n_samples, n_features]\n        n_samples is the number of points in the data set, and\n        n_features is the dimension of the parameter space.\n        Note: if X is a C-contiguous array of doubles then data will\n        not be copied. Otherwise, an internal copy will be made.\n\n    leaf_size : positive integer (default = 20)\n        Number of points at which to switch to brute-force. Changing\n        leaf_size will not affect the results of a query, but can\n        significantly impact the speed of a query and the memory required\n        to store the built ball tree.  The amount of memory needed to\n        store the tree scales as\n        2 ** (1 + floor(log2((n_samples - 1) / leaf_size))) - 1\n        For a specified ``leaf_size``, a leaf node is guaranteed to\n        satisfy ``leaf_size <= n_points <= 2 * leaf_size``, except in\n        the case that ``n_samples < leaf_size``.\n\n    p : distance metric for the BallTree.  ``p`` encodes the Minkowski\n        p-distance:\n            D = sum((X[i] - X[j]) ** p) ** (1. / p)\n        p must be greater than or equal to 1, so that the triangle\n        inequality will hold.  If ``p == np.inf``, then the distance is\n        equivalent to\n            D = max(X[i] - X[j])\n\n    Examples\n    --------\n    Query for k-nearest neighbors\n\n        # >>> import numpy as np\n        # >>> np.random.seed(0)\n        # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n        # >>> ball_tree = BallTree(X, leaf_size=2)\n        # >>> dist, ind = ball_tree.query(X[0], n_neighbors=3)\n        # >>> print ind  # indices of 3 closest neighbors\n        # [0 3 1]\n        # >>> print dist  # distances to 3 closest neighbors\n        # [ 0.          0.19662693  0.29473397]\n\n    Pickle and Unpickle a ball tree (using protocol = 2).  Note that the\n    state of the tree is saved in the pickle operation: the tree is not\n    rebuilt on un-pickling\n\n        # >>> import numpy as np\n        # >>> import pickle\n        # >>> np.random.seed(0)\n        # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions\n        # >>> ball_tree = BallTree(X, leaf_size=2)\n        # >>> s = pickle.dumps(ball_tree, protocol=2)\n        # >>> ball_tree_copy = pickle.loads(s)\n        # >>> dist, ind = ball_tree_copy.query(X[0], k=3)\n        # >>> print ind  # indices of 3 closest neighbors\n        # [0 3 1]\n        # >>> print dist  # distances to 3 closest neighbors\n        # [ 0.          0.19662693  0.29473397]\n    "), /*tp_doc*/
   __pyx_tp_traverse_7sklearn_9neighbors_9ball_tree_BallTree, /*tp_traverse*/
   __pyx_tp_clear_7sklearn_9neighbors_9ball_tree_BallTree, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -10829,7 +11005,7 @@ static PyMethodDef __pyx_methods[] = {
 static struct PyModuleDef __pyx_moduledef = {
     PyModuleDef_HEAD_INIT,
     __Pyx_NAMESTR("ball_tree"),
-    __Pyx_DOCSTR(__pyx_k_54), /* m_doc */
+    __Pyx_DOCSTR(__pyx_k_52), /* m_doc */
     -1, /* m_size */
     __pyx_methods /* m_methods */,
     NULL, /* m_reload */
@@ -10851,21 +11027,19 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
   {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
   {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
-  {&__pyx_n_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 1},
-  {&__pyx_n_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 1},
+  {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
   {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
-  {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
+  {&__pyx_kp_u_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 1, 0, 0},
   {&__pyx_kp_u_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 1, 0, 0},
   {&__pyx_kp_u_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 1, 0, 0},
   {&__pyx_kp_u_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 1, 0, 0},
-  {&__pyx_kp_u_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 1, 0, 0},
-  {&__pyx_kp_u_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 1, 0, 0},
-  {&__pyx_kp_u_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 1, 0, 0},
-  {&__pyx_n_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 1},
+  {&__pyx_kp_u_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 1, 0, 0},
+  {&__pyx_kp_u_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 1, 0, 0},
+  {&__pyx_n_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 1},
+  {&__pyx_kp_u_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 1, 0, 0},
+  {&__pyx_kp_u_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 1, 0, 0},
   {&__pyx_kp_u_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 1, 0, 0},
   {&__pyx_kp_u_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 1, 0, 0},
-  {&__pyx_kp_u_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 1, 0, 0},
-  {&__pyx_kp_u_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 1, 0, 0},
   {&__pyx_n_s__C, __pyx_k__C, sizeof(__pyx_k__C), 0, 0, 1, 1},
   {&__pyx_n_s__DTYPE, __pyx_k__DTYPE, sizeof(__pyx_k__DTYPE), 0, 0, 1, 1},
   {&__pyx_n_s__ITYPE, __pyx_k__ITYPE, sizeof(__pyx_k__ITYPE), 0, 0, 1, 1},
@@ -10880,78 +11054,48 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__asarray, __pyx_k__asarray, sizeof(__pyx_k__asarray), 0, 0, 1, 1},
   {&__pyx_n_s__atleast_1d, __pyx_k__atleast_1d, sizeof(__pyx_k__atleast_1d), 0, 0, 1, 1},
   {&__pyx_n_s__atleast_2d, __pyx_k__atleast_2d, sizeof(__pyx_k__atleast_2d), 0, 0, 1, 1},
-  {&__pyx_n_s__base, __pyx_k__base, sizeof(__pyx_k__base), 0, 0, 1, 1},
-  {&__pyx_n_s__buf, __pyx_k__buf, sizeof(__pyx_k__buf), 0, 0, 1, 1},
-  {&__pyx_n_s__build_tree_, __pyx_k__build_tree_, sizeof(__pyx_k__build_tree_), 0, 0, 1, 1},
-  {&__pyx_n_s__byteorder, __pyx_k__byteorder, sizeof(__pyx_k__byteorder), 0, 0, 1, 1},
   {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1},
   {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
   {&__pyx_n_s__count_only, __pyx_k__count_only, sizeof(__pyx_k__count_only), 0, 0, 1, 1},
-  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
-  {&__pyx_n_s__descr, __pyx_k__descr, sizeof(__pyx_k__descr), 0, 0, 1, 1},
-  {&__pyx_n_s__dist_p_LB, __pyx_k__dist_p_LB, sizeof(__pyx_k__dist_p_LB), 0, 0, 1, 1},
   {&__pyx_n_s__double, __pyx_k__double, sizeof(__pyx_k__double), 0, 0, 1, 1},
   {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1},
   {&__pyx_n_s__empty, __pyx_k__empty, sizeof(__pyx_k__empty), 0, 0, 1, 1},
   {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1},
-  {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
   {&__pyx_n_s__float64, __pyx_k__float64, sizeof(__pyx_k__float64), 0, 0, 1, 1},
-  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
-  {&__pyx_n_s__heap, __pyx_k__heap, sizeof(__pyx_k__heap), 0, 0, 1, 1},
-  {&__pyx_n_s__i_node, __pyx_k__i_node, sizeof(__pyx_k__i_node), 0, 0, 1, 1},
-  {&__pyx_n_s__idx_array, __pyx_k__idx_array, sizeof(__pyx_k__idx_array), 0, 0, 1, 1},
-  {&__pyx_n_s__idx_end, __pyx_k__idx_end, sizeof(__pyx_k__idx_end), 0, 0, 1, 1},
-  {&__pyx_n_s__idx_start, __pyx_k__idx_start, sizeof(__pyx_k__idx_start), 0, 0, 1, 1},
   {&__pyx_n_s__inf, __pyx_k__inf, sizeof(__pyx_k__inf), 0, 0, 1, 1},
   {&__pyx_n_s__int32, __pyx_k__int32, sizeof(__pyx_k__int32), 0, 0, 1, 1},
-  {&__pyx_n_s__is_leaf, __pyx_k__is_leaf, sizeof(__pyx_k__is_leaf), 0, 0, 1, 1},
-  {&__pyx_n_s__itemsize, __pyx_k__itemsize, sizeof(__pyx_k__itemsize), 0, 0, 1, 1},
   {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1},
   {&__pyx_n_s__leaf_size, __pyx_k__leaf_size, sizeof(__pyx_k__leaf_size), 0, 0, 1, 1},
   {&__pyx_n_s__log2, __pyx_k__log2, sizeof(__pyx_k__log2), 0, 0, 1, 1},
-  {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
-  {&__pyx_n_s__n_levels, __pyx_k__n_levels, sizeof(__pyx_k__n_levels), 0, 0, 1, 1},
-  {&__pyx_n_s__n_nodes, __pyx_k__n_nodes, sizeof(__pyx_k__n_nodes), 0, 0, 1, 1},
-  {&__pyx_n_s__names, __pyx_k__names, sizeof(__pyx_k__names), 0, 0, 1, 1},
-  {&__pyx_n_s__ndim, __pyx_k__ndim, sizeof(__pyx_k__ndim), 0, 0, 1, 1},
   {&__pyx_n_s__newObj, __pyx_k__newObj, sizeof(__pyx_k__newObj), 0, 0, 1, 1},
-  {&__pyx_n_s__node_centroid_arr, __pyx_k__node_centroid_arr, sizeof(__pyx_k__node_centroid_arr), 0, 0, 1, 1},
-  {&__pyx_n_s__node_info_arr, __pyx_k__node_info_arr, sizeof(__pyx_k__node_info_arr), 0, 0, 1, 1},
   {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1},
   {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1},
-  {&__pyx_n_s__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 0, 0, 1, 1},
   {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1},
   {&__pyx_n_s__ones, __pyx_k__ones, sizeof(__pyx_k__ones), 0, 0, 1, 1},
   {&__pyx_n_s__order, __pyx_k__order, sizeof(__pyx_k__order), 0, 0, 1, 1},
   {&__pyx_n_s__p, __pyx_k__p, sizeof(__pyx_k__p), 0, 0, 1, 1},
-  {&__pyx_n_s__query_one_, __pyx_k__query_one_, sizeof(__pyx_k__query_one_), 0, 0, 1, 1},
-  {&__pyx_n_s__query_radius_count_, __pyx_k__query_radius_count_, sizeof(__pyx_k__query_radius_count_), 0, 0, 1, 1},
   {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1},
-  {&__pyx_n_s__radius, __pyx_k__radius, sizeof(__pyx_k__radius), 0, 0, 1, 1},
   {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
-  {&__pyx_n_s__readonly, __pyx_k__readonly, sizeof(__pyx_k__readonly), 0, 0, 1, 1},
   {&__pyx_n_s__reshape, __pyx_k__reshape, sizeof(__pyx_k__reshape), 0, 0, 1, 1},
   {&__pyx_n_s__return_distance, __pyx_k__return_distance, sizeof(__pyx_k__return_distance), 0, 0, 1, 1},
   {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1},
   {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1},
   {&__pyx_n_s__sort_results, __pyx_k__sort_results, sizeof(__pyx_k__sort_results), 0, 0, 1, 1},
-  {&__pyx_n_s__strides, __pyx_k__strides, sizeof(__pyx_k__strides), 0, 0, 1, 1},
-  {&__pyx_n_s__suboffsets, __pyx_k__suboffsets, sizeof(__pyx_k__suboffsets), 0, 0, 1, 1},
-  {&__pyx_n_s__type_num, __pyx_k__type_num, sizeof(__pyx_k__type_num), 0, 0, 1, 1},
   {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1},
   {0, 0, 0, 0, 0, 0, 0}
 };
 static int __Pyx_InitCachedBuiltins(void) {
   __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   return 0;
   __pyx_L1_error:;
   return -1;
 }
 
 static int __Pyx_InitCachedConstants(void) {
+  __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
 
   /* "sklearn/neighbors/ball_tree.pyx":360
@@ -11231,12 +11375,12 @@ static int __Pyx_InitCachedConstants(void) {
  *                                  "allocation is flawed")
  * 
  */
-  __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_39));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
-  PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, ((PyObject *)__pyx_kp_s_38));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39));
+  __pyx_k_tuple_37 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_37));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_36));
+  PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, ((PyObject *)__pyx_kp_s_36));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_36));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37));
 
   /* "sklearn/neighbors/ball_tree.pyx":885
  * 
@@ -11245,96 +11389,96 @@ static int __Pyx_InitCachedConstants(void) {
  * 
  *             elif n_points == 1:
  */
-  __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_41));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
-  PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_s_40));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));
+  __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_39));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
+  PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, ((PyObject *)__pyx_kp_s_38));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39));
 
-  /* "numpy.pxd":206
+  /* "numpy.pxd":211
  *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
  *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
  * 
  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  */
-  __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_43));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_u_42));
-  PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_u_42));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_42));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43));
+  __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_41));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_u_40));
+  PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_u_40));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_40));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));
 
-  /* "numpy.pxd":210
+  /* "numpy.pxd":215
  *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
  *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
  * 
  *             info.buf = PyArray_DATA(self)
  */
-  __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_45));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_u_44));
-  PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_u_44));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_44));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45));
+  __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_43));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_u_42));
+  PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_u_42));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_42));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43));
 
-  /* "numpy.pxd":248
+  /* "numpy.pxd":253
  *                 if ((descr.byteorder == '>' and little_endian) or
  *                     (descr.byteorder == '<' and not little_endian)):
  *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
  *                 if   t == NPY_BYTE:        f = "b"
  *                 elif t == NPY_UBYTE:       f = "B"
  */
-  __pyx_k_tuple_47 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_47));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_u_46));
-  PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_kp_u_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
+  __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_45));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_u_44));
+  PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_u_44));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_44));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45));
 
-  /* "numpy.pxd":787
+  /* "numpy.pxd":795
  * 
  *         if (end - f) - (new_offset - offset[0]) < 15:
  *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
  * 
  *         if ((child.byteorder == '>' and little_endian) or
  */
-  __pyx_k_tuple_50 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_50));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_u_49));
-  PyTuple_SET_ITEM(__pyx_k_tuple_50, 0, ((PyObject *)__pyx_kp_u_49));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_49));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50));
+  __pyx_k_tuple_48 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_48));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_u_47));
+  PyTuple_SET_ITEM(__pyx_k_tuple_48, 0, ((PyObject *)__pyx_kp_u_47));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_47));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48));
 
-  /* "numpy.pxd":791
+  /* "numpy.pxd":799
  *         if ((child.byteorder == '>' and little_endian) or
  *             (child.byteorder == '<' and not little_endian)):
  *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
  *             # One could encode it in the format string and have Cython
  *             # complain instead, BUT: < and > in format strings also imply
  */
-  __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_51));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_u_46));
-  PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_u_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
+  __pyx_k_tuple_49 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_49)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_49));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_u_44));
+  PyTuple_SET_ITEM(__pyx_k_tuple_49, 0, ((PyObject *)__pyx_kp_u_44));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_44));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_49));
 
-  /* "numpy.pxd":811
+  /* "numpy.pxd":819
  *             t = child.type_num
  *             if end - f < 5:
  *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
  * 
  *             # Until ticket #99 is fixed, use integers to avoid warnings
  */
-  __pyx_k_tuple_53 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_53));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_u_52));
-  PyTuple_SET_ITEM(__pyx_k_tuple_53, 0, ((PyObject *)__pyx_kp_u_52));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_52));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53));
+  __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_51));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_u_50));
+  PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_u_50));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_50));
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
   __Pyx_RefNannyFinishContext();
   return 0;
   __pyx_L1_error:;
@@ -11365,8 +11509,8 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __pyx_t_7sklearn_9neighbors_9ball_tree_DTYPE_t __pyx_t_3;
+  __Pyx_RefNannyDeclarations
   #if CYTHON_REFNANNY
-  void* __pyx_refnanny = NULL;
   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
   if (!__Pyx_RefNanny) {
       PyErr_Clear();
@@ -11374,8 +11518,9 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
       if (!__Pyx_RefNanny)
           Py_FatalError("failed to import 'refnanny' module");
   }
-  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_ball_tree(void)", __LINE__, __FILE__);
   #endif
+  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ball_tree(void)");
+  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #ifdef __pyx_binding_PyCFunctionType_USED
@@ -11390,7 +11535,7 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
   #endif
   /*--- Module creation code ---*/
   #if PY_MAJOR_VERSION < 3
-  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("ball_tree"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_54), 0, PYTHON_API_VERSION);
+  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("ball_tree"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_52), 0, PYTHON_API_VERSION);
   #else
   __pyx_m = PyModule_Create(&__pyx_moduledef);
   #endif
@@ -11411,6 +11556,7 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
   /*--- Constants init code ---*/
   if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   /*--- Global init code ---*/
+  /*--- Variable export code ---*/
   /*--- Function export code ---*/
   /*--- Type init code ---*/
   __pyx_vtabptr_7sklearn_9neighbors_9ball_tree_BallTree = &__pyx_vtable_7sklearn_9neighbors_9ball_tree_BallTree;
@@ -11424,11 +11570,12 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
   if (__Pyx_SetAttrString(__pyx_m, "BallTree", (PyObject *)&__pyx_type_7sklearn_9neighbors_9ball_tree_BallTree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_7sklearn_9neighbors_9ball_tree_BallTree = &__pyx_type_7sklearn_9neighbors_9ball_tree_BallTree;
   /*--- Type import code ---*/
-  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Variable import code ---*/
   /*--- Function import code ---*/
   /*--- Execution code ---*/
 
@@ -11439,7 +11586,7 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
  * 
  * cimport numpy as np
  */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -11497,7 +11644,7 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
  *     return obj.__new__(obj)
  * 
  */
-  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_9neighbors_9ball_tree_newObj, NULL, __pyx_n_s_55); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_9neighbors_9ball_tree_newObj, NULL, __pyx_n_s_53); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__newObj, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -11554,22 +11701,24 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
  */
   __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_54), ((PyObject *)__pyx_kp_u_55)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_56), ((PyObject *)__pyx_kp_u_57)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_58), ((PyObject *)__pyx_kp_u_59)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
-  /* "libc/stdio.pxd":1
- * # 7.19 Input/output <stdio.h>             # <<<<<<<<<<<<<<
+  /* "numpy.pxd":971
+ *      arr.base = baseptr
  * 
- * cdef extern from *:
+ * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
+ *     if arr.base is NULL:
+ *         return None
  */
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
   if (__pyx_m) {
-    __Pyx_AddTraceback("init sklearn.neighbors.ball_tree");
+    __Pyx_AddTraceback("init sklearn.neighbors.ball_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
     Py_DECREF(__pyx_m); __pyx_m = 0;
   } else if (!PyErr_Occurred()) {
     PyErr_SetString(PyExc_ImportError, "init sklearn.neighbors.ball_tree");
@@ -11585,11 +11734,34 @@ PyMODINIT_FUNC PyInit_ball_tree(void)
 
 /* Runtime support code */
 
+#if CYTHON_REFNANNY
+static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
+    PyObject *m = NULL, *p = NULL;
+    void *r = NULL;
+    m = PyImport_ImportModule((char *)modname);
+    if (!m) goto end;
+    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
+    if (!p) goto end;
+    r = PyLong_AsVoidPtr(p);
+end:
+    Py_XDECREF(p);
+    Py_XDECREF(m);
+    return (__Pyx_RefNannyAPIStruct *)r;
+}
+#endif /* CYTHON_REFNANNY */
+
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
     PyObject *result;
     result = PyObject_GetAttr(dict, name);
-    if (!result)
-        PyErr_SetObject(PyExc_NameError, name);
+    if (!result) {
+        if (dict != __pyx_b) {
+            PyErr_Clear();
+            result = PyObject_GetAttr(__pyx_b, name);
+        }
+        if (!result) {
+            PyErr_SetObject(PyExc_NameError, name);
+        }
+    }
     return result;
 }
 
@@ -11621,7 +11793,8 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb
 
 
 #if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
+    /* cause is unused */
     Py_XINCREF(type);
     Py_XINCREF(value);
     Py_XINCREF(tb);
@@ -11688,7 +11861,7 @@ raise_error:
 
 #else /* Python 3+ */
 
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
     if (tb == Py_None) {
         tb = 0;
     } else if (tb && !PyTraceBack_Check(tb)) {
@@ -11713,6 +11886,29 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
         goto bad;
     }
 
+    if (cause) {
+        PyObject *fixed_cause;
+        if (PyExceptionClass_Check(cause)) {
+            fixed_cause = PyObject_CallObject(cause, NULL);
+            if (fixed_cause == NULL)
+                goto bad;
+        }
+        else if (PyExceptionInstance_Check(cause)) {
+            fixed_cause = cause;
+            Py_INCREF(fixed_cause);
+        }
+        else {
+            PyErr_SetString(PyExc_TypeError,
+                            "exception causes must derive from "
+                            "BaseException");
+            goto bad;
+        }
+        if (!value) {
+            value = PyObject_CallObject(type, NULL);
+        }
+        PyException_SetCause(value, fixed_cause);
+    }
+
     PyErr_SetObject(type, value);
 
     if (tb) {
@@ -11738,7 +11934,7 @@ static void __Pyx_RaiseArgtupleInvalid(
     Py_ssize_t num_found)
 {
     Py_ssize_t num_expected;
-    const char *number, *more_or_less;
+    const char *more_or_less;
 
     if (num_found < num_min) {
         num_expected = num_min;
@@ -11750,14 +11946,10 @@ static void __Pyx_RaiseArgtupleInvalid(
     if (exact) {
         more_or_less = "exactly";
     }
-    number = (num_expected == 1) ? "" : "s";
     PyErr_Format(PyExc_TypeError,
-        #if PY_VERSION_HEX < 0x02050000
-            "%s() takes %s %d positional argument%s (%d given)",
-        #else
-            "%s() takes %s %zd positional argument%s (%zd given)",
-        #endif
-        func_name, more_or_less, num_expected, number, num_found);
+                 "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
+                 func_name, more_or_less, num_expected,
+                 (num_expected == 1) ? "" : "s", num_found);
 }
 
 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
@@ -11906,27 +12098,23 @@ static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
 }
 
 
-static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
+    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
 }
 
 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
     PyErr_Format(PyExc_ValueError,
-        #if PY_VERSION_HEX < 0x02050000
-                 "need more than %d value%s to unpack", (int)index,
-        #else
-                 "need more than %zd value%s to unpack", index,
-        #endif
-                 (index == 1) ? "" : "s");
+                 "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
+                 index, (index == 1) ? "" : "s");
 }
 
 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
     PyErr_Format(PyExc_ValueError,
-        #if PY_VERSION_HEX < 0x02050000
-            "too many values to unpack (expected %d)", (int)expected);
-        #else
-            "too many values to unpack (expected %zd)", expected);
-        #endif
+                 "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
+}
+
+static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
 }
 
 static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
@@ -11939,7 +12127,7 @@ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
     }
 }
 
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
     PyObject *py_import = 0;
     PyObject *empty_list = 0;
     PyObject *module = 0;
@@ -11963,8 +12151,23 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
     empty_dict = PyDict_New();
     if (!empty_dict)
         goto bad;
+    #if PY_VERSION_HEX >= 0x02050000
+    {
+        PyObject *py_level = PyInt_FromLong(level);
+        if (!py_level)
+            goto bad;
+        module = PyObject_CallFunctionObjArgs(py_import,
+            name, global_dict, empty_dict, list, py_level, NULL);
+        Py_DECREF(py_level);
+    }
+    #else
+    if (level>0) {
+        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
+        goto bad;
+    }
     module = PyObject_CallFunctionObjArgs(py_import,
         name, global_dict, empty_dict, list, NULL);
+    #endif
 bad:
     Py_XDECREF(empty_list);
     Py_XDECREF(py_import);
@@ -12066,7 +12269,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int32(npy_int32 val) {
     } else {
         int one = 1; int little = (int)*(unsigned char *)&one;
         unsigned char *bytes = (unsigned char *)&val;
-        return _PyLong_FromByteArray(bytes, sizeof(npy_int32), 
+        return _PyLong_FromByteArray(bytes, sizeof(npy_int32),
                                      little, !is_unsigned);
     }
 }
@@ -12091,7 +12294,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_Py_intptr_t(Py_intptr_t val) {
     } else {
         int one = 1; int little = (int)*(unsigned char *)&one;
         unsigned char *bytes = (unsigned char *)&val;
-        return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t), 
+        return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
                                      little, !is_unsigned);
     }
 }
@@ -12547,9 +12750,9 @@ static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
                                 "can't convert negative value to unsigned long");
                 return (unsigned long)-1;
             }
-            return PyLong_AsUnsignedLong(x);
+            return (unsigned long)PyLong_AsUnsignedLong(x);
         } else {
-            return PyLong_AsLong(x);
+            return (unsigned long)PyLong_AsLong(x);
         }
     } else {
         unsigned long val;
@@ -12582,9 +12785,9 @@ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObje
                                 "can't convert negative value to unsigned PY_LONG_LONG");
                 return (unsigned PY_LONG_LONG)-1;
             }
-            return PyLong_AsUnsignedLongLong(x);
+            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
         } else {
-            return PyLong_AsLongLong(x);
+            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
         }
     } else {
         unsigned PY_LONG_LONG val;
@@ -12617,9 +12820,9 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
                                 "can't convert negative value to long");
                 return (long)-1;
             }
-            return PyLong_AsUnsignedLong(x);
+            return (long)PyLong_AsUnsignedLong(x);
         } else {
-            return PyLong_AsLong(x);
+            return (long)PyLong_AsLong(x);
         }
     } else {
         long val;
@@ -12652,9 +12855,9 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
                                 "can't convert negative value to PY_LONG_LONG");
                 return (PY_LONG_LONG)-1;
             }
-            return PyLong_AsUnsignedLongLong(x);
+            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
         } else {
-            return PyLong_AsLongLong(x);
+            return (PY_LONG_LONG)PyLong_AsLongLong(x);
         }
     } else {
         PY_LONG_LONG val;
@@ -12687,9 +12890,9 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
                                 "can't convert negative value to signed long");
                 return (signed long)-1;
             }
-            return PyLong_AsUnsignedLong(x);
+            return (signed long)PyLong_AsUnsignedLong(x);
         } else {
-            return PyLong_AsLong(x);
+            return (signed long)PyLong_AsLong(x);
         }
     } else {
         signed long val;
@@ -12722,9 +12925,9 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject*
                                 "can't convert negative value to signed PY_LONG_LONG");
                 return (signed PY_LONG_LONG)-1;
             }
-            return PyLong_AsUnsignedLongLong(x);
+            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
         } else {
-            return PyLong_AsLongLong(x);
+            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
         }
     } else {
         signed PY_LONG_LONG val;
@@ -12736,7 +12939,8 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject*
     }
 }
 
-static void __Pyx_WriteUnraisable(const char *name) {
+static void __Pyx_WriteUnraisable(const char *name, int clineno,
+                                  int lineno, const char *filename) {
     PyObject *old_exc, *old_val, *old_tb;
     PyObject *ctx;
     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
@@ -12754,6 +12958,25 @@ static void __Pyx_WriteUnraisable(const char *name) {
     }
 }
 
+static int __Pyx_check_binary_version(void) {
+    char ctversion[4], rtversion[4];
+    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
+    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
+    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
+        char message[200];
+        PyOS_snprintf(message, sizeof(message),
+                      "compiletime version %s of module '%.100s' "
+                      "does not match runtime version %s",
+                      ctversion, __Pyx_MODULE_NAME, rtversion);
+        #if PY_VERSION_HEX < 0x02050000
+        return PyErr_Warn(NULL, message);
+        #else
+        return PyErr_WarnEx(NULL, message, 1);
+        #endif
+    }
+    return 0;
+}
+
 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
 #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
     PyObject *ob = PyCapsule_New(vtable, 0, 0);
@@ -12774,7 +12997,7 @@ bad:
 #ifndef __PYX_HAVE_RT_ImportType
 #define __PYX_HAVE_RT_ImportType
 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
-    long size, int strict)
+    size_t size, int strict)
 {
     PyObject *py_module = 0;
     PyObject *result = 0;
@@ -12804,17 +13027,17 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
             module_name, class_name);
         goto bad;
     }
-    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
+    if (!strict && ((PyTypeObject *)result)->tp_basicsize > (Py_ssize_t)size) {
         PyOS_snprintf(warning, sizeof(warning),
             "%s.%s size changed, may indicate binary incompatibility",
             module_name, class_name);
         #if PY_VERSION_HEX < 0x02050000
-        PyErr_Warn(NULL, warning);
+        if (PyErr_Warn(NULL, warning) < 0) goto bad;
         #else
-        PyErr_WarnEx(NULL, warning, 0);
+        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
         #endif
     }
-    else if (((PyTypeObject *)result)->tp_basicsize != size) {
+    else if (((PyTypeObject *)result)->tp_basicsize != (Py_ssize_t)size) {
         PyErr_Format(PyExc_ValueError,
             "%s.%s has the wrong size, try recompiling",
             module_name, class_name);
@@ -12824,7 +13047,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
 bad:
     Py_XDECREF(py_module);
     Py_XDECREF(result);
-    return 0;
+    return NULL;
 }
 #endif
 
@@ -12854,7 +13077,8 @@ bad:
 #include "frameobject.h"
 #include "traceback.h"
 
-static void __Pyx_AddTraceback(const char *funcname) {
+static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
+                               int __pyx_lineno, const char *__pyx_filename) {
     PyObject *py_srcfile = 0;
     PyObject *py_funcname = 0;
     PyObject *py_globals = 0;
diff --git a/sklearn/neighbors/ball_tree.pyx b/sklearn/neighbors/ball_tree.pyx
index 3885e8a8a2d17e827db12b7a08bcbe208e7b353e..0309859fe8d7d294c405e38e6e15f8337b8e457c 100644
--- a/sklearn/neighbors/ball_tree.pyx
+++ b/sklearn/neighbors/ball_tree.pyx
@@ -429,32 +429,32 @@ cdef class BallTree(object):
     --------
     Query for k-nearest neighbors
 
-        >>> import numpy as np
-        >>> np.random.seed(0)
-        >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
-        >>> ball_tree = BallTree(X, leaf_size=2)
-        >>> dist, ind = ball_tree.query(X[0], n_neighbors=3)
-        >>> print ind  # indices of 3 closest neighbors
-        [0 3 1]
-        >>> print dist  # distances to 3 closest neighbors
-        [ 0.          0.19662693  0.29473397]
+        # >>> import numpy as np
+        # >>> np.random.seed(0)
+        # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
+        # >>> ball_tree = BallTree(X, leaf_size=2)
+        # >>> dist, ind = ball_tree.query(X[0], n_neighbors=3)
+        # >>> print ind  # indices of 3 closest neighbors
+        # [0 3 1]
+        # >>> print dist  # distances to 3 closest neighbors
+        # [ 0.          0.19662693  0.29473397]
 
     Pickle and Unpickle a ball tree (using protocol = 2).  Note that the
     state of the tree is saved in the pickle operation: the tree is not
     rebuilt on un-pickling
 
-        >>> import numpy as np
-        >>> import pickle
-        >>> np.random.seed(0)
-        >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
-        >>> ball_tree = BallTree(X, leaf_size=2)
-        >>> s = pickle.dumps(ball_tree, protocol=2)
-        >>> ball_tree_copy = pickle.loads(s)
-        >>> dist, ind = ball_tree_copy.query(X[0], k=3)
-        >>> print ind  # indices of 3 closest neighbors
-        [0 3 1]
-        >>> print dist  # distances to 3 closest neighbors
-        [ 0.          0.19662693  0.29473397]
+        # >>> import numpy as np
+        # >>> import pickle
+        # >>> np.random.seed(0)
+        # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
+        # >>> ball_tree = BallTree(X, leaf_size=2)
+        # >>> s = pickle.dumps(ball_tree, protocol=2)
+        # >>> ball_tree_copy = pickle.loads(s)
+        # >>> dist, ind = ball_tree_copy.query(X[0], k=3)
+        # >>> print ind  # indices of 3 closest neighbors
+        # [0 3 1]
+        # >>> print dist  # distances to 3 closest neighbors
+        # [ 0.          0.19662693  0.29473397]
     """
     cdef readonly np.ndarray data
     cdef np.ndarray idx_array
@@ -576,15 +576,15 @@ cdef class BallTree(object):
         --------
         Query for k-nearest neighbors
 
-            >>> import numpy as np
-            >>> np.random.seed(0)
-            >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
-            >>> ball_tree = BallTree(X, leaf_size=2)
-            >>> dist, ind = ball_tree.query(X[0], k=3)
-            >>> print ind  # indices of 3 closest neighbors
-            [0 3 1]
-            >>> print dist  # distances to 3 closest neighbors
-            [ 0.          0.19662693  0.29473397]
+            # >>> import numpy as np
+            # >>> np.random.seed(0)
+            # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
+            # >>> ball_tree = BallTree(X, leaf_size=2)
+            # >>> dist, ind = ball_tree.query(X[0], k=3)
+            # >>> print ind  # indices of 3 closest neighbors
+            # [0 3 1]
+            # >>> print dist  # distances to 3 closest neighbors
+            # [ 0.          0.19662693  0.29473397]
         """
         X = np.asarray(X, dtype=DTYPE, order='C')
         X = np.atleast_2d(X)
@@ -697,15 +697,15 @@ cdef class BallTree(object):
         --------
         Query for neighbors in a given radius
 
-            >>> import numpy as np
-            >>> np.random.seed(0)
-            >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
-            >>> ball_tree = BallTree(X, leaf_size=2)
-            >>> print ball_tree.query_radius(X[0], r=0.3, count_only=True)
-            3
-            >>> ind = ball_tree.query_radius(X[0], r=0.3)
-            >>> print ind  # indices of neighbors within distance 0.3
-            [3 0 1]
+            # >>> import numpy as np
+            # >>> np.random.seed(0)
+            # >>> X = np.random.random((10,3))  # 10 points in 3 dimensions
+            # >>> ball_tree = BallTree(X, leaf_size=2)
+            # >>> print ball_tree.query_radius(X[0], r=0.3, count_only=True)
+            # 3
+            # >>> ind = ball_tree.query_radius(X[0], r=0.3)
+            # >>> print ind  # indices of neighbors within distance 0.3
+            # [3 0 1]
         """
         if count_only and return_distance:
             raise ValueError("count_only and return_distance "