[Yt-svn] yt-commit r796 - trunk/yt/lagos

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Mon Sep 22 01:46:02 PDT 2008


Author: mturk
Date: Mon Sep 22 01:46:01 2008
New Revision: 796
URL: http://yt.spacepope.org/changeset/796

Log:
Added depth-first octree flattening.  More to come on this front.  This is
another Cython checking, where the extension has been commented out in
setup.py, but where we also depend on the C code and not the Cython code.

Also, I think this could be significantly faster.  Right now it takes ~30
seconds for a 5 million-cell run, start to finish.  The output of 'cython -a'
indicates I could be doing quite a bit better, but this will do for now.  Also,
it's a tad bit ugly, and there might be bugs, but I'll figure that out after
Phase Two is complete.



Added:
   trunk/yt/lagos/DepthFirstOctree.c
   trunk/yt/lagos/DepthFirstOctree.pyx
Modified:
   trunk/yt/lagos/HierarchyType.py
   trunk/yt/lagos/setup.py

Added: trunk/yt/lagos/DepthFirstOctree.c
==============================================================================
--- (empty file)
+++ trunk/yt/lagos/DepthFirstOctree.c	Mon Sep 22 01:46:01 2008
@@ -0,0 +1,3022 @@
+/* Generated by Cython 0.9.8.1.1 on Mon Sep 22 10:18:51 2008 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#if PY_VERSION_HEX < 0x02040000
+  #define METH_COEXIST 0
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
+  #define PyNumber_Index(o)    PyNumber_Int(o)
+  #define PyIndex_Check(o)     PyNumber_Check(o)
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+  #define PyVarObject_HEAD_INIT(type, size) \
+          PyObject_HEAD_INIT(type) size,
+  #define PyType_Modified(t)
+
+  typedef struct {
+       void *buf;
+       Py_ssize_t len;
+       int readonly;
+       const char *format;
+       int ndim;
+       Py_ssize_t *shape;
+       Py_ssize_t *strides;
+       Py_ssize_t *suboffsets;
+       Py_ssize_t itemsize;
+       void *internal;
+  } Py_buffer;
+
+  #define PyBUF_SIMPLE 0
+  #define PyBUF_WRITABLE 0x0001
+  #define PyBUF_LOCK 0x0002
+  #define PyBUF_FORMAT 0x0004
+  #define PyBUF_ND 0x0008
+  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+
+#endif
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define Py_TPFLAGS_CHECKTYPES 0
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyString_Type                PyBytes_Type
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
+  #define PyBytes_Type                 PyString_Type
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+#else
+  #define _USE_MATH_DEFINES
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+#define __PYX_HAVE_API__yt__lagos__DepthFirstOctree
+#include "numpy/arrayobject.h"
+
+
+#ifdef __GNUC__
+#define INLINE __inline__
+#elif _WIN32
+#define INLINE __inline
+#else
+#define INLINE 
+#endif
+
+typedef struct {PyObject **p; char *s; long n; char is_unicode; char intern; char is_identifier;} __Pyx_StringTabEntry; /*proto*/
+
+
+
+static int __pyx_skip_dispatch = 0;
+
+
+/* Type Conversion Predeclarations */
+
+#if PY_MAJOR_VERSION < 3
+#define __Pyx_PyBytes_FromString PyString_FromString
+#define __Pyx_PyBytes_AsString   PyString_AsString
+#else
+#define __Pyx_PyBytes_FromString PyBytes_FromString
+#define __Pyx_PyBytes_AsString   PyBytes_AsString
+#endif
+
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
+static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
+static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x);
+static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b);
+
+#define __pyx_PyInt_AsLong(x) (PyInt_CheckExact(x) ? PyInt_AS_LONG(x) : PyInt_AsLong(x))
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+
+static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x);
+static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x);
+static INLINE char __pyx_PyInt_char(PyObject* x);
+static INLINE short __pyx_PyInt_short(PyObject* x);
+static INLINE int __pyx_PyInt_int(PyObject* x);
+static INLINE long __pyx_PyInt_long(PyObject* x);
+static INLINE signed char __pyx_PyInt_signed_char(PyObject* x);
+static INLINE signed short __pyx_PyInt_signed_short(PyObject* x);
+static INLINE signed int __pyx_PyInt_signed_int(PyObject* x);
+static INLINE signed long __pyx_PyInt_signed_long(PyObject* x);
+static INLINE long double __pyx_PyInt_long_double(PyObject* x);
+#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 ... */
+#else /* __GNUC__ */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ */
+    
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+static const char **__pyx_f;
+
+static char __pyx_mdoc[] = "\nThis is a recursive function to return a depth-first octree\n\nAuthor: Matthew Turk <matthewturk at gmail.com>\nAffiliation: KIPAC/SLAC/Stanford\nHomepage: http://yt.enzotools.org/\nLicense:\n  Copyright (C) 2008 Matthew Turk.  All Rights Reserved.\n\n  This file is part of yt.\n\n  yt is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License as published by\n  the Free Software Foundation; either version 3 of the License, or\n  (at your option) any later version.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n";
+static INLINE void __Pyx_SafeReleaseBuffer(PyObject* obj, Py_buffer* info);
+static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf); /*proto*/
+static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts); /*proto*/
+static INLINE const char* __Pyx_BufferTypestringCheckEndian(const char* ts); /*proto*/
+static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim); /*proto*/
+static const char* __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_int_t(const char* ts); /*proto*/
+
+static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int_t(PyObject* obj, Py_buffer* buf, int flags, int nd); /*proto*/
+static const char* __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_float64_t(const char* ts); /*proto*/
+
+static int __Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t(PyObject* obj, Py_buffer* buf, int flags, int nd); /*proto*/
+#define __Pyx_BufPtrStrided1d(buf, i0, s0) ((char*)buf + i0 * s0)
+#define __Pyx_BufPtrStrided3d(buf, i0, s0, i1, s1, i2, s2) ((char*)buf + i0 * s0 + i1 * s1 + i2 * s2)
+
+static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
+
+static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name, int exact); /*proto*/
+
+static INLINE void __Pyx_RaiseArgtupleTooLong(Py_ssize_t num_expected, Py_ssize_t num_found); /*proto*/
+#if (PY_MAJOR_VERSION < 3) && !(Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
+static void __Pyx_ReleaseBuffer(PyObject *obj, Py_buffer *view);
+#else
+#define __Pyx_GetBuffer PyObject_GetBuffer
+#define __Pyx_ReleaseBuffer PyObject_ReleaseBuffer
+#endif
+
+Py_ssize_t __Pyx_zeros[] = {0, 0, 0};
+Py_ssize_t __Pyx_minusones[] = {-1, -1, -1};
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+
+static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
+    PyObject *r;
+    if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) {
+        r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (PyTuple_CheckExact(o) && 0 <= i && i < PyTuple_GET_SIZE(o)) {
+        r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0) || !is_unsigned))
+        r = PySequence_GetItem(o, i);
+    else {
+        PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) : PyLong_FromUnsignedLongLong((sizeof(unsigned long long) > sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i);
+        if (!j)
+            return 0;
+        r = PyObject_GetItem(o, j);
+        Py_DECREF(j);
+    }
+    return r;
+}
+
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
+
+static int __Pyx_Print(PyObject *, int); /*proto*/
+#if PY_MAJOR_VERSION >= 3
+static PyObject* __pyx_print = 0;
+static PyObject* __pyx_print_kwargs = 0;
+#endif
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/
+
+static PyObject *__Pyx_ImportModule(char *name); /*proto*/
+
+static void __Pyx_AddTraceback(const char *funcname); /*proto*/
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+/* Type declarations */
+
+typedef npy_int8 __pyx_t_5numpy_int8_t;
+
+typedef npy_int16 __pyx_t_5numpy_int16_t;
+
+typedef npy_int32 __pyx_t_5numpy_int32_t;
+
+typedef npy_int64 __pyx_t_5numpy_int64_t;
+
+typedef npy_uint8 __pyx_t_5numpy_uint8_t;
+
+typedef npy_uint16 __pyx_t_5numpy_uint16_t;
+
+typedef npy_uint32 __pyx_t_5numpy_uint32_t;
+
+typedef npy_uint64 __pyx_t_5numpy_uint64_t;
+
+typedef npy_float32 __pyx_t_5numpy_float32_t;
+
+typedef npy_float64 __pyx_t_5numpy_float64_t;
+
+typedef npy_long __pyx_t_5numpy_int_t;
+
+typedef npy_longlong __pyx_t_5numpy_long_t;
+
+typedef npy_ulong __pyx_t_5numpy_uint_t;
+
+typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
+
+typedef npy_double __pyx_t_5numpy_float_t;
+
+typedef npy_double __pyx_t_5numpy_double_t;
+
+typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
+
+struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position {
+  PyObject_HEAD
+  int output_pos;
+  int refined_pos;
+};
+
+struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid {
+  PyObject_HEAD
+  PyObject *child_indices;
+  PyObject *field;
+  PyObject *left_edges;
+  PyObject *dimensions;
+  PyObject *dx;
+};
+
+struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList {
+  PyObject_HEAD
+  PyObject *grids;
+};
+/* Module declarations from numpy */
+
+/* Module declarations from numpy */
+
+static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
+/* Module declarations from cython */
+
+/* Module declarations from yt.lagos.DepthFirstOctree */
+
+static PyTypeObject *__pyx_ptype_2yt_5lagos_16DepthFirstOctree_position = 0;
+static PyTypeObject *__pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGrid = 0;
+static PyTypeObject *__pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGridList = 0;
+
+
+/* Implementation of yt.lagos.DepthFirstOctree */
+static char __pyx_k___cinit__[] = "__cinit__";
+static PyObject *__pyx_kp___cinit__;
+static char __pyx_k___getitem__[] = "__getitem__";
+static PyObject *__pyx_kp___getitem__;
+static char __pyx_k_numpy[] = "numpy";
+static PyObject *__pyx_kp_numpy;
+static char __pyx_k_np[] = "np";
+static PyObject *__pyx_kp_np;
+static char __pyx_k_RecurseOctree[] = "RecurseOctree";
+static PyObject *__pyx_kp_RecurseOctree;
+static char __pyx_k___getbuffer__[] = "__getbuffer__";
+static PyObject *__pyx_kp___getbuffer__;
+static char __pyx_k_RuntimeError[] = "RuntimeError";
+static PyObject *__pyx_kp_RuntimeError;
+static char __pyx_k_ValueError[] = "ValueError";
+static PyObject *__pyx_kp_ValueError;
+static PyObject *__pyx_kp_1;
+static PyObject *__pyx_kp_16;
+static PyObject *__pyx_builtin_RuntimeError;
+static PyObject *__pyx_builtin_ValueError;
+static char __pyx_k_1[] = "Py_intptr_t and Py_ssize_t differs in size, numpy.pxd does not support this";
+static char __pyx_k_2[] = "b";
+static char __pyx_k_3[] = "B";
+static char __pyx_k_4[] = "h";
+static char __pyx_k_5[] = "H";
+static char __pyx_k_6[] = "i";
+static char __pyx_k_7[] = "I";
+static char __pyx_k_8[] = "l";
+static char __pyx_k_9[] = "L";
+static char __pyx_k_10[] = "q";
+static char __pyx_k_11[] = "Q";
+static char __pyx_k_12[] = "f";
+static char __pyx_k_13[] = "d";
+static char __pyx_k_14[] = "g";
+static char __pyx_k_15[] = "O";
+static char __pyx_k_16[] = "only objects, int and float dtypes supported for ndarray buffer access so far (dtype is %d)";
+
+static int __pyx_pf_2yt_5lagos_16DepthFirstOctree_10OctreeGrid___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_2yt_5lagos_16DepthFirstOctree_10OctreeGrid___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyArrayObject *__pyx_v_child_indices = 0;
+  PyArrayObject *__pyx_v_field = 0;
+  PyArrayObject *__pyx_v_left_edges = 0;
+  PyArrayObject *__pyx_v_dimensions = 0;
+  PyArrayObject *__pyx_v_dx = 0;
+  Py_buffer __pyx_bstruct_child_indices;
+  Py_ssize_t __pyx_bstride_0_child_indices = 0;
+  Py_ssize_t __pyx_bstride_1_child_indices = 0;
+  Py_ssize_t __pyx_bstride_2_child_indices = 0;
+  Py_ssize_t __pyx_bshape_0_child_indices = 0;
+  Py_ssize_t __pyx_bshape_1_child_indices = 0;
+  Py_ssize_t __pyx_bshape_2_child_indices = 0;
+  Py_buffer __pyx_bstruct_field;
+  Py_ssize_t __pyx_bstride_0_field = 0;
+  Py_ssize_t __pyx_bstride_1_field = 0;
+  Py_ssize_t __pyx_bstride_2_field = 0;
+  Py_ssize_t __pyx_bshape_0_field = 0;
+  Py_ssize_t __pyx_bshape_1_field = 0;
+  Py_ssize_t __pyx_bshape_2_field = 0;
+  Py_buffer __pyx_bstruct_dx;
+  Py_ssize_t __pyx_bstride_0_dx = 0;
+  Py_ssize_t __pyx_bshape_0_dx = 0;
+  Py_buffer __pyx_bstruct_left_edges;
+  Py_ssize_t __pyx_bstride_0_left_edges = 0;
+  Py_ssize_t __pyx_bshape_0_left_edges = 0;
+  Py_buffer __pyx_bstruct_dimensions;
+  Py_ssize_t __pyx_bstride_0_dimensions = 0;
+  Py_ssize_t __pyx_bshape_0_dimensions = 0;
+  int __pyx_r;
+  static char *__pyx_argnames[] = {"child_indices","field","left_edges","dimensions","dx",0};
+  if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 5)) {
+    __pyx_v_child_indices = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
+    __pyx_v_field = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
+    __pyx_v_left_edges = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
+    __pyx_v_dimensions = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
+    __pyx_v_dx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
+  }
+  else {
+    if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOO", __pyx_argnames, &__pyx_v_child_indices, &__pyx_v_field, &__pyx_v_left_edges, &__pyx_v_dimensions, &__pyx_v_dx))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.OctreeGrid.__cinit__");
+  return -1;
+  __pyx_L4:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_indices), __pyx_ptype_5numpy_ndarray, 1, "child_indices", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_field), __pyx_ptype_5numpy_ndarray, 1, "field", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edges), __pyx_ptype_5numpy_ndarray, 1, "left_edges", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dimensions), __pyx_ptype_5numpy_ndarray, 1, "dimensions", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dx), __pyx_ptype_5numpy_ndarray, 1, "dx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_v_child_indices, &__pyx_bstruct_child_indices, PyBUF_FORMAT| PyBUF_STRIDES, 3) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_child_indices = __pyx_bstruct_child_indices.strides[0]; __pyx_bstride_1_child_indices = __pyx_bstruct_child_indices.strides[1]; __pyx_bstride_2_child_indices = __pyx_bstruct_child_indices.strides[2];
+  __pyx_bshape_0_child_indices = __pyx_bstruct_child_indices.shape[0]; __pyx_bshape_1_child_indices = __pyx_bstruct_child_indices.shape[1]; __pyx_bshape_2_child_indices = __pyx_bstruct_child_indices.shape[2];
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_field, &__pyx_bstruct_field, PyBUF_FORMAT| PyBUF_STRIDES, 3) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_field = __pyx_bstruct_field.strides[0]; __pyx_bstride_1_field = __pyx_bstruct_field.strides[1]; __pyx_bstride_2_field = __pyx_bstruct_field.strides[2];
+  __pyx_bshape_0_field = __pyx_bstruct_field.shape[0]; __pyx_bshape_1_field = __pyx_bstruct_field.shape[1]; __pyx_bshape_2_field = __pyx_bstruct_field.shape[2];
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_left_edges, &__pyx_bstruct_left_edges, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_left_edges = __pyx_bstruct_left_edges.strides[0];
+  __pyx_bshape_0_left_edges = __pyx_bstruct_left_edges.shape[0];
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_v_dimensions, &__pyx_bstruct_dimensions, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_dimensions = __pyx_bstruct_dimensions.strides[0];
+  __pyx_bshape_0_dimensions = __pyx_bstruct_dimensions.shape[0];
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_dx, &__pyx_bstruct_dx, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
+  __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];
+  Py_INCREF(((PyObject *)__pyx_v_child_indices));
+  Py_DECREF(((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->child_indices);
+  ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->child_indices = ((PyObject *)__pyx_v_child_indices);
+  Py_INCREF(((PyObject *)__pyx_v_field));
+  Py_DECREF(((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->field);
+  ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->field = ((PyObject *)__pyx_v_field);
+  Py_INCREF(((PyObject *)__pyx_v_left_edges));
+  Py_DECREF(((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->left_edges);
+  ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->left_edges = ((PyObject *)__pyx_v_left_edges);
+  Py_INCREF(((PyObject *)__pyx_v_dimensions));
+  Py_DECREF(((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->dimensions);
+  ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->dimensions = ((PyObject *)__pyx_v_dimensions);
+  Py_INCREF(((PyObject *)__pyx_v_dx));
+  Py_DECREF(((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->dx);
+  ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_v_self)->dx = ((PyObject *)__pyx_v_dx);
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
+    PyErr_Fetch(&__pyx_type, &__pyx_value, &__pyx_tb);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_indices, &__pyx_bstruct_child_indices);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_field, &__pyx_bstruct_field);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dx, &__pyx_bstruct_dx);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_left_edges, &__pyx_bstruct_left_edges);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dimensions, &__pyx_bstruct_dimensions);
+  PyErr_Restore(__pyx_type, __pyx_value, __pyx_tb);}
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.OctreeGrid.__cinit__");
+  __pyx_r = -1;
+  goto __pyx_L2;
+  __pyx_L0:;
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_indices, &__pyx_bstruct_child_indices);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_field, &__pyx_bstruct_field);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dx, &__pyx_bstruct_dx);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_left_edges, &__pyx_bstruct_left_edges);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dimensions, &__pyx_bstruct_dimensions);
+  __pyx_L2:;
+  return __pyx_r;
+}
+
+static int __pyx_pf_2yt_5lagos_16DepthFirstOctree_14OctreeGridList___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_2yt_5lagos_16DepthFirstOctree_14OctreeGridList___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_grids = 0;
+  int __pyx_r;
+  static char *__pyx_argnames[] = {"grids",0};
+  if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 1)) {
+    __pyx_v_grids = PyTuple_GET_ITEM(__pyx_args, 0);
+  }
+  else {
+    if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_grids))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.OctreeGridList.__cinit__");
+  return -1;
+  __pyx_L4:;
+  Py_INCREF(__pyx_v_grids);
+  Py_DECREF(((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)__pyx_v_self)->grids);
+  ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)__pyx_v_self)->grids = __pyx_v_grids;
+
+  __pyx_r = 0;
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_2yt_5lagos_16DepthFirstOctree_14OctreeGridList___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_item); /*proto*/
+static PyObject *__pyx_pf_2yt_5lagos_16DepthFirstOctree_14OctreeGridList___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_item) {
+  int __pyx_v_item;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  assert(__pyx_arg_item); {
+    __pyx_v_item = __pyx_PyInt_int(__pyx_arg_item); if (unlikely((__pyx_v_item == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.OctreeGridList.__getitem__");
+  return NULL;
+  __pyx_L4:;
+  __pyx_1 = __Pyx_GetItemInt(((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)__pyx_v_self)->grids, __pyx_v_item, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_1;
+  __pyx_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_1);
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.OctreeGridList.__getitem__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_2yt_5lagos_16DepthFirstOctree_WalkRootgrid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_2yt_5lagos_16DepthFirstOctree_WalkRootgrid[] = "\n    This function only gets called on a 'root grid' -- a base grid\n    of the simulation we are converting.  It will call a recursive walker.\n    ";
+static PyObject *__pyx_pf_2yt_5lagos_16DepthFirstOctree_WalkRootgrid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyArrayObject *__pyx_v_output = 0;
+  PyArrayObject *__pyx_v_refined = 0;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *__pyx_v_grids = 0;
+  int __pyx_v_pi;
+  int __pyx_v_s;
+  int __pyx_v_r;
+  int __pyx_v_i;
+  int __pyx_v_j;
+  int __pyx_v_k;
+  int __pyx_v_gi;
+  int __pyx_v_child_i;
+  int __pyx_v_child_j;
+  int __pyx_v_child_k;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *__pyx_v_child_grid;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *__pyx_v_grid = 0;
+  PyArrayObject *__pyx_v_child_indices = 0;
+  PyArrayObject *__pyx_v_dimensions = 0;
+  PyArrayObject *__pyx_v_field = 0;
+  PyArrayObject *__pyx_v_leftedges = 0;
+  PyArrayObject *__pyx_v_dx = 0;
+  PyArrayObject *__pyx_v_child_dx;
+  PyArrayObject *__pyx_v_child_leftedges;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position *__pyx_v_curpos;
+  Py_buffer __pyx_bstruct_leftedges;
+  Py_ssize_t __pyx_bstride_0_leftedges = 0;
+  Py_ssize_t __pyx_bshape_0_leftedges = 0;
+  Py_buffer __pyx_bstruct_dx;
+  Py_ssize_t __pyx_bstride_0_dx = 0;
+  Py_ssize_t __pyx_bshape_0_dx = 0;
+  Py_buffer __pyx_bstruct_refined;
+  Py_ssize_t __pyx_bstride_0_refined = 0;
+  Py_ssize_t __pyx_bshape_0_refined = 0;
+  Py_buffer __pyx_bstruct_dimensions;
+  Py_ssize_t __pyx_bstride_0_dimensions = 0;
+  Py_ssize_t __pyx_bshape_0_dimensions = 0;
+  Py_buffer __pyx_bstruct_child_dx;
+  Py_ssize_t __pyx_bstride_0_child_dx = 0;
+  Py_ssize_t __pyx_bshape_0_child_dx = 0;
+  Py_buffer __pyx_bstruct_field;
+  Py_ssize_t __pyx_bstride_0_field = 0;
+  Py_ssize_t __pyx_bstride_1_field = 0;
+  Py_ssize_t __pyx_bstride_2_field = 0;
+  Py_ssize_t __pyx_bshape_0_field = 0;
+  Py_ssize_t __pyx_bshape_1_field = 0;
+  Py_ssize_t __pyx_bshape_2_field = 0;
+  Py_buffer __pyx_bstruct_child_leftedges;
+  Py_ssize_t __pyx_bstride_0_child_leftedges = 0;
+  Py_ssize_t __pyx_bshape_0_child_leftedges = 0;
+  Py_buffer __pyx_bstruct_child_indices;
+  Py_ssize_t __pyx_bstride_0_child_indices = 0;
+  Py_ssize_t __pyx_bstride_1_child_indices = 0;
+  Py_ssize_t __pyx_bstride_2_child_indices = 0;
+  Py_ssize_t __pyx_bshape_0_child_indices = 0;
+  Py_ssize_t __pyx_bshape_1_child_indices = 0;
+  Py_ssize_t __pyx_bshape_2_child_indices = 0;
+  Py_buffer __pyx_bstruct_output;
+  Py_ssize_t __pyx_bstride_0_output = 0;
+  Py_ssize_t __pyx_bshape_0_output = 0;
+  PyObject *__pyx_r;
+  long __pyx_1;
+  PyObject *__pyx_2 = 0;
+  __pyx_t_5numpy_int_t __pyx_3;
+  PyObject *__pyx_4 = 0;
+  __pyx_t_5numpy_int_t __pyx_5;
+  __pyx_t_5numpy_int_t __pyx_6;
+  __pyx_t_5numpy_int_t __pyx_7;
+  int __pyx_8;
+  __pyx_t_5numpy_float64_t __pyx_9;
+  PyObject *__pyx_10 = 0;
+  int __pyx_11;
+  PyObject *__pyx_12 = 0;
+  PyObject *__pyx_13 = 0;
+  PyObject *__pyx_14 = 0;
+  PyObject *__pyx_15 = 0;
+  PyArrayObject *__pyx_t_1 = NULL;
+  PyArrayObject *__pyx_t_2 = NULL;
+  PyArrayObject *__pyx_t_3 = NULL;
+  PyArrayObject *__pyx_t_4 = NULL;
+  PyArrayObject *__pyx_t_5 = NULL;
+  long __pyx_t_6;
+  long __pyx_t_7;
+  long __pyx_t_8;
+  int __pyx_t_9;
+  int __pyx_t_10;
+  int __pyx_t_11;
+  int __pyx_t_12;
+  int __pyx_t_13;
+  int __pyx_t_14;
+  int __pyx_t_15;
+  int __pyx_t_16;
+  int __pyx_t_17;
+  PyArrayObject *__pyx_t_18 = NULL;
+  int __pyx_t_19;
+  PyObject *__pyx_t_20 = NULL;
+  PyObject *__pyx_t_21 = NULL;
+  PyObject *__pyx_t_22 = NULL;
+  PyArrayObject *__pyx_t_23 = NULL;
+  long __pyx_t_24;
+  long __pyx_t_25;
+  long __pyx_t_26;
+  long __pyx_t_27;
+  long __pyx_t_28;
+  long __pyx_t_29;
+  static char *__pyx_argnames[] = {"output","refined","grids","pi","s","r",0};
+  __pyx_self = __pyx_self;
+  __pyx_v_s = 0;
+  __pyx_v_r = 0;
+  if (likely(!__pyx_kwds) && likely(4 <= PyTuple_GET_SIZE(__pyx_args)) && likely(PyTuple_GET_SIZE(__pyx_args) <= 6)) {
+    __pyx_v_output = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
+    __pyx_v_refined = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
+    __pyx_v_grids = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)PyTuple_GET_ITEM(__pyx_args, 2));
+    __pyx_v_pi = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_pi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    if (PyTuple_GET_SIZE(__pyx_args) > 4) {
+      __pyx_v_s = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_s == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (PyTuple_GET_SIZE(__pyx_args) > 5) {
+        __pyx_v_r = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_r == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+  }
+  else {
+    if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOi|ii", __pyx_argnames, &__pyx_v_output, &__pyx_v_refined, &__pyx_v_grids, &__pyx_v_pi, &__pyx_v_s, &__pyx_v_r))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.WalkRootgrid");
+  return NULL;
+  __pyx_L4:;
+  __pyx_v_child_grid = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_child_indices.buf = NULL;
+  __pyx_bstruct_dimensions.buf = NULL;
+  __pyx_bstruct_field.buf = NULL;
+  __pyx_bstruct_leftedges.buf = NULL;
+  __pyx_bstruct_dx.buf = NULL;
+  __pyx_v_child_dx = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_child_dx.buf = NULL;
+  __pyx_v_child_leftedges = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_child_leftedges.buf = NULL;
+  __pyx_v_curpos = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position *)Py_None); Py_INCREF(Py_None);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output), __pyx_ptype_5numpy_ndarray, 1, "output", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_refined), __pyx_ptype_5numpy_ndarray, 1, "refined", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grids), __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGridList, 1, "grids", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_output, &__pyx_bstruct_output, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_output = __pyx_bstruct_output.strides[0];
+  __pyx_bshape_0_output = __pyx_bstruct_output.shape[0];
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_v_refined, &__pyx_bstruct_refined, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_refined = __pyx_bstruct_refined.strides[0];
+  __pyx_bshape_0_refined = __pyx_bstruct_refined.shape[0];
+  __pyx_1 = (__pyx_v_pi - 1);
+  __pyx_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGrid))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_grid = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_2);
+  __pyx_2 = 0;
+  if (!(__Pyx_TypeTest(__pyx_v_grid->child_indices, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyArrayObject *)__pyx_v_grid->child_indices);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_t_1, &__pyx_bstruct_child_indices, PyBUF_FORMAT| PyBUF_STRIDES, 3) == -1)) {
+    __pyx_v_child_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_child_indices.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_child_indices = __pyx_bstruct_child_indices.strides[0]; __pyx_bstride_1_child_indices = __pyx_bstruct_child_indices.strides[1]; __pyx_bstride_2_child_indices = __pyx_bstruct_child_indices.strides[2];
+    __pyx_bshape_0_child_indices = __pyx_bstruct_child_indices.shape[0]; __pyx_bshape_1_child_indices = __pyx_bstruct_child_indices.shape[1]; __pyx_bshape_2_child_indices = __pyx_bstruct_child_indices.shape[2];
+  }
+  __pyx_t_1 = 0;
+  Py_INCREF(__pyx_v_grid->child_indices);
+  __pyx_v_child_indices = ((PyArrayObject *)__pyx_v_grid->child_indices);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->dimensions, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyArrayObject *)__pyx_v_grid->dimensions);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_t_2, &__pyx_bstruct_dimensions, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+    __pyx_v_dimensions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_dimensions.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_dimensions = __pyx_bstruct_dimensions.strides[0];
+    __pyx_bshape_0_dimensions = __pyx_bstruct_dimensions.shape[0];
+  }
+  __pyx_t_2 = 0;
+  Py_INCREF(__pyx_v_grid->dimensions);
+  __pyx_v_dimensions = ((PyArrayObject *)__pyx_v_grid->dimensions);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->field, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = ((PyArrayObject *)__pyx_v_grid->field);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_3, &__pyx_bstruct_field, PyBUF_FORMAT| PyBUF_STRIDES, 3) == -1)) {
+    __pyx_v_field = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_field.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_field = __pyx_bstruct_field.strides[0]; __pyx_bstride_1_field = __pyx_bstruct_field.strides[1]; __pyx_bstride_2_field = __pyx_bstruct_field.strides[2];
+    __pyx_bshape_0_field = __pyx_bstruct_field.shape[0]; __pyx_bshape_1_field = __pyx_bstruct_field.shape[1]; __pyx_bshape_2_field = __pyx_bstruct_field.shape[2];
+  }
+  __pyx_t_3 = 0;
+  Py_INCREF(__pyx_v_grid->field);
+  __pyx_v_field = ((PyArrayObject *)__pyx_v_grid->field);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->left_edges, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = ((PyArrayObject *)__pyx_v_grid->left_edges);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_4, &__pyx_bstruct_leftedges, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+    __pyx_v_leftedges = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_leftedges.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_leftedges = __pyx_bstruct_leftedges.strides[0];
+    __pyx_bshape_0_leftedges = __pyx_bstruct_leftedges.shape[0];
+  }
+  __pyx_t_4 = 0;
+  Py_INCREF(__pyx_v_grid->left_edges);
+  __pyx_v_leftedges = ((PyArrayObject *)__pyx_v_grid->left_edges);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->dx, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = ((PyArrayObject *)__pyx_v_grid->dx);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_5, &__pyx_bstruct_dx, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+    __pyx_v_dx = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_dx.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
+    __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];
+  }
+  __pyx_t_5 = 0;
+  Py_INCREF(__pyx_v_grid->dx);
+  __pyx_v_dx = ((PyArrayObject *)__pyx_v_grid->dx);
+  __pyx_v_curpos->output_pos = __pyx_v_s;
+  __pyx_v_curpos->refined_pos = __pyx_v_r;
+  __pyx_t_6 = 2;
+  if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_bshape_0_dimensions;
+  __pyx_3 = *((__pyx_t_5numpy_int_t *)((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_dimensions.buf, __pyx_t_6, __pyx_bstride_0_dimensions)));
+  for (__pyx_v_k = 0; __pyx_v_k < __pyx_3; __pyx_v_k+=1) {
+    __pyx_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
+    __pyx_2 = 0;
+    if (__Pyx_Print(((PyObject *)__pyx_4), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
+    __pyx_t_7 = 1;
+    if (__pyx_t_7 < 0) __pyx_t_7 += __pyx_bshape_0_dimensions;
+    __pyx_5 = *((__pyx_t_5numpy_int_t *)((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_dimensions.buf, __pyx_t_7, __pyx_bstride_0_dimensions)));
+    for (__pyx_v_j = 0; __pyx_v_j < __pyx_5; __pyx_v_j+=1) {
+      __pyx_t_8 = 0;
+      if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_bshape_0_dimensions;
+      __pyx_6 = *((__pyx_t_5numpy_int_t *)((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_dimensions.buf, __pyx_t_8, __pyx_bstride_0_dimensions)));
+      for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; __pyx_v_i+=1) {
+        __pyx_t_9 = __pyx_v_i;
+        __pyx_t_10 = __pyx_v_j;
+        __pyx_t_11 = __pyx_v_k;
+        if (__pyx_t_9 < 0) __pyx_t_9 += __pyx_bshape_0_child_indices;
+        if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_bshape_1_child_indices;
+        if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_bshape_2_child_indices;
+        __pyx_7 = *((__pyx_t_5numpy_int_t *)((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided3d(__pyx_bstruct_child_indices.buf, __pyx_t_9, __pyx_bstride_0_child_indices, __pyx_t_10, __pyx_bstride_1_child_indices, __pyx_t_11, __pyx_bstride_2_child_indices)));
+        __pyx_v_gi = __pyx_7;
+        __pyx_8 = (__pyx_v_gi == -1);
+        if (__pyx_8) {
+          __pyx_t_12 = __pyx_v_i;
+          __pyx_t_13 = __pyx_v_j;
+          __pyx_t_14 = __pyx_v_k;
+          if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_0_field;
+          if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_bshape_1_field;
+          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_bshape_2_field;
+          __pyx_9 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided3d(__pyx_bstruct_field.buf, __pyx_t_12, __pyx_bstride_0_field, __pyx_t_13, __pyx_bstride_1_field, __pyx_t_14, __pyx_bstride_2_field)));
+          __pyx_t_15 = __pyx_v_curpos->output_pos;
+          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_output;
+          *((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_output.buf, __pyx_t_15, __pyx_bstride_0_output)) = __pyx_9;
+          __pyx_t_16 = __pyx_v_curpos->refined_pos;
+          if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_0_refined;
+          *((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_refined.buf, __pyx_t_16, __pyx_bstride_0_refined)) = 0;
+          __pyx_v_curpos->output_pos += 1;
+          __pyx_v_curpos->refined_pos += 1;
+          goto __pyx_L11;
+        }
+        /*else*/ {
+          __pyx_t_17 = __pyx_v_curpos->refined_pos;
+          if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_bshape_0_refined;
+          *((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_refined.buf, __pyx_t_17, __pyx_bstride_0_refined)) = 1;
+          __pyx_v_curpos->refined_pos += 1;
+          __pyx_1 = (__pyx_v_gi - 1);
+          __pyx_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGrid))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(((PyObject *)__pyx_v_child_grid));
+          __pyx_v_child_grid = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_2);
+          __pyx_2 = 0;
+          if (!(__Pyx_TypeTest(__pyx_v_child_grid->dx, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_18 = ((PyArrayObject *)__pyx_v_child_grid->dx);
+          __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx);
+          __pyx_t_19 = __Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_18, &__pyx_bstruct_child_dx, PyBUF_FORMAT| PyBUF_STRIDES, 1);
+          if (unlikely(__pyx_t_19 < 0)) 
+          {
+              PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
+              if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+                  Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
+                  __Pyx_RaiseBufferFallbackError();
+                } else {
+                  PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
+              }
+          }
+          __pyx_bstride_0_child_dx = __pyx_bstruct_child_dx.strides[0];
+          __pyx_bshape_0_child_dx = __pyx_bstruct_child_dx.shape[0];
+          if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_18 = 0;
+          Py_INCREF(__pyx_v_child_grid->dx);
+          Py_DECREF(((PyObject *)__pyx_v_child_dx));
+          __pyx_v_child_dx = ((PyArrayObject *)__pyx_v_child_grid->dx);
+          if (!(__Pyx_TypeTest(__pyx_v_child_grid->left_edges, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_23 = ((PyArrayObject *)__pyx_v_child_grid->left_edges);
+          __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges);
+          __pyx_t_19 = __Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_23, &__pyx_bstruct_child_leftedges, PyBUF_FORMAT| PyBUF_STRIDES, 1);
+          if (unlikely(__pyx_t_19 < 0)) 
+          {
+              PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
+              if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+                  Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
+                  __Pyx_RaiseBufferFallbackError();
+                } else {
+                  PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
+              }
+          }
+          __pyx_bstride_0_child_leftedges = __pyx_bstruct_child_leftedges.strides[0];
+          __pyx_bshape_0_child_leftedges = __pyx_bstruct_child_leftedges.shape[0];
+          if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_23 = 0;
+          Py_INCREF(__pyx_v_child_grid->left_edges);
+          Py_DECREF(((PyObject *)__pyx_v_child_leftedges));
+          __pyx_v_child_leftedges = ((PyArrayObject *)__pyx_v_child_grid->left_edges);
+          __pyx_t_24 = 0;
+          if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_bshape_0_leftedges;
+          __pyx_9 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_leftedges.buf, __pyx_t_24, __pyx_bstride_0_leftedges)));
+          __pyx_4 = PyFloat_FromDouble(__pyx_9); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_10 = PyNumber_Multiply(__pyx_2, ((PyObject *)__pyx_v_dx)); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_2 = PyNumber_Add(__pyx_4, __pyx_10); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+          __pyx_t_25 = 0;
+          if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_bshape_0_child_leftedges;
+          __pyx_9 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_child_leftedges.buf, __pyx_t_25, __pyx_bstride_0_child_leftedges)));
+          __pyx_4 = PyFloat_FromDouble(__pyx_9); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_10 = PyNumber_Subtract(__pyx_2, __pyx_4); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          __pyx_2 = __Pyx_PyNumber_Divide(__pyx_10, ((PyObject *)__pyx_v_child_dx)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+          __pyx_11 = __pyx_PyInt_int(__pyx_2); if (unlikely((__pyx_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_v_child_i = __pyx_11;
+          __pyx_t_26 = 1;
+          if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_bshape_0_leftedges;
+          __pyx_9 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_leftedges.buf, __pyx_t_26, __pyx_bstride_0_leftedges)));
+          __pyx_4 = PyFloat_FromDouble(__pyx_9); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_10 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyNumber_Multiply(__pyx_10, ((PyObject *)__pyx_v_dx)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+          __pyx_10 = PyNumber_Add(__pyx_4, __pyx_2); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_t_27 = 1;
+          if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_bshape_0_child_leftedges;
+          __pyx_9 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_child_leftedges.buf, __pyx_t_27, __pyx_bstride_0_child_leftedges)));
+          __pyx_4 = PyFloat_FromDouble(__pyx_9); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyNumber_Subtract(__pyx_10, __pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          __pyx_10 = __Pyx_PyNumber_Divide(__pyx_2, ((PyObject *)__pyx_v_child_dx)); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_11 = __pyx_PyInt_int(__pyx_10); if (unlikely((__pyx_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+          __pyx_v_child_j = __pyx_11;
+          __pyx_t_28 = 2;
+          if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_bshape_0_leftedges;
+          __pyx_9 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_leftedges.buf, __pyx_t_28, __pyx_bstride_0_leftedges)));
+          __pyx_4 = PyFloat_FromDouble(__pyx_9); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_10 = PyNumber_Multiply(__pyx_2, ((PyObject *)__pyx_v_dx)); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_2 = PyNumber_Add(__pyx_4, __pyx_10); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+          __pyx_t_29 = 2;
+          if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_bshape_0_child_leftedges;
+          __pyx_9 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_child_leftedges.buf, __pyx_t_29, __pyx_bstride_0_child_leftedges)));
+          __pyx_4 = PyFloat_FromDouble(__pyx_9); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_10 = PyNumber_Subtract(__pyx_2, __pyx_4); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          __pyx_2 = __Pyx_PyNumber_Divide(__pyx_10, ((PyObject *)__pyx_v_child_dx)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+          __pyx_11 = __pyx_PyInt_int(__pyx_2); if (unlikely((__pyx_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_v_child_k = __pyx_11;
+          __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_RecurseOctree); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_10 = PyInt_FromLong(__pyx_v_child_i); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyInt_FromLong(__pyx_v_child_j); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_12 = PyInt_FromLong(__pyx_v_child_k); if (unlikely(!__pyx_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_13 = PyInt_FromLong(__pyx_v_gi); if (unlikely(!__pyx_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_14 = PyInt_FromLong(__pyx_v_pi); if (unlikely(!__pyx_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_15 = PyTuple_New(9); if (unlikely(!__pyx_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          PyTuple_SET_ITEM(__pyx_15, 0, __pyx_10);
+          PyTuple_SET_ITEM(__pyx_15, 1, __pyx_2);
+          PyTuple_SET_ITEM(__pyx_15, 2, __pyx_12);
+          Py_INCREF(((PyObject *)__pyx_v_curpos));
+          PyTuple_SET_ITEM(__pyx_15, 3, ((PyObject *)__pyx_v_curpos));
+          PyTuple_SET_ITEM(__pyx_15, 4, __pyx_13);
+          PyTuple_SET_ITEM(__pyx_15, 5, __pyx_14);
+          Py_INCREF(((PyObject *)__pyx_v_output));
+          PyTuple_SET_ITEM(__pyx_15, 6, ((PyObject *)__pyx_v_output));
+          Py_INCREF(((PyObject *)__pyx_v_refined));
+          PyTuple_SET_ITEM(__pyx_15, 7, ((PyObject *)__pyx_v_refined));
+          Py_INCREF(((PyObject *)__pyx_v_grids));
+          PyTuple_SET_ITEM(__pyx_15, 8, ((PyObject *)__pyx_v_grids));
+          __pyx_10 = 0;
+          __pyx_2 = 0;
+          __pyx_12 = 0;
+          __pyx_13 = 0;
+          __pyx_14 = 0;
+          __pyx_10 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_15), NULL); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          Py_DECREF(((PyObject *)__pyx_15)); __pyx_15 = 0;
+          Py_DECREF(__pyx_10); __pyx_10 = 0;
+        }
+        __pyx_L11:;
+      }
+    }
+  }
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_4);
+  Py_XDECREF(__pyx_10);
+  Py_XDECREF(__pyx_12);
+  Py_XDECREF(__pyx_13);
+  Py_XDECREF(__pyx_14);
+  Py_XDECREF(__pyx_15);
+  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
+    PyErr_Fetch(&__pyx_type, &__pyx_value, &__pyx_tb);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_leftedges, &__pyx_bstruct_leftedges);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dx, &__pyx_bstruct_dx);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_refined, &__pyx_bstruct_refined);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dimensions, &__pyx_bstruct_dimensions);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_field, &__pyx_bstruct_field);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_indices, &__pyx_bstruct_child_indices);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_output, &__pyx_bstruct_output);
+  PyErr_Restore(__pyx_type, __pyx_value, __pyx_tb);}
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.WalkRootgrid");
+  __pyx_r = NULL;
+  goto __pyx_L2;
+  __pyx_L0:;
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_leftedges, &__pyx_bstruct_leftedges);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dx, &__pyx_bstruct_dx);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_refined, &__pyx_bstruct_refined);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dimensions, &__pyx_bstruct_dimensions);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_field, &__pyx_bstruct_field);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_indices, &__pyx_bstruct_child_indices);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_output, &__pyx_bstruct_output);
+  __pyx_L2:;
+  Py_DECREF(__pyx_v_child_grid);
+  Py_XDECREF(__pyx_v_grid);
+  Py_XDECREF(__pyx_v_child_indices);
+  Py_XDECREF(__pyx_v_dimensions);
+  Py_XDECREF(__pyx_v_field);
+  Py_XDECREF(__pyx_v_leftedges);
+  Py_XDECREF(__pyx_v_dx);
+  Py_DECREF(__pyx_v_child_dx);
+  Py_DECREF(__pyx_v_child_leftedges);
+  Py_DECREF(__pyx_v_curpos);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_2yt_5lagos_16DepthFirstOctree_RecurseOctree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_2yt_5lagos_16DepthFirstOctree_RecurseOctree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_v_i_i;
+  int __pyx_v_j_i;
+  int __pyx_v_k_i;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position *__pyx_v_curpos = 0;
+  int __pyx_v_gi;
+  int __pyx_v_pi;
+  PyArrayObject *__pyx_v_output = 0;
+  PyArrayObject *__pyx_v_refined = 0;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *__pyx_v_grids = 0;
+  int __pyx_v_i;
+  int __pyx_v_i_off;
+  int __pyx_v_j;
+  int __pyx_v_j_off;
+  int __pyx_v_k;
+  int __pyx_v_k_off;
+  int __pyx_v_ci;
+  PyObject *__pyx_v_child_i;
+  PyObject *__pyx_v_child_j;
+  PyObject *__pyx_v_child_k;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *__pyx_v_child_grid;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *__pyx_v_grid = 0;
+  PyArrayObject *__pyx_v_child_indices = 0;
+  PyArrayObject *__pyx_v_dimensions = 0;
+  PyArrayObject *__pyx_v_field = 0;
+  PyArrayObject *__pyx_v_leftedges = 0;
+  PyArrayObject *__pyx_v_dx = 0;
+  PyArrayObject *__pyx_v_child_dx;
+  PyArrayObject *__pyx_v_child_leftedges;
+  PyObject *__pyx_v_s;
+  Py_buffer __pyx_bstruct_dx;
+  Py_ssize_t __pyx_bstride_0_dx = 0;
+  Py_ssize_t __pyx_bshape_0_dx = 0;
+  Py_buffer __pyx_bstruct_leftedges;
+  Py_ssize_t __pyx_bstride_0_leftedges = 0;
+  Py_ssize_t __pyx_bshape_0_leftedges = 0;
+  Py_buffer __pyx_bstruct_refined;
+  Py_ssize_t __pyx_bstride_0_refined = 0;
+  Py_ssize_t __pyx_bshape_0_refined = 0;
+  Py_buffer __pyx_bstruct_child_dx;
+  Py_ssize_t __pyx_bstride_0_child_dx = 0;
+  Py_ssize_t __pyx_bshape_0_child_dx = 0;
+  Py_buffer __pyx_bstruct_field;
+  Py_ssize_t __pyx_bstride_0_field = 0;
+  Py_ssize_t __pyx_bstride_1_field = 0;
+  Py_ssize_t __pyx_bstride_2_field = 0;
+  Py_ssize_t __pyx_bshape_0_field = 0;
+  Py_ssize_t __pyx_bshape_1_field = 0;
+  Py_ssize_t __pyx_bshape_2_field = 0;
+  Py_buffer __pyx_bstruct_child_leftedges;
+  Py_ssize_t __pyx_bstride_0_child_leftedges = 0;
+  Py_ssize_t __pyx_bshape_0_child_leftedges = 0;
+  Py_buffer __pyx_bstruct_dimensions;
+  Py_ssize_t __pyx_bstride_0_dimensions = 0;
+  Py_ssize_t __pyx_bshape_0_dimensions = 0;
+  Py_buffer __pyx_bstruct_child_indices;
+  Py_ssize_t __pyx_bstride_0_child_indices = 0;
+  Py_ssize_t __pyx_bstride_1_child_indices = 0;
+  Py_ssize_t __pyx_bstride_2_child_indices = 0;
+  Py_ssize_t __pyx_bshape_0_child_indices = 0;
+  Py_ssize_t __pyx_bshape_1_child_indices = 0;
+  Py_ssize_t __pyx_bshape_2_child_indices = 0;
+  Py_buffer __pyx_bstruct_output;
+  Py_ssize_t __pyx_bstride_0_output = 0;
+  Py_ssize_t __pyx_bshape_0_output = 0;
+  PyObject *__pyx_r;
+  long __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  PyObject *__pyx_5 = 0;
+  int __pyx_6;
+  int __pyx_7;
+  __pyx_t_5numpy_float64_t __pyx_8;
+  PyArrayObject *__pyx_t_1 = NULL;
+  PyArrayObject *__pyx_t_2 = NULL;
+  PyArrayObject *__pyx_t_3 = NULL;
+  PyArrayObject *__pyx_t_4 = NULL;
+  PyArrayObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  int __pyx_t_8;
+  PyArrayObject *__pyx_t_9 = NULL;
+  int __pyx_t_10;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyArrayObject *__pyx_t_14 = NULL;
+  long __pyx_t_15;
+  long __pyx_t_16;
+  long __pyx_t_17;
+  long __pyx_t_18;
+  long __pyx_t_19;
+  long __pyx_t_20;
+  static char *__pyx_argnames[] = {"i_i","j_i","k_i","curpos","gi","pi","output","refined","grids",0};
+  __pyx_self = __pyx_self;
+  if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 9)) {
+    __pyx_v_i_i = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_i_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_j_i = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_j_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_k_i = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_k_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_curpos = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position *)PyTuple_GET_ITEM(__pyx_args, 3));
+    __pyx_v_gi = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_gi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_pi = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_pi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_output = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
+    __pyx_v_refined = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7));
+    __pyx_v_grids = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)PyTuple_GET_ITEM(__pyx_args, 8));
+  }
+  else {
+    if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iiiOiiOOO", __pyx_argnames, &__pyx_v_i_i, &__pyx_v_j_i, &__pyx_v_k_i, &__pyx_v_curpos, &__pyx_v_gi, &__pyx_v_pi, &__pyx_v_output, &__pyx_v_refined, &__pyx_v_grids))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.RecurseOctree");
+  return NULL;
+  __pyx_L4:;
+  __pyx_v_child_i = Py_None; Py_INCREF(Py_None);
+  __pyx_v_child_j = Py_None; Py_INCREF(Py_None);
+  __pyx_v_child_k = Py_None; Py_INCREF(Py_None);
+  __pyx_v_child_grid = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_child_indices.buf = NULL;
+  __pyx_bstruct_dimensions.buf = NULL;
+  __pyx_bstruct_field.buf = NULL;
+  __pyx_bstruct_leftedges.buf = NULL;
+  __pyx_bstruct_dx.buf = NULL;
+  __pyx_v_child_dx = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_child_dx.buf = NULL;
+  __pyx_v_child_leftedges = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
+  __pyx_bstruct_child_leftedges.buf = NULL;
+  __pyx_v_s = Py_None; Py_INCREF(Py_None);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_curpos), __pyx_ptype_2yt_5lagos_16DepthFirstOctree_position, 1, "curpos", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output), __pyx_ptype_5numpy_ndarray, 1, "output", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_refined), __pyx_ptype_5numpy_ndarray, 1, "refined", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grids), __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGridList, 1, "grids", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_output, &__pyx_bstruct_output, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_output = __pyx_bstruct_output.strides[0];
+  __pyx_bshape_0_output = __pyx_bstruct_output.shape[0];
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_v_refined, &__pyx_bstruct_refined, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_bstride_0_refined = __pyx_bstruct_refined.strides[0];
+  __pyx_bshape_0_refined = __pyx_bstruct_refined.shape[0];
+  __pyx_1 = (__pyx_v_gi - 1);
+  __pyx_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGrid))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_grid = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_2);
+  __pyx_2 = 0;
+  if (!(__Pyx_TypeTest(__pyx_v_grid->child_indices, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyArrayObject *)__pyx_v_grid->child_indices);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_t_1, &__pyx_bstruct_child_indices, PyBUF_FORMAT| PyBUF_STRIDES, 3) == -1)) {
+    __pyx_v_child_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_child_indices.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_child_indices = __pyx_bstruct_child_indices.strides[0]; __pyx_bstride_1_child_indices = __pyx_bstruct_child_indices.strides[1]; __pyx_bstride_2_child_indices = __pyx_bstruct_child_indices.strides[2];
+    __pyx_bshape_0_child_indices = __pyx_bstruct_child_indices.shape[0]; __pyx_bshape_1_child_indices = __pyx_bstruct_child_indices.shape[1]; __pyx_bshape_2_child_indices = __pyx_bstruct_child_indices.shape[2];
+  }
+  __pyx_t_1 = 0;
+  Py_INCREF(__pyx_v_grid->child_indices);
+  __pyx_v_child_indices = ((PyArrayObject *)__pyx_v_grid->child_indices);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->dimensions, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyArrayObject *)__pyx_v_grid->dimensions);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_int_t((PyObject*)__pyx_t_2, &__pyx_bstruct_dimensions, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+    __pyx_v_dimensions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_dimensions.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_dimensions = __pyx_bstruct_dimensions.strides[0];
+    __pyx_bshape_0_dimensions = __pyx_bstruct_dimensions.shape[0];
+  }
+  __pyx_t_2 = 0;
+  Py_INCREF(__pyx_v_grid->dimensions);
+  __pyx_v_dimensions = ((PyArrayObject *)__pyx_v_grid->dimensions);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->field, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = ((PyArrayObject *)__pyx_v_grid->field);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_3, &__pyx_bstruct_field, PyBUF_FORMAT| PyBUF_STRIDES, 3) == -1)) {
+    __pyx_v_field = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_field.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_field = __pyx_bstruct_field.strides[0]; __pyx_bstride_1_field = __pyx_bstruct_field.strides[1]; __pyx_bstride_2_field = __pyx_bstruct_field.strides[2];
+    __pyx_bshape_0_field = __pyx_bstruct_field.shape[0]; __pyx_bshape_1_field = __pyx_bstruct_field.shape[1]; __pyx_bshape_2_field = __pyx_bstruct_field.shape[2];
+  }
+  __pyx_t_3 = 0;
+  Py_INCREF(__pyx_v_grid->field);
+  __pyx_v_field = ((PyArrayObject *)__pyx_v_grid->field);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->left_edges, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = ((PyArrayObject *)__pyx_v_grid->left_edges);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_4, &__pyx_bstruct_leftedges, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+    __pyx_v_leftedges = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_leftedges.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_leftedges = __pyx_bstruct_leftedges.strides[0];
+    __pyx_bshape_0_leftedges = __pyx_bstruct_leftedges.shape[0];
+  }
+  __pyx_t_4 = 0;
+  Py_INCREF(__pyx_v_grid->left_edges);
+  __pyx_v_leftedges = ((PyArrayObject *)__pyx_v_grid->left_edges);
+  if (!(__Pyx_TypeTest(__pyx_v_grid->dx, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = ((PyArrayObject *)__pyx_v_grid->dx);
+  if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_5, &__pyx_bstruct_dx, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+    __pyx_v_dx = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_bstruct_dx.buf = NULL;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  } else {__pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
+    __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];
+  }
+  __pyx_t_5 = 0;
+  Py_INCREF(__pyx_v_grid->dx);
+  __pyx_v_dx = ((PyArrayObject *)__pyx_v_grid->dx);
+  for (__pyx_v_k_off = 0; __pyx_v_k_off < 2; __pyx_v_k_off+=1) {
+    __pyx_v_k = (__pyx_v_k_off + __pyx_v_k_i);
+    for (__pyx_v_j_off = 0; __pyx_v_j_off < 2; __pyx_v_j_off+=1) {
+      __pyx_v_j = (__pyx_v_j_off + __pyx_v_j_i);
+      for (__pyx_v_i_off = 0; __pyx_v_i_off < 2; __pyx_v_i_off+=1) {
+        __pyx_v_i = (__pyx_v_i_off + __pyx_v_i_i);
+        __pyx_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_3 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_4 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_5 = PyTuple_New(3); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
+        PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
+        PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
+        __pyx_2 = 0;
+        __pyx_3 = 0;
+        __pyx_4 = 0;
+        __pyx_2 = PyObject_GetItem(__pyx_v_grid->child_indices, ((PyObject *)__pyx_5)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
+        __pyx_6 = __pyx_PyInt_int(__pyx_2); if (unlikely((__pyx_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        Py_DECREF(__pyx_2); __pyx_2 = 0;
+        __pyx_v_ci = __pyx_6;
+        __pyx_7 = (__pyx_v_ci == -1);
+        if (__pyx_7) {
+          __pyx_3 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_4 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_5 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyTuple_New(3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
+          PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);
+          PyTuple_SET_ITEM(__pyx_2, 2, __pyx_5);
+          __pyx_3 = 0;
+          __pyx_4 = 0;
+          __pyx_5 = 0;
+          __pyx_3 = PyObject_GetItem(__pyx_v_grid->field, ((PyObject *)__pyx_2)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+          __pyx_8 = __pyx_PyFloat_AsDouble(__pyx_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_3); __pyx_3 = 0;
+          __pyx_t_6 = __pyx_v_curpos->output_pos;
+          if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_bshape_0_output;
+          *((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_output.buf, __pyx_t_6, __pyx_bstride_0_output)) = __pyx_8;
+          __pyx_t_7 = __pyx_v_curpos->refined_pos;
+          if (__pyx_t_7 < 0) __pyx_t_7 += __pyx_bshape_0_refined;
+          *((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_refined.buf, __pyx_t_7, __pyx_bstride_0_refined)) = 0;
+          __pyx_v_curpos->output_pos += 1;
+          __pyx_v_curpos->refined_pos += 1;
+          goto __pyx_L11;
+        }
+        /*else*/ {
+          __pyx_t_8 = __pyx_v_curpos->refined_pos;
+          if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_bshape_0_refined;
+          *((__pyx_t_5numpy_int_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_refined.buf, __pyx_t_8, __pyx_bstride_0_refined)) = 1;
+          __pyx_v_curpos->refined_pos += 1;
+          __pyx_1 = (__pyx_v_ci - 1);
+          __pyx_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_1, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGrid))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(((PyObject *)__pyx_v_child_grid));
+          __pyx_v_child_grid = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)__pyx_4);
+          __pyx_4 = 0;
+          if (!(__Pyx_TypeTest(__pyx_v_child_grid->dx, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = ((PyArrayObject *)__pyx_v_child_grid->dx);
+          __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx);
+          __pyx_t_10 = __Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_9, &__pyx_bstruct_child_dx, PyBUF_FORMAT| PyBUF_STRIDES, 1);
+          if (unlikely(__pyx_t_10 < 0)) 
+          {
+              PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
+              if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+                  Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
+                  __Pyx_RaiseBufferFallbackError();
+                } else {
+                  PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
+              }
+          }
+          __pyx_bstride_0_child_dx = __pyx_bstruct_child_dx.strides[0];
+          __pyx_bshape_0_child_dx = __pyx_bstruct_child_dx.shape[0];
+          if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = 0;
+          Py_INCREF(__pyx_v_child_grid->dx);
+          Py_DECREF(((PyObject *)__pyx_v_child_dx));
+          __pyx_v_child_dx = ((PyArrayObject *)__pyx_v_child_grid->dx);
+          if (!(__Pyx_TypeTest(__pyx_v_child_grid->left_edges, __pyx_ptype_5numpy_ndarray))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_14 = ((PyArrayObject *)__pyx_v_child_grid->left_edges);
+          __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges);
+          __pyx_t_10 = __Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_t_14, &__pyx_bstruct_child_leftedges, PyBUF_FORMAT| PyBUF_STRIDES, 1);
+          if (unlikely(__pyx_t_10 < 0)) 
+          {
+              PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
+              if (unlikely(__Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges, PyBUF_FORMAT| PyBUF_STRIDES, 1) == -1)) {
+                  Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
+                  __Pyx_RaiseBufferFallbackError();
+                } else {
+                  PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
+              }
+          }
+          __pyx_bstride_0_child_leftedges = __pyx_bstruct_child_leftedges.strides[0];
+          __pyx_bshape_0_child_leftedges = __pyx_bstruct_child_leftedges.shape[0];
+          if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_14 = 0;
+          Py_INCREF(__pyx_v_child_grid->left_edges);
+          Py_DECREF(((PyObject *)__pyx_v_child_leftedges));
+          __pyx_v_child_leftedges = ((PyArrayObject *)__pyx_v_child_grid->left_edges);
+          __pyx_t_15 = 0;
+          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_leftedges;
+          __pyx_8 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_leftedges.buf, __pyx_t_15, __pyx_bstride_0_leftedges)));
+          __pyx_5 = PyFloat_FromDouble(__pyx_8); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_3 = PyNumber_Multiply(__pyx_2, ((PyObject *)__pyx_v_dx)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_4 = PyNumber_Add(__pyx_5, __pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_5); __pyx_5 = 0;
+          Py_DECREF(__pyx_3); __pyx_3 = 0;
+          __pyx_t_16 = 0;
+          if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_0_child_leftedges;
+          __pyx_8 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_child_leftedges.buf, __pyx_t_16, __pyx_bstride_0_child_leftedges)));
+          __pyx_2 = PyFloat_FromDouble(__pyx_8); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_5 = PyNumber_Subtract(__pyx_4, __pyx_2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_3 = __Pyx_PyNumber_Divide(__pyx_5, ((PyObject *)__pyx_v_child_dx)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_5); __pyx_5 = 0;
+          Py_DECREF(__pyx_v_child_i);
+          __pyx_v_child_i = __pyx_3;
+          __pyx_3 = 0;
+          __pyx_t_17 = 1;
+          if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_bshape_0_leftedges;
+          __pyx_8 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_leftedges.buf, __pyx_t_17, __pyx_bstride_0_leftedges)));
+          __pyx_4 = PyFloat_FromDouble(__pyx_8); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_5 = PyNumber_Multiply(__pyx_2, ((PyObject *)__pyx_v_dx)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_3 = PyNumber_Add(__pyx_4, __pyx_5); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          Py_DECREF(__pyx_5); __pyx_5 = 0;
+          __pyx_t_18 = 1;
+          if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_bshape_0_child_leftedges;
+          __pyx_8 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_child_leftedges.buf, __pyx_t_18, __pyx_bstride_0_child_leftedges)));
+          __pyx_2 = PyFloat_FromDouble(__pyx_8); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_4 = PyNumber_Subtract(__pyx_3, __pyx_2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_3); __pyx_3 = 0;
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_5 = __Pyx_PyNumber_Divide(__pyx_4, ((PyObject *)__pyx_v_child_dx)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          Py_DECREF(__pyx_v_child_j);
+          __pyx_v_child_j = __pyx_5;
+          __pyx_5 = 0;
+          __pyx_t_19 = 2;
+          if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_0_leftedges;
+          __pyx_8 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_leftedges.buf, __pyx_t_19, __pyx_bstride_0_leftedges)));
+          __pyx_3 = PyFloat_FromDouble(__pyx_8); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_4 = PyNumber_Multiply(__pyx_2, ((PyObject *)__pyx_v_dx)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_5 = PyNumber_Add(__pyx_3, __pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_3); __pyx_3 = 0;
+          Py_DECREF(__pyx_4); __pyx_4 = 0;
+          __pyx_t_20 = 2;
+          if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_0_child_leftedges;
+          __pyx_8 = *((__pyx_t_5numpy_float64_t *)((__pyx_t_5numpy_float64_t *)__Pyx_BufPtrStrided1d(__pyx_bstruct_child_leftedges.buf, __pyx_t_20, __pyx_bstride_0_child_leftedges)));
+          __pyx_2 = PyFloat_FromDouble(__pyx_8); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_3 = PyNumber_Subtract(__pyx_5, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_5); __pyx_5 = 0;
+          Py_DECREF(__pyx_2); __pyx_2 = 0;
+          __pyx_4 = __Pyx_PyNumber_Divide(__pyx_3, ((PyObject *)__pyx_v_child_dx)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_3); __pyx_3 = 0;
+          Py_DECREF(__pyx_v_child_k);
+          __pyx_v_child_k = __pyx_4;
+          __pyx_4 = 0;
+          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_RecurseOctree); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_2 = PyInt_FromLong(__pyx_v_ci); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_3 = PyInt_FromLong(__pyx_v_gi); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_4 = PyTuple_New(9); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_INCREF(__pyx_v_child_i);
+          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_child_i);
+          Py_INCREF(__pyx_v_child_j);
+          PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_child_j);
+          Py_INCREF(__pyx_v_child_k);
+          PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_child_k);
+          Py_INCREF(((PyObject *)__pyx_v_curpos));
+          PyTuple_SET_ITEM(__pyx_4, 3, ((PyObject *)__pyx_v_curpos));
+          PyTuple_SET_ITEM(__pyx_4, 4, __pyx_2);
+          PyTuple_SET_ITEM(__pyx_4, 5, __pyx_3);
+          Py_INCREF(((PyObject *)__pyx_v_output));
+          PyTuple_SET_ITEM(__pyx_4, 6, ((PyObject *)__pyx_v_output));
+          Py_INCREF(((PyObject *)__pyx_v_refined));
+          PyTuple_SET_ITEM(__pyx_4, 7, ((PyObject *)__pyx_v_refined));
+          Py_INCREF(((PyObject *)__pyx_v_grids));
+          PyTuple_SET_ITEM(__pyx_4, 8, ((PyObject *)__pyx_v_grids));
+          __pyx_2 = 0;
+          __pyx_3 = 0;
+          __pyx_2 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          Py_DECREF(__pyx_5); __pyx_5 = 0;
+          Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
+          Py_DECREF(__pyx_v_s);
+          __pyx_v_s = __pyx_2;
+          __pyx_2 = 0;
+        }
+        __pyx_L11:;
+      }
+    }
+  }
+  Py_INCREF(__pyx_v_s);
+  __pyx_r = __pyx_v_s;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  Py_XDECREF(__pyx_5);
+  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
+    PyErr_Fetch(&__pyx_type, &__pyx_value, &__pyx_tb);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dx, &__pyx_bstruct_dx);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_leftedges, &__pyx_bstruct_leftedges);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_refined, &__pyx_bstruct_refined);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_field, &__pyx_bstruct_field);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dimensions, &__pyx_bstruct_dimensions);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_indices, &__pyx_bstruct_child_indices);
+    __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_output, &__pyx_bstruct_output);
+  PyErr_Restore(__pyx_type, __pyx_value, __pyx_tb);}
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree.RecurseOctree");
+  __pyx_r = NULL;
+  goto __pyx_L2;
+  __pyx_L0:;
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dx, &__pyx_bstruct_dx);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_leftedges, &__pyx_bstruct_leftedges);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_refined, &__pyx_bstruct_refined);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_dx, &__pyx_bstruct_child_dx);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_field, &__pyx_bstruct_field);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_leftedges, &__pyx_bstruct_child_leftedges);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_dimensions, &__pyx_bstruct_dimensions);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_child_indices, &__pyx_bstruct_child_indices);
+  __Pyx_SafeReleaseBuffer((PyObject*)__pyx_v_output, &__pyx_bstruct_output);
+  __pyx_L2:;
+  Py_DECREF(__pyx_v_child_i);
+  Py_DECREF(__pyx_v_child_j);
+  Py_DECREF(__pyx_v_child_k);
+  Py_DECREF(__pyx_v_child_grid);
+  Py_XDECREF(__pyx_v_grid);
+  Py_XDECREF(__pyx_v_child_indices);
+  Py_XDECREF(__pyx_v_dimensions);
+  Py_XDECREF(__pyx_v_field);
+  Py_XDECREF(__pyx_v_leftedges);
+  Py_XDECREF(__pyx_v_dx);
+  Py_DECREF(__pyx_v_child_dx);
+  Py_DECREF(__pyx_v_child_leftedges);
+  Py_DECREF(__pyx_v_s);
+  return __pyx_r;
+}
+
+static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
+static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
+  int __pyx_v_t;
+  char *__pyx_v_f;
+  int __pyx_r;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  __pyx_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
+  if (__pyx_1) {
+    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_INCREF(__pyx_kp_1);
+    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_1);
+    __pyx_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+  __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self));
+  __pyx_v_info->ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self));
+  __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self)));
+  __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self)));
+  __pyx_v_info->suboffsets = NULL;
+  __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self));
+  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self)));
+  __pyx_v_t = PyArray_TYPE(((PyArrayObject *)__pyx_v_self));
+  __pyx_v_f = NULL;
+  switch (__pyx_v_t) {
+    case NPY_BYTE:
+    __pyx_v_f = __pyx_k_2;
+    break;
+    case NPY_UBYTE:
+    __pyx_v_f = __pyx_k_3;
+    break;
+    case NPY_SHORT:
+    __pyx_v_f = __pyx_k_4;
+    break;
+    case NPY_USHORT:
+    __pyx_v_f = __pyx_k_5;
+    break;
+    case NPY_INT:
+    __pyx_v_f = __pyx_k_6;
+    break;
+    case NPY_UINT:
+    __pyx_v_f = __pyx_k_7;
+    break;
+    case NPY_LONG:
+    __pyx_v_f = __pyx_k_8;
+    break;
+    case NPY_ULONG:
+    __pyx_v_f = __pyx_k_9;
+    break;
+    case NPY_LONGLONG:
+    __pyx_v_f = __pyx_k_10;
+    break;
+    case NPY_ULONGLONG:
+    __pyx_v_f = __pyx_k_11;
+    break;
+    case NPY_FLOAT:
+    __pyx_v_f = __pyx_k_12;
+    break;
+    case NPY_DOUBLE:
+    __pyx_v_f = __pyx_k_13;
+    break;
+    case NPY_LONGDOUBLE:
+    __pyx_v_f = __pyx_k_14;
+    break;
+    case NPY_OBJECT:
+    __pyx_v_f = __pyx_k_15;
+    break;
+  }
+  __pyx_1 = (__pyx_v_f == NULL);
+  if (__pyx_1) {
+    __pyx_2 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_3 = PyNumber_Remainder(__pyx_kp_16, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
+    __pyx_3 = 0;
+    __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+  __pyx_v_info->format = __pyx_v_f;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  return __pyx_r;
+}
+
+static PyObject *__pyx_tp_new_2yt_5lagos_16DepthFirstOctree_position(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  return o;
+}
+
+static void __pyx_tp_dealloc_2yt_5lagos_16DepthFirstOctree_position(PyObject *o) {
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static struct PyMethodDef __pyx_methods_2yt_5lagos_16DepthFirstOctree_position[] = {
+  {0, 0, 0, 0}
+};
+
+static struct PyMemberDef __pyx_members_2yt_5lagos_16DepthFirstOctree_position[] = {
+  {"output_pos", T_INT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position, output_pos), 0, 0},
+  {"refined_pos", T_INT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position, refined_pos), 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_position = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  0, /*nb_long*/
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_position = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_position = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_position = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+  0, /*bf_getbuffer*/
+  #endif
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_2yt_5lagos_16DepthFirstOctree_position = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "yt.lagos.DepthFirstOctree.position", /*tp_name*/
+  sizeof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_position), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_2yt_5lagos_16DepthFirstOctree_position, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  0, /*tp_compare*/
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_position, /*tp_as_number*/
+  &__pyx_tp_as_sequence_position, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_position, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_position, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+  0, /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_2yt_5lagos_16DepthFirstOctree_position, /*tp_methods*/
+  __pyx_members_2yt_5lagos_16DepthFirstOctree_position, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_2yt_5lagos_16DepthFirstOctree_position, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+};
+
+static PyObject *__pyx_tp_new_2yt_5lagos_16DepthFirstOctree_OctreeGrid(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)o);
+  p->child_indices = Py_None; Py_INCREF(Py_None);
+  p->field = Py_None; Py_INCREF(Py_None);
+  p->left_edges = Py_None; Py_INCREF(Py_None);
+  p->dimensions = Py_None; Py_INCREF(Py_None);
+  p->dx = Py_None; Py_INCREF(Py_None);
+  if (__pyx_pf_2yt_5lagos_16DepthFirstOctree_10OctreeGrid___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_2yt_5lagos_16DepthFirstOctree_OctreeGrid(PyObject *o) {
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *p = (struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)o;
+  Py_XDECREF(p->child_indices);
+  Py_XDECREF(p->field);
+  Py_XDECREF(p->left_edges);
+  Py_XDECREF(p->dimensions);
+  Py_XDECREF(p->dx);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_2yt_5lagos_16DepthFirstOctree_OctreeGrid(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *p = (struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)o;
+  if (p->child_indices) {
+    e = (*v)(p->child_indices, a); if (e) return e;
+  }
+  if (p->field) {
+    e = (*v)(p->field, a); if (e) return e;
+  }
+  if (p->left_edges) {
+    e = (*v)(p->left_edges, a); if (e) return e;
+  }
+  if (p->dimensions) {
+    e = (*v)(p->dimensions, a); if (e) return e;
+  }
+  if (p->dx) {
+    e = (*v)(p->dx, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_2yt_5lagos_16DepthFirstOctree_OctreeGrid(PyObject *o) {
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *p = (struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid *)o;
+  PyObject* tmp;
+  tmp = ((PyObject*)p->child_indices);
+  p->child_indices = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->field);
+  p->field = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->left_edges);
+  p->left_edges = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->dimensions);
+  p->dimensions = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->dx);
+  p->dx = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static struct PyMethodDef __pyx_methods_2yt_5lagos_16DepthFirstOctree_OctreeGrid[] = {
+  {0, 0, 0, 0}
+};
+
+static struct PyMemberDef __pyx_members_2yt_5lagos_16DepthFirstOctree_OctreeGrid[] = {
+  {"child_indices", T_OBJECT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid, child_indices), 0, 0},
+  {"field", T_OBJECT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid, field), 0, 0},
+  {"left_edges", T_OBJECT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid, left_edges), 0, 0},
+  {"dimensions", T_OBJECT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid, dimensions), 0, 0},
+  {"dx", T_OBJECT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid, dx), 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_OctreeGrid = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  0, /*nb_long*/
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_OctreeGrid = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_OctreeGrid = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_OctreeGrid = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+  0, /*bf_getbuffer*/
+  #endif
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGrid = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "yt.lagos.DepthFirstOctree.OctreeGrid", /*tp_name*/
+  sizeof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGrid), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_2yt_5lagos_16DepthFirstOctree_OctreeGrid, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  0, /*tp_compare*/
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_OctreeGrid, /*tp_as_number*/
+  &__pyx_tp_as_sequence_OctreeGrid, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_OctreeGrid, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_OctreeGrid, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_2yt_5lagos_16DepthFirstOctree_OctreeGrid, /*tp_traverse*/
+  __pyx_tp_clear_2yt_5lagos_16DepthFirstOctree_OctreeGrid, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_2yt_5lagos_16DepthFirstOctree_OctreeGrid, /*tp_methods*/
+  __pyx_members_2yt_5lagos_16DepthFirstOctree_OctreeGrid, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_2yt_5lagos_16DepthFirstOctree_OctreeGrid, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+};
+
+static PyObject *__pyx_tp_new_2yt_5lagos_16DepthFirstOctree_OctreeGridList(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)o);
+  p->grids = Py_None; Py_INCREF(Py_None);
+  if (__pyx_pf_2yt_5lagos_16DepthFirstOctree_14OctreeGridList___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_2yt_5lagos_16DepthFirstOctree_OctreeGridList(PyObject *o) {
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *p = (struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)o;
+  Py_XDECREF(p->grids);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_2yt_5lagos_16DepthFirstOctree_OctreeGridList(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *p = (struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)o;
+  if (p->grids) {
+    e = (*v)(p->grids, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_2yt_5lagos_16DepthFirstOctree_OctreeGridList(PyObject *o) {
+  struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *p = (struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList *)o;
+  PyObject* tmp;
+  tmp = ((PyObject*)p->grids);
+  p->grids = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+static PyObject *__pyx_sq_item_2yt_5lagos_16DepthFirstOctree_OctreeGridList(PyObject *o, Py_ssize_t i) {
+  PyObject *r;
+  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+  Py_DECREF(x);
+  return r;
+}
+
+static struct PyMethodDef __pyx_methods_2yt_5lagos_16DepthFirstOctree_OctreeGridList[] = {
+  {"__getitem__", (PyCFunction)__pyx_pf_2yt_5lagos_16DepthFirstOctree_14OctreeGridList___getitem__, METH_O|METH_COEXIST, 0},
+  {0, 0, 0, 0}
+};
+
+static struct PyMemberDef __pyx_members_2yt_5lagos_16DepthFirstOctree_OctreeGridList[] = {
+  {"grids", T_OBJECT, offsetof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList, grids), 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_OctreeGridList = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  0, /*nb_long*/
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_OctreeGridList = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  __pyx_sq_item_2yt_5lagos_16DepthFirstOctree_OctreeGridList, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_OctreeGridList = {
+  0, /*mp_length*/
+  __pyx_pf_2yt_5lagos_16DepthFirstOctree_14OctreeGridList___getitem__, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_OctreeGridList = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+  0, /*bf_getbuffer*/
+  #endif
+  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGridList = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "yt.lagos.DepthFirstOctree.OctreeGridList", /*tp_name*/
+  sizeof(struct __pyx_obj_2yt_5lagos_16DepthFirstOctree_OctreeGridList), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_2yt_5lagos_16DepthFirstOctree_OctreeGridList, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  0, /*tp_compare*/
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_OctreeGridList, /*tp_as_number*/
+  &__pyx_tp_as_sequence_OctreeGridList, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_OctreeGridList, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_OctreeGridList, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_2yt_5lagos_16DepthFirstOctree_OctreeGridList, /*tp_traverse*/
+  __pyx_tp_clear_2yt_5lagos_16DepthFirstOctree_OctreeGridList, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_2yt_5lagos_16DepthFirstOctree_OctreeGridList, /*tp_methods*/
+  __pyx_members_2yt_5lagos_16DepthFirstOctree_OctreeGridList, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_2yt_5lagos_16DepthFirstOctree_OctreeGridList, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+};
+
+static struct PyMethodDef __pyx_methods[] = {
+  {"WalkRootgrid", (PyCFunction)__pyx_pf_2yt_5lagos_16DepthFirstOctree_WalkRootgrid, METH_VARARGS|METH_KEYWORDS, __pyx_doc_2yt_5lagos_16DepthFirstOctree_WalkRootgrid},
+  {"RecurseOctree", (PyCFunction)__pyx_pf_2yt_5lagos_16DepthFirstOctree_RecurseOctree, METH_VARARGS|METH_KEYWORDS, 0},
+  {0, 0, 0, 0}
+};
+
+static void __pyx_init_filenames(void); /*proto*/
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+    PyModuleDef_HEAD_INIT,
+    "DepthFirstOctree",
+    __pyx_mdoc, /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_kp___cinit__, __pyx_k___cinit__, sizeof(__pyx_k___cinit__), 0, 1, 1},
+  {&__pyx_kp___getitem__, __pyx_k___getitem__, sizeof(__pyx_k___getitem__), 0, 1, 1},
+  {&__pyx_kp_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 1, 1, 1},
+  {&__pyx_kp_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 1, 1},
+  {&__pyx_kp_RecurseOctree, __pyx_k_RecurseOctree, sizeof(__pyx_k_RecurseOctree), 0, 1, 1},
+  {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 0, 1, 1},
+  {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1},
+  {&__pyx_kp_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 1, 1, 1},
+  {&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 0},
+  {&__pyx_kp_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 0},
+  {0, 0, 0, 0, 0, 0}
+};
+static int __Pyx_InitCachedBuiltins(void) {
+  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC initDepthFirstOctree(void); /*proto*/
+PyMODINIT_FUNC initDepthFirstOctree(void)
+#else
+PyMODINIT_FUNC PyInit_DepthFirstOctree(void); /*proto*/
+PyMODINIT_FUNC PyInit_DepthFirstOctree(void)
+#endif
+{
+  PyObject *__pyx_1 = 0;
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Libary function declarations ---*/
+  __pyx_init_filenames();
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4("DepthFirstOctree", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  #if PY_MAJOR_VERSION < 3
+  Py_INCREF(__pyx_m);
+  #endif
+  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME);
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_skip_dispatch = 0;
+  /*--- Global init code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  if (PyType_Ready(&__pyx_type_2yt_5lagos_16DepthFirstOctree_position) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttrString(__pyx_m, "position", (PyObject *)&__pyx_type_2yt_5lagos_16DepthFirstOctree_position) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_2yt_5lagos_16DepthFirstOctree_position = &__pyx_type_2yt_5lagos_16DepthFirstOctree_position;
+  if (PyType_Ready(&__pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGrid) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttrString(__pyx_m, "OctreeGrid", (PyObject *)&__pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGrid) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGrid = &__pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGrid;
+  if (PyType_Ready(&__pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGridList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttrString(__pyx_m, "OctreeGridList", (PyObject *)&__pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGridList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_2yt_5lagos_16DepthFirstOctree_OctreeGridList = &__pyx_type_2yt_5lagos_16DepthFirstOctree_OctreeGridList;
+  /*--- Type import code ---*/
+  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+  __pyx_1 = __Pyx_Import(__pyx_kp_numpy, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_kp_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+  __pyx_L1_error:;
+  Py_XDECREF(__pyx_1);
+  __Pyx_AddTraceback("yt.lagos.DepthFirstOctree");
+  #if PY_MAJOR_VERSION >= 3
+  return NULL;
+  #endif
+}
+
+static const char *__pyx_filenames[] = {
+  "DepthFirstOctree.pyx",
+  "numpy.pxd",
+};
+
+/* Runtime support code */
+
+static void __pyx_init_filenames(void) {
+  __pyx_f = __pyx_filenames;
+}
+
+static INLINE void __Pyx_SafeReleaseBuffer(PyObject* obj, Py_buffer* info) {
+  if (info->buf == NULL) return;
+  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
+  __Pyx_ReleaseBuffer(obj, info);
+}
+
+static INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
+  buf->buf = NULL;
+  buf->strides = __Pyx_zeros;
+  buf->shape = __Pyx_zeros;
+  buf->suboffsets = __Pyx_minusones;
+}
+
+static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts) {
+  while (1) {
+    switch (*ts) {
+      case 10:
+      case 13:
+      case ' ':
+        ++ts;
+      default:
+        return ts;
+    }
+  }
+}
+
+static INLINE const char* __Pyx_BufferTypestringCheckEndian(const char* ts) {
+  int num = 1;
+  int little_endian = ((char*)&num)[0];
+  int ok = 1;
+  switch (*ts) {
+    case '@':
+    case '=':
+      ++ts; break;
+    case '<':
+      if (little_endian) ++ts;
+      else ok = 0;
+      break;
+    case '>':
+    case '!':
+      if (!little_endian) ++ts;
+      else ok = 0;
+      break;
+  }
+  if (!ok) {
+    PyErr_Format(PyExc_ValueError, "Buffer has wrong endianness (rejecting on '%s')", ts);
+    return NULL;
+  }
+  return ts;
+}
+
+static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim) {
+  PyErr_Format(PyExc_ValueError,
+               "Buffer has wrong number of dimensions (expected %d, got %d)",
+               expected_ndim, buffer->ndim);
+}
+
+
+static const char* __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_int_t(const char* ts) {
+  int ok;
+  if (*ts == '1') ++ts;
+  switch (*ts) {
+    case 'b': ok = (sizeof(__pyx_t_5numpy_int_t) == sizeof(char) && (__pyx_t_5numpy_int_t)-1 < 0); break;
+    case 'h': ok = (sizeof(__pyx_t_5numpy_int_t) == sizeof(short) && (__pyx_t_5numpy_int_t)-1 < 0); break;
+    case 'i': ok = (sizeof(__pyx_t_5numpy_int_t) == sizeof(int) && (__pyx_t_5numpy_int_t)-1 < 0); break;
+    case 'l': ok = (sizeof(__pyx_t_5numpy_int_t) == sizeof(long) && (__pyx_t_5numpy_int_t)-1 < 0); break;
+    case 'q': ok = (sizeof(__pyx_t_5numpy_int_t) == sizeof(long long) && (__pyx_t_5numpy_int_t)-1 < 0); break;  default: ok = 0;
+  }
+  if (!ok) {
+      PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (rejecting on '%s')", ts);
+      return NULL;
+  } else return ts + 1;
+  
+}
+
+static int __Pyx_GetBuffer_nn___pyx_t_5numpy_int_t(PyObject* obj, Py_buffer* buf, int flags, int nd) {
+  const char* ts;
+  if (obj == Py_None) {
+    __Pyx_ZeroBuffer(buf);
+    return 0;
+  }
+  buf->buf = NULL;
+  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
+  if (buf->ndim != nd) {
+    __Pyx_BufferNdimError(buf, nd);
+    goto fail;
+  }
+  ts = buf->format;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  ts = __Pyx_BufferTypestringCheckEndian(ts);
+  if (!ts) goto fail;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  ts = __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_int_t(ts);
+  if (!ts) goto fail;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  if (*ts != 0) {
+    PyErr_Format(PyExc_ValueError,
+      "Expected non-struct buffer data type (expected end, got '%s')", ts);
+    goto fail;
+  }
+  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
+  return 0;
+fail:;
+  __Pyx_ZeroBuffer(buf);
+  return -1;
+}
+static const char* __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_float64_t(const char* ts) {
+  int ok;
+  if (*ts == '1') ++ts;
+  switch (*ts) {
+    case 'f': ok = (sizeof(__pyx_t_5numpy_float64_t) == sizeof(float) && (__pyx_t_5numpy_float64_t)-1 < 0); break;
+    case 'd': ok = (sizeof(__pyx_t_5numpy_float64_t) == sizeof(double) && (__pyx_t_5numpy_float64_t)-1 < 0); break;
+    case 'g': ok = (sizeof(__pyx_t_5numpy_float64_t) == sizeof(long double) && (__pyx_t_5numpy_float64_t)-1 < 0); break;  default: ok = 0;
+  }
+  if (!ok) {
+      PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (rejecting on '%s')", ts);
+      return NULL;
+  } else return ts + 1;
+  
+}
+
+static int __Pyx_GetBuffer_nn___pyx_t_5numpy_float64_t(PyObject* obj, Py_buffer* buf, int flags, int nd) {
+  const char* ts;
+  if (obj == Py_None) {
+    __Pyx_ZeroBuffer(buf);
+    return 0;
+  }
+  buf->buf = NULL;
+  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
+  if (buf->ndim != nd) {
+    __Pyx_BufferNdimError(buf, nd);
+    goto fail;
+  }
+  ts = buf->format;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  ts = __Pyx_BufferTypestringCheckEndian(ts);
+  if (!ts) goto fail;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  ts = __Pyx_BufferTypestringCheck_item_nn___pyx_t_5numpy_float64_t(ts);
+  if (!ts) goto fail;
+  ts = __Pyx_ConsumeWhitespace(ts);
+  if (*ts != 0) {
+    PyErr_Format(PyExc_ValueError,
+      "Expected non-struct buffer data type (expected end, got '%s')", ts);
+    goto fail;
+  }
+  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
+  return 0;
+fail:;
+  __Pyx_ZeroBuffer(buf);
+  return -1;
+}
+static void __Pyx_RaiseBufferFallbackError(void) {
+  PyErr_Format(PyExc_ValueError,
+     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
+}
+
+
+static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name, int exact) {
+    if (!type) {
+        PyErr_Format(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (none_allowed && obj == Py_None) return 1;
+    else if (exact) {
+        if (Py_TYPE(obj) == type) return 1;
+    }
+    else {
+        if (PyObject_TypeCheck(obj, type)) return 1;
+    }
+    PyErr_Format(PyExc_TypeError,
+        "Argument '%s' has incorrect type (expected %s, got %s)",
+        name, type->tp_name, Py_TYPE(obj)->tp_name);
+    return 0;
+}
+
+static INLINE void __Pyx_RaiseArgtupleTooLong(
+    Py_ssize_t num_expected,
+    Py_ssize_t num_found)
+{
+    const char* error_message =
+    #if PY_VERSION_HEX < 0x02050000
+        "function takes at most %d positional arguments (%d given)";
+    #else
+        "function takes at most %zd positional arguments (%zd given)";
+    #endif
+    PyErr_Format(PyExc_TypeError, error_message, num_expected, num_found);
+}
+
+#if (PY_MAJOR_VERSION < 3) && !(Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_NEWBUFFER)
+static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
+  if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pf_5numpy_7ndarray___getbuffer__(obj, view, flags);
+  else {
+  PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
+  return -1;
+    }
+}
+
+static void __Pyx_ReleaseBuffer(PyObject *obj, Py_buffer *view) {
+
+}
+
+#endif
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
+    PyObject *__import__ = 0;
+    PyObject *empty_list = 0;
+    PyObject *module = 0;
+    PyObject *global_dict = 0;
+    PyObject *empty_dict = 0;
+    PyObject *list;
+    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
+    if (!__import__)
+        goto bad;
+    if (from_list)
+        list = from_list;
+    else {
+        empty_list = PyList_New(0);
+        if (!empty_list)
+            goto bad;
+        list = empty_list;
+    }
+    global_dict = PyModule_GetDict(__pyx_m);
+    if (!global_dict)
+        goto bad;
+    empty_dict = PyDict_New();
+    if (!empty_dict)
+        goto bad;
+    module = PyObject_CallFunction(__import__, "OOOO",
+        name, global_dict, empty_dict, list);
+bad:
+    Py_XDECREF(empty_list);
+    Py_XDECREF(__import__);
+    Py_XDECREF(empty_dict);
+    return module;
+}
+
+
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
+    if (!type) {
+        PyErr_Format(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (obj == Py_None || PyObject_TypeCheck(obj, type))
+        return 1;
+    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
+        Py_TYPE(obj)->tp_name, type->tp_name);
+    return 0;
+}
+
+#if PY_MAJOR_VERSION < 3
+static PyObject *__Pyx_GetStdout(void) {
+    PyObject *f = PySys_GetObject("stdout");
+    if (!f) {
+        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
+    }
+    return f;
+}
+
+static int __Pyx_Print(PyObject *arg_tuple, int newline) {
+    PyObject *f;
+    PyObject* v;
+    int i;
+    
+    if (!(f = __Pyx_GetStdout()))
+        return -1;
+    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
+        if (PyFile_SoftSpace(f, 1)) {
+            if (PyFile_WriteString(" ", f) < 0)
+                return -1;
+        }
+        v = PyTuple_GET_ITEM(arg_tuple, i);
+        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
+            return -1;
+        if (PyString_Check(v)) {
+            char *s = PyString_AsString(v);
+            Py_ssize_t len = PyString_Size(v);
+            if (len > 0 &&
+                isspace(Py_CHARMASK(s[len-1])) &&
+                s[len-1] != ' ')
+                    PyFile_SoftSpace(f, 0);
+        }
+    }
+    if (newline) {
+        if (PyFile_WriteString("\n", f) < 0)
+            return -1;
+        PyFile_SoftSpace(f, 0);
+    }
+    return 0;
+}
+
+#else /* Python 3 has a print function */
+static int __Pyx_Print(PyObject *arg_tuple, int newline) {
+    PyObject* kwargs = 0;
+    PyObject* result = 0;
+    PyObject* end_string;
+    if (!__pyx_print) {
+        __pyx_print = PyObject_GetAttrString(__pyx_b, "print");
+        if (!__pyx_print)
+            return -1;
+    }
+    if (!newline) {
+        if (!__pyx_print_kwargs) {
+            __pyx_print_kwargs = PyDict_New();
+            if (!__pyx_print_kwargs)
+                return -1;
+            end_string = PyUnicode_FromStringAndSize(" ", 1);
+            if (!end_string)
+                return -1;
+            if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
+                Py_DECREF(end_string);
+                return -1;
+            }
+            Py_DECREF(end_string);
+        }
+        kwargs = __pyx_print_kwargs;
+    }
+    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
+    if (!result)
+        return -1;
+    Py_DECREF(result);
+    return 0;
+}
+#endif
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
+    PyObject *result;
+    result = PyObject_GetAttr(dict, name);
+    if (!result)
+        PyErr_SetObject(PyExc_NameError, name);
+    return result;
+}
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    Py_XINCREF(type);
+    Py_XINCREF(value);
+    Py_XINCREF(tb);
+    /* First, check the traceback argument, replacing None with NULL. */
+    if (tb == Py_None) {
+        Py_DECREF(tb);
+        tb = 0;
+    }
+    else if (tb != NULL && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto raise_error;
+    }
+    /* Next, replace a missing value with None */
+    if (value == NULL) {
+        value = Py_None;
+        Py_INCREF(value);
+    }
+    #if PY_VERSION_HEX < 0x02050000
+    if (!PyClass_Check(type))
+    #else
+    if (!PyType_Check(type))
+    #endif
+    {
+        /* Raising an instance.  The value should be a dummy. */
+        if (value != Py_None) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        /* Normalize to raise <class>, <instance> */
+        Py_DECREF(value);
+        value = type;
+        #if PY_VERSION_HEX < 0x02050000
+            if (PyInstance_Check(type)) {
+                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
+                Py_INCREF(type);
+            }
+            else {
+                type = 0;
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception must be an old-style class or instance");
+                goto raise_error;
+            }
+        #else
+            type = (PyObject*) Py_TYPE(type);
+            Py_INCREF(type);
+            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception class must be a subclass of BaseException");
+                goto raise_error;
+            }
+        #endif
+    }
+    PyErr_Restore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name,
+    long size)
+{
+    PyObject *py_module = 0;
+    PyObject *result = 0;
+    PyObject *py_name = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(module_name);
+    #else
+    py_name = PyUnicode_FromString(module_name);
+    #endif
+    if (!py_name)
+        goto bad;
+
+    py_module = __Pyx_ImportModule(module_name);
+    if (!py_module)
+        goto bad;
+    result = PyObject_GetAttrString(py_module, class_name);
+    if (!result)
+        goto bad;
+    if (!PyType_Check(result)) {
+        PyErr_Format(PyExc_TypeError, 
+            "%s.%s is not a type object",
+            module_name, class_name);
+        goto bad;
+    }
+    if (((PyTypeObject *)result)->tp_basicsize != size) {
+        PyErr_Format(PyExc_ValueError, 
+            "%s.%s does not appear to be the correct type object",
+            module_name, class_name);
+        goto bad;
+    }
+    return (PyTypeObject *)result;
+bad:
+    Py_XDECREF(py_name);
+    Py_XDECREF(result);
+    return 0;
+}
+#endif
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(char *name) {
+    PyObject *py_name = 0;
+    PyObject *py_module = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(name);
+    #else
+    py_name = PyUnicode_FromString(name);
+    #endif
+    if (!py_name)
+        goto bad;
+    py_module = PyImport_Import(py_name);
+    Py_DECREF(py_name);
+    return py_module;
+bad:
+    Py_XDECREF(py_name);
+    return 0;
+}
+#endif
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(const char *funcname) {
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    PyObject *py_globals = 0;
+    PyObject *empty_string = 0;
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(__pyx_filename);
+    #else
+    py_srcfile = PyUnicode_FromString(__pyx_filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (__pyx_clineno) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_globals = PyModule_GetDict(__pyx_m);
+    if (!py_globals) goto bad;
+    #if PY_MAJOR_VERSION < 3
+    empty_string = PyString_FromStringAndSize("", 0);
+    #else
+    empty_string = PyBytes_FromStringAndSize("", 0);
+    #endif
+    if (!empty_string) goto bad;
+    py_code = PyCode_New(
+        0,            /*int argcount,*/
+        #if PY_MAJOR_VERSION >= 3
+        0,            /*int kwonlyargcount,*/
+        #endif
+        0,            /*int nlocals,*/
+        0,            /*int stacksize,*/
+        0,            /*int flags,*/
+        empty_string, /*PyObject *code,*/
+        __pyx_empty_tuple,  /*PyObject *consts,*/
+        __pyx_empty_tuple,  /*PyObject *names,*/
+        __pyx_empty_tuple,  /*PyObject *varnames,*/
+        __pyx_empty_tuple,  /*PyObject *freevars,*/
+        __pyx_empty_tuple,  /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        __pyx_lineno,   /*int firstlineno,*/
+        empty_string  /*PyObject *lnotab*/
+    );
+    if (!py_code) goto bad;
+    py_frame = PyFrame_New(
+        PyThreadState_Get(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        py_globals,          /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = __pyx_lineno;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    Py_XDECREF(empty_string);
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode && (!t->is_identifier)) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else  /* Python 3+ has unicode identifiers */
+        if (t->is_identifier || (t->is_unicode && t->intern)) {
+            *t->p = PyUnicode_InternFromString(t->s);
+        } else if (t->is_unicode) {
+            *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+/* Type Conversion Functions */
+
+static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject* x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+
+static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   if (x == Py_True) return 1;
+   else if (x == Py_False) return 0;
+   else return PyObject_IsTrue(x);
+}
+
+static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
+    if (PyInt_CheckExact(x)) {
+        return PyInt_AS_LONG(x);
+    }
+    else if (PyLong_CheckExact(x)) {
+        return PyLong_AsLongLong(x);
+    }
+    else {
+        PY_LONG_LONG val;
+        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
+        val = __pyx_PyInt_AsLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
+    if (PyInt_CheckExact(x)) {
+        long val = PyInt_AS_LONG(x);
+        if (unlikely(val < 0)) {
+            PyErr_SetString(PyExc_TypeError, "Negative assignment to unsigned type.");
+            return (unsigned PY_LONG_LONG)-1;
+        }
+        return val;
+    }
+    else if (PyLong_CheckExact(x)) {
+        return PyLong_AsUnsignedLongLong(x);
+    }
+    else {
+        PY_LONG_LONG val;
+        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
+        val = __pyx_PyInt_AsUnsignedLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+
+static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x) {
+    if (sizeof(unsigned char) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        unsigned char val = (unsigned char)long_val;
+        if (unlikely((val != long_val)  || (long_val < 0))) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned char");
+            return (unsigned char)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x) {
+    if (sizeof(unsigned short) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        unsigned short val = (unsigned short)long_val;
+        if (unlikely((val != long_val)  || (long_val < 0))) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned short");
+            return (unsigned short)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE char __pyx_PyInt_char(PyObject* x) {
+    if (sizeof(char) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        char val = (char)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to char");
+            return (char)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE short __pyx_PyInt_short(PyObject* x) {
+    if (sizeof(short) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        short val = (short)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to short");
+            return (short)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE int __pyx_PyInt_int(PyObject* x) {
+    if (sizeof(int) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        int val = (int)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to int");
+            return (int)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE long __pyx_PyInt_long(PyObject* x) {
+    if (sizeof(long) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        long val = (long)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long");
+            return (long)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed char __pyx_PyInt_signed_char(PyObject* x) {
+    if (sizeof(signed char) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed char val = (signed char)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed char");
+            return (signed char)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed short __pyx_PyInt_signed_short(PyObject* x) {
+    if (sizeof(signed short) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed short val = (signed short)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed short");
+            return (signed short)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed int __pyx_PyInt_signed_int(PyObject* x) {
+    if (sizeof(signed int) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed int val = (signed int)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed int");
+            return (signed int)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE signed long __pyx_PyInt_signed_long(PyObject* x) {
+    if (sizeof(signed long) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        signed long val = (signed long)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed long");
+            return (signed long)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+
+static INLINE long double __pyx_PyInt_long_double(PyObject* x) {
+    if (sizeof(long double) < sizeof(long)) {
+        long long_val = __pyx_PyInt_AsLong(x);
+        long double val = (long double)long_val;
+        if (unlikely((val != long_val) )) {
+            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long double");
+            return (long double)-1;
+        }
+        return val;
+    }
+    else {
+        return __pyx_PyInt_AsLong(x);
+    }
+}
+

Added: trunk/yt/lagos/DepthFirstOctree.pyx
==============================================================================
--- (empty file)
+++ trunk/yt/lagos/DepthFirstOctree.pyx	Mon Sep 22 01:46:01 2008
@@ -0,0 +1,138 @@
+"""
+This is a recursive function to return a depth-first octree
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: KIPAC/SLAC/Stanford
+Homepage: http://yt.enzotools.org/
+License:
+  Copyright (C) 2008 Matthew Turk.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import numpy as np
+cimport numpy as np
+cimport cython
+
+cdef class position:
+    cdef public int output_pos, refined_pos
+
+cdef class OctreeGrid:
+    cdef public object child_indices, field, left_edges, dimensions, dx
+    def __cinit__(self,
+                  np.ndarray[np.int_t, ndim=3] child_indices,
+                  np.ndarray[np.float64_t, ndim=3] field,
+                  np.ndarray[np.float64_t, ndim=1] left_edges,
+                  np.ndarray[np.int_t, ndim=1] dimensions,
+                  np.ndarray[np.float64_t, ndim=1] dx):
+        self.child_indices = child_indices
+        self.field = field
+        self.left_edges = left_edges
+        self.dimensions = dimensions
+        self.dx = dx
+
+cdef class OctreeGridList:
+    cdef public object grids
+    def __cinit__(self, grids):
+        self.grids = grids
+
+    def __getitem__(self, int item):
+        return self.grids[item]
+
+ at cython.boundscheck(False)
+def WalkRootgrid(np.ndarray[np.float64_t, ndim=1] output,
+                 np.ndarray[np.int_t, ndim=1] refined,
+                 OctreeGridList grids, int pi, int s = 0, int r = 0):
+    """
+    This function only gets called on a 'root grid' -- a base grid
+    of the simulation we are converting.  It will call a recursive walker.
+    """
+    cdef int i, j, k, gi
+    cdef int child_i, child_j, child_k
+    cdef OctreeGrid child_grid
+    cdef OctreeGrid grid = grids[pi-1]
+    cdef np.ndarray[np.int_t, ndim=3] child_indices = grid.child_indices
+    cdef np.ndarray[np.int_t, ndim=1] dimensions = grid.dimensions
+    cdef np.ndarray[np.float64_t, ndim=3] field = grid.field
+    cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
+    cdef np.ndarray[np.float64_t, ndim=1] dx = grid.dx
+    cdef np.ndarray[np.float64_t, ndim=1] child_dx
+    cdef np.ndarray[np.float64_t, ndim=1] child_leftedges
+    cdef position curpos
+    curpos.output_pos = s
+    curpos.refined_pos = r
+    for k in range(dimensions[2]):
+        print k
+        for j in range(dimensions[1]):
+            for i in range(dimensions[0]):
+                gi = child_indices[i,j,k]
+                if gi == -1:
+                    output[curpos.output_pos] = field[i,j,k]
+                    refined[curpos.refined_pos] = 0
+                    curpos.output_pos += 1
+                    curpos.refined_pos += 1
+                else:
+                    refined[curpos.refined_pos] = 1
+                    curpos.refined_pos += 1
+                    child_grid = grids[gi-1]
+                    child_dx = child_grid.dx
+                    child_leftedges = child_grid.left_edges
+                    child_i = ((leftedges[0] + i * dx) - child_leftedges[0])/child_dx
+                    child_j = ((leftedges[1] + j * dx) - child_leftedges[1])/child_dx
+                    child_k = ((leftedges[2] + k * dx) - child_leftedges[2])/child_dx
+                    RecurseOctree(child_i, child_j, child_k, curpos, gi, pi, output, refined, grids)
+
+ at cython.boundscheck(False)
+def RecurseOctree(int i_i, int j_i, int k_i,
+                  position curpos, int gi, int pi,
+                  np.ndarray[np.float64_t, ndim=1] output,
+                  np.ndarray[np.int_t, ndim=1] refined,
+                  OctreeGridList grids):
+    cdef int i, i_off, j, j_off, k, k_off, ci
+    cdef child_i, child_j, child_k
+    cdef OctreeGrid child_grid
+    cdef OctreeGrid grid = grids[gi-1]
+    cdef np.ndarray[np.int_t, ndim=3] child_indices = grid.child_indices
+    cdef np.ndarray[np.int_t, ndim=1] dimensions = grid.dimensions
+    cdef np.ndarray[np.float64_t, ndim=3] field = grid.field
+    cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
+    cdef np.ndarray[np.float64_t, ndim=1] dx = grid.dx
+    cdef np.ndarray[np.float64_t, ndim=1] child_dx
+    cdef np.ndarray[np.float64_t, ndim=1] child_leftedges
+    # Not sure how to get around this
+    for k_off in range(2):
+        k = k_off + k_i
+        for j_off in range(2):
+            j = j_off + j_i
+            for i_off in range(2):
+                i = i_off + i_i
+                ci = grid.child_indices[i,j,k]
+                if ci == -1:
+                    output[curpos.output_pos] = grid.field[i,j,k]
+                    refined[curpos.refined_pos] = 0
+                    curpos.output_pos += 1
+                    curpos.refined_pos += 1
+                else:
+                    refined[curpos.refined_pos] = 1
+                    curpos.refined_pos += 1
+                    child_grid = grids[ci-1]
+                    child_dx = child_grid.dx
+                    child_leftedges = child_grid.left_edges
+                    child_i = ((leftedges[0] + i * dx) - child_leftedges[0])/child_dx
+                    child_j = ((leftedges[1] + j * dx) - child_leftedges[1])/child_dx
+                    child_k = ((leftedges[2] + k * dx) - child_leftedges[2])/child_dx
+                    s = RecurseOctree(child_i, child_j, child_k, curpos, ci, gi, output, refined, grids)
+    return s

Modified: trunk/yt/lagos/HierarchyType.py
==============================================================================
--- trunk/yt/lagos/HierarchyType.py	(original)
+++ trunk/yt/lagos/HierarchyType.py	Mon Sep 22 01:46:01 2008
@@ -752,6 +752,31 @@
         f.close()
         mylog.info("Wrote %s particles to %s", tot, filename)
 
+    def _generate_flat_octree(self, field):
+        """
+        Generates two arrays, one of the actual values in a depth-first flat
+        octree array, and the other of the values describing the refinement.
+        This allows for export to a code that understands this.  *field* is the
+        field used in the data array.
+        """
+        import DepthFirstOctree as dfo
+        o_length = r_length = 0
+        grids = []
+        for g in self.grids:
+            grids.append(dfo.OctreeGrid(
+                            g.child_index_mask,
+                            g[field].astype("float64"),
+                            g.LeftEdge.astype('float64'),
+                            g.ActiveDimensions.astype('int'),
+                            na.ones(1,dtype='float64') * g.dx))
+            o_length += g.child_mask.ravel().sum()
+            r_length += g.ActiveDimensions.prod()
+        output = na.zeros(o_length, dtype='float64')
+        refined = na.zeros(r_length, dtype='int')
+        ogl = dfo.OctreeGridList(grids)
+        dfo.WalkRootgrid(output, refined, ogl, 1, 0)
+        return output, refined
+
     @time_execution
     def export_boxes_pv(self, filename):
         """

Modified: trunk/yt/lagos/setup.py
==============================================================================
--- trunk/yt/lagos/setup.py	(original)
+++ trunk/yt/lagos/setup.py	Mon Sep 22 01:46:01 2008
@@ -21,6 +21,7 @@
     config.add_extension("PointCombine", "yt/lagos/PointCombine.c", libraries=["m"])
     #config.add_extension("RTIntegrator", "yt/lagos/RTIntegrator.c")
     config.add_extension("Interpolators", "yt/lagos/Interpolators.c")
+    #config.add_extension("DepthFirstOctree", "yt/lagos/DepthFirstOctree.c")
     config.add_subpackage("hop")
     H5dir = check_for_hdf5()
     if H5dir is not None:



More information about the yt-svn mailing list