1 /* Generated by Cython 0.29.25 */
2 
3 #ifndef PY_SSIZE_T_CLEAN
4 #define PY_SSIZE_T_CLEAN
5 #endif /* PY_SSIZE_T_CLEAN */
6 #include "Python.h"
7 #ifndef Py_PYTHON_H
8     #error Python headers needed to compile C extensions, please install development version of Python.
9 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10     #error Cython requires Python 2.6+ or Python 3.3+.
11 #else
12 #define CYTHON_ABI "0_29_25"
13 #define CYTHON_HEX_VERSION 0x001D19F0
14 #define CYTHON_FUTURE_DIVISION 0
15 #include <stddef.h>
16 #ifndef offsetof
17   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18 #endif
19 #if !defined(WIN32) && !defined(MS_WINDOWS)
20   #ifndef __stdcall
21     #define __stdcall
22   #endif
23   #ifndef __cdecl
24     #define __cdecl
25   #endif
26   #ifndef __fastcall
27     #define __fastcall
28   #endif
29 #endif
30 #ifndef DL_IMPORT
31   #define DL_IMPORT(t) t
32 #endif
33 #ifndef DL_EXPORT
34   #define DL_EXPORT(t) t
35 #endif
36 #define __PYX_COMMA ,
37 #ifndef HAVE_LONG_LONG
38   #if PY_VERSION_HEX >= 0x02070000
39     #define HAVE_LONG_LONG
40   #endif
41 #endif
42 #ifndef PY_LONG_LONG
43   #define PY_LONG_LONG LONG_LONG
44 #endif
45 #ifndef Py_HUGE_VAL
46   #define Py_HUGE_VAL HUGE_VAL
47 #endif
48 #ifdef PYPY_VERSION
49   #define CYTHON_COMPILING_IN_PYPY 1
50   #define CYTHON_COMPILING_IN_PYSTON 0
51   #define CYTHON_COMPILING_IN_CPYTHON 0
52   #undef CYTHON_USE_TYPE_SLOTS
53   #define CYTHON_USE_TYPE_SLOTS 0
54   #undef CYTHON_USE_PYTYPE_LOOKUP
55   #define CYTHON_USE_PYTYPE_LOOKUP 0
56   #if PY_VERSION_HEX < 0x03050000
57     #undef CYTHON_USE_ASYNC_SLOTS
58     #define CYTHON_USE_ASYNC_SLOTS 0
59   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
60     #define CYTHON_USE_ASYNC_SLOTS 1
61   #endif
62   #undef CYTHON_USE_PYLIST_INTERNALS
63   #define CYTHON_USE_PYLIST_INTERNALS 0
64   #undef CYTHON_USE_UNICODE_INTERNALS
65   #define CYTHON_USE_UNICODE_INTERNALS 0
66   #undef CYTHON_USE_UNICODE_WRITER
67   #define CYTHON_USE_UNICODE_WRITER 0
68   #undef CYTHON_USE_PYLONG_INTERNALS
69   #define CYTHON_USE_PYLONG_INTERNALS 0
70   #undef CYTHON_AVOID_BORROWED_REFS
71   #define CYTHON_AVOID_BORROWED_REFS 1
72   #undef CYTHON_ASSUME_SAFE_MACROS
73   #define CYTHON_ASSUME_SAFE_MACROS 0
74   #undef CYTHON_UNPACK_METHODS
75   #define CYTHON_UNPACK_METHODS 0
76   #undef CYTHON_FAST_THREAD_STATE
77   #define CYTHON_FAST_THREAD_STATE 0
78   #undef CYTHON_FAST_PYCALL
79   #define CYTHON_FAST_PYCALL 0
80   #undef CYTHON_PEP489_MULTI_PHASE_INIT
81   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
82   #undef CYTHON_USE_TP_FINALIZE
83   #define CYTHON_USE_TP_FINALIZE 0
84   #undef CYTHON_USE_DICT_VERSIONS
85   #define CYTHON_USE_DICT_VERSIONS 0
86   #undef CYTHON_USE_EXC_INFO_STACK
87   #define CYTHON_USE_EXC_INFO_STACK 0
88 #elif defined(PYSTON_VERSION)
89   #define CYTHON_COMPILING_IN_PYPY 0
90   #define CYTHON_COMPILING_IN_PYSTON 1
91   #define CYTHON_COMPILING_IN_CPYTHON 0
92   #ifndef CYTHON_USE_TYPE_SLOTS
93     #define CYTHON_USE_TYPE_SLOTS 1
94   #endif
95   #undef CYTHON_USE_PYTYPE_LOOKUP
96   #define CYTHON_USE_PYTYPE_LOOKUP 0
97   #undef CYTHON_USE_ASYNC_SLOTS
98   #define CYTHON_USE_ASYNC_SLOTS 0
99   #undef CYTHON_USE_PYLIST_INTERNALS
100   #define CYTHON_USE_PYLIST_INTERNALS 0
101   #ifndef CYTHON_USE_UNICODE_INTERNALS
102     #define CYTHON_USE_UNICODE_INTERNALS 1
103   #endif
104   #undef CYTHON_USE_UNICODE_WRITER
105   #define CYTHON_USE_UNICODE_WRITER 0
106   #undef CYTHON_USE_PYLONG_INTERNALS
107   #define CYTHON_USE_PYLONG_INTERNALS 0
108   #ifndef CYTHON_AVOID_BORROWED_REFS
109     #define CYTHON_AVOID_BORROWED_REFS 0
110   #endif
111   #ifndef CYTHON_ASSUME_SAFE_MACROS
112     #define CYTHON_ASSUME_SAFE_MACROS 1
113   #endif
114   #ifndef CYTHON_UNPACK_METHODS
115     #define CYTHON_UNPACK_METHODS 1
116   #endif
117   #undef CYTHON_FAST_THREAD_STATE
118   #define CYTHON_FAST_THREAD_STATE 0
119   #undef CYTHON_FAST_PYCALL
120   #define CYTHON_FAST_PYCALL 0
121   #undef CYTHON_PEP489_MULTI_PHASE_INIT
122   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123   #undef CYTHON_USE_TP_FINALIZE
124   #define CYTHON_USE_TP_FINALIZE 0
125   #undef CYTHON_USE_DICT_VERSIONS
126   #define CYTHON_USE_DICT_VERSIONS 0
127   #undef CYTHON_USE_EXC_INFO_STACK
128   #define CYTHON_USE_EXC_INFO_STACK 0
129 #else
130   #define CYTHON_COMPILING_IN_PYPY 0
131   #define CYTHON_COMPILING_IN_PYSTON 0
132   #define CYTHON_COMPILING_IN_CPYTHON 1
133   #ifndef CYTHON_USE_TYPE_SLOTS
134     #define CYTHON_USE_TYPE_SLOTS 1
135   #endif
136   #if PY_VERSION_HEX < 0x02070000
137     #undef CYTHON_USE_PYTYPE_LOOKUP
138     #define CYTHON_USE_PYTYPE_LOOKUP 0
139   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140     #define CYTHON_USE_PYTYPE_LOOKUP 1
141   #endif
142   #if PY_MAJOR_VERSION < 3
143     #undef CYTHON_USE_ASYNC_SLOTS
144     #define CYTHON_USE_ASYNC_SLOTS 0
145   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
146     #define CYTHON_USE_ASYNC_SLOTS 1
147   #endif
148   #if PY_VERSION_HEX < 0x02070000
149     #undef CYTHON_USE_PYLONG_INTERNALS
150     #define CYTHON_USE_PYLONG_INTERNALS 0
151   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152     #define CYTHON_USE_PYLONG_INTERNALS 1
153   #endif
154   #ifndef CYTHON_USE_PYLIST_INTERNALS
155     #define CYTHON_USE_PYLIST_INTERNALS 1
156   #endif
157   #ifndef CYTHON_USE_UNICODE_INTERNALS
158     #define CYTHON_USE_UNICODE_INTERNALS 1
159   #endif
160   #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
161     #undef CYTHON_USE_UNICODE_WRITER
162     #define CYTHON_USE_UNICODE_WRITER 0
163   #elif !defined(CYTHON_USE_UNICODE_WRITER)
164     #define CYTHON_USE_UNICODE_WRITER 1
165   #endif
166   #ifndef CYTHON_AVOID_BORROWED_REFS
167     #define CYTHON_AVOID_BORROWED_REFS 0
168   #endif
169   #ifndef CYTHON_ASSUME_SAFE_MACROS
170     #define CYTHON_ASSUME_SAFE_MACROS 1
171   #endif
172   #ifndef CYTHON_UNPACK_METHODS
173     #define CYTHON_UNPACK_METHODS 1
174   #endif
175   #ifndef CYTHON_FAST_THREAD_STATE
176     #define CYTHON_FAST_THREAD_STATE 1
177   #endif
178   #ifndef CYTHON_FAST_PYCALL
179     #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030B00A1)
180   #endif
181   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183   #endif
184   #ifndef CYTHON_USE_TP_FINALIZE
185     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186   #endif
187   #ifndef CYTHON_USE_DICT_VERSIONS
188     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189   #endif
190   #ifndef CYTHON_USE_EXC_INFO_STACK
191     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192   #endif
193 #endif
194 #if !defined(CYTHON_FAST_PYCCALL)
195 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196 #endif
197 #if CYTHON_USE_PYLONG_INTERNALS
198   #if PY_MAJOR_VERSION < 3
199     #include "longintrepr.h"
200   #endif
201   #undef SHIFT
202   #undef BASE
203   #undef MASK
204   #ifdef SIZEOF_VOID_P
205     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
206   #endif
207 #endif
208 #ifndef __has_attribute
209   #define __has_attribute(x) 0
210 #endif
211 #ifndef __has_cpp_attribute
212   #define __has_cpp_attribute(x) 0
213 #endif
214 #ifndef CYTHON_RESTRICT
215   #if defined(__GNUC__)
216     #define CYTHON_RESTRICT __restrict__
217   #elif defined(_MSC_VER) && _MSC_VER >= 1400
218     #define CYTHON_RESTRICT __restrict
219   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
220     #define CYTHON_RESTRICT restrict
221   #else
222     #define CYTHON_RESTRICT
223   #endif
224 #endif
225 #ifndef CYTHON_UNUSED
226 # if defined(__GNUC__)
227 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
228 #     define CYTHON_UNUSED __attribute__ ((__unused__))
229 #   else
230 #     define CYTHON_UNUSED
231 #   endif
232 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
233 #   define CYTHON_UNUSED __attribute__ ((__unused__))
234 # else
235 #   define CYTHON_UNUSED
236 # endif
237 #endif
238 #ifndef CYTHON_MAYBE_UNUSED_VAR
239 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)240      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
241 #  else
242 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
243 #  endif
244 #endif
245 #ifndef CYTHON_NCP_UNUSED
246 # if CYTHON_COMPILING_IN_CPYTHON
247 #  define CYTHON_NCP_UNUSED
248 # else
249 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
250 # endif
251 #endif
252 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
253 #ifdef _MSC_VER
254     #ifndef _MSC_STDINT_H_
255         #if _MSC_VER < 1300
256            typedef unsigned char     uint8_t;
257            typedef unsigned int      uint32_t;
258         #else
259            typedef unsigned __int8   uint8_t;
260            typedef unsigned __int32  uint32_t;
261         #endif
262     #endif
263 #else
264    #include <stdint.h>
265 #endif
266 #ifndef CYTHON_FALLTHROUGH
267   #if defined(__cplusplus) && __cplusplus >= 201103L
268     #if __has_cpp_attribute(fallthrough)
269       #define CYTHON_FALLTHROUGH [[fallthrough]]
270     #elif __has_cpp_attribute(clang::fallthrough)
271       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
272     #elif __has_cpp_attribute(gnu::fallthrough)
273       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
274     #endif
275   #endif
276   #ifndef CYTHON_FALLTHROUGH
277     #if __has_attribute(fallthrough)
278       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
279     #else
280       #define CYTHON_FALLTHROUGH
281     #endif
282   #endif
283   #if defined(__clang__ ) && defined(__apple_build_version__)
284     #if __apple_build_version__ < 7000000
285       #undef  CYTHON_FALLTHROUGH
286       #define CYTHON_FALLTHROUGH
287     #endif
288   #endif
289 #endif
290 
291 #ifndef CYTHON_INLINE
292   #if defined(__clang__)
293     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
294   #elif defined(__GNUC__)
295     #define CYTHON_INLINE __inline__
296   #elif defined(_MSC_VER)
297     #define CYTHON_INLINE __inline
298   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
299     #define CYTHON_INLINE inline
300   #else
301     #define CYTHON_INLINE
302   #endif
303 #endif
304 
305 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
306   #define Py_OptimizeFlag 0
307 #endif
308 #define __PYX_BUILD_PY_SSIZE_T "n"
309 #define CYTHON_FORMAT_SSIZE_T "z"
310 #if PY_MAJOR_VERSION < 3
311   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
312   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
313           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
314   #define __Pyx_DefaultClassType PyClass_Type
315 #else
316   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
317   #define __Pyx_DefaultClassType PyType_Type
318 #if PY_VERSION_HEX >= 0x030B00A1
__Pyx_PyCode_New(int a,int k,int l,int s,int f,PyObject * code,PyObject * c,PyObject * n,PyObject * v,PyObject * fv,PyObject * cell,PyObject * fn,PyObject * name,int fline,PyObject * lnos)319     static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
320                                                     PyObject *code, PyObject *c, PyObject* n, PyObject *v,
321                                                     PyObject *fv, PyObject *cell, PyObject* fn,
322                                                     PyObject *name, int fline, PyObject *lnos) {
323         PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
324         PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
325         const char *fn_cstr=NULL;
326         const char *name_cstr=NULL;
327         PyCodeObject* co=NULL;
328         PyObject *type, *value, *traceback;
329         PyErr_Fetch(&type, &value, &traceback);
330         if (!(kwds=PyDict_New())) goto end;
331         if (!(argcount=PyLong_FromLong(a))) goto end;
332         if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
333         if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
334         if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
335         if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
336         if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
337         if (!(nlocals=PyLong_FromLong(l))) goto end;
338         if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
339         if (!(stacksize=PyLong_FromLong(s))) goto end;
340         if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
341         if (!(flags=PyLong_FromLong(f))) goto end;
342         if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
343         if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
344         if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
345         if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
346         if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
347         if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
348         if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
349         if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
350         if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
351         if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
352         if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
353         if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
354         if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
355         if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
356         Py_XDECREF((PyObject*)co);
357         co = (PyCodeObject*)call_result;
358         call_result = NULL;
359         if (0) {
360             cleanup_code_too:
361             Py_XDECREF((PyObject*)co);
362             co = NULL;
363         }
364         end:
365         Py_XDECREF(kwds);
366         Py_XDECREF(argcount);
367         Py_XDECREF(posonlyargcount);
368         Py_XDECREF(kwonlyargcount);
369         Py_XDECREF(nlocals);
370         Py_XDECREF(stacksize);
371         Py_XDECREF(replace);
372         Py_XDECREF(call_result);
373         Py_XDECREF(empty);
374         if (type) {
375             PyErr_Restore(type, value, traceback);
376         }
377         return co;
378     }
379 #else
380   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
381           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
382 #endif
383   #define __Pyx_DefaultClassType PyType_Type
384 #endif
385 #ifndef Py_TPFLAGS_CHECKTYPES
386   #define Py_TPFLAGS_CHECKTYPES 0
387 #endif
388 #ifndef Py_TPFLAGS_HAVE_INDEX
389   #define Py_TPFLAGS_HAVE_INDEX 0
390 #endif
391 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
392   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
393 #endif
394 #ifndef Py_TPFLAGS_HAVE_FINALIZE
395   #define Py_TPFLAGS_HAVE_FINALIZE 0
396 #endif
397 #ifndef METH_STACKLESS
398   #define METH_STACKLESS 0
399 #endif
400 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
401   #ifndef METH_FASTCALL
402      #define METH_FASTCALL 0x80
403   #endif
404   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
405   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
406                                                           Py_ssize_t nargs, PyObject *kwnames);
407 #else
408   #define __Pyx_PyCFunctionFast _PyCFunctionFast
409   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
410 #endif
411 #if CYTHON_FAST_PYCCALL
412 #define __Pyx_PyFastCFunction_Check(func)\
413     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
414 #else
415 #define __Pyx_PyFastCFunction_Check(func) 0
416 #endif
417 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
418   #define PyObject_Malloc(s)   PyMem_Malloc(s)
419   #define PyObject_Free(p)     PyMem_Free(p)
420   #define PyObject_Realloc(p)  PyMem_Realloc(p)
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
423   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
424   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
425   #define PyMem_RawFree(p)             PyMem_Free(p)
426 #endif
427 #if CYTHON_COMPILING_IN_PYSTON
428   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
429   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
430 #else
431   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
432   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
433 #endif
434 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
435   #define __Pyx_PyThreadState_Current PyThreadState_GET()
436 #elif PY_VERSION_HEX >= 0x03060000
437   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
438 #elif PY_VERSION_HEX >= 0x03000000
439   #define __Pyx_PyThreadState_Current PyThreadState_GET()
440 #else
441   #define __Pyx_PyThreadState_Current _PyThreadState_Current
442 #endif
443 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
444 #include "pythread.h"
445 #define Py_tss_NEEDS_INIT 0
446 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)447 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
448   *key = PyThread_create_key();
449   return 0;
450 }
PyThread_tss_alloc(void)451 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
452   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
453   *key = Py_tss_NEEDS_INIT;
454   return key;
455 }
PyThread_tss_free(Py_tss_t * key)456 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
457   PyObject_Free(key);
458 }
PyThread_tss_is_created(Py_tss_t * key)459 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
460   return *key != Py_tss_NEEDS_INIT;
461 }
PyThread_tss_delete(Py_tss_t * key)462 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
463   PyThread_delete_key(*key);
464   *key = Py_tss_NEEDS_INIT;
465 }
PyThread_tss_set(Py_tss_t * key,void * value)466 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
467   return PyThread_set_key_value(*key, value);
468 }
PyThread_tss_get(Py_tss_t * key)469 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
470   return PyThread_get_key_value(*key);
471 }
472 #endif
473 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
474 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
475 #else
476 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
477 #endif
478 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
479   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
480   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
481 #else
482   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
483   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
484 #endif
485 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
486 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
487 #else
488 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
489 #endif
490 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
491   #define CYTHON_PEP393_ENABLED 1
492   #if defined(PyUnicode_IS_READY)
493   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
494                                               0 : _PyUnicode_Ready((PyObject *)(op)))
495   #else
496   #define __Pyx_PyUnicode_READY(op)       (0)
497   #endif
498   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
499   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
500   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
501   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
502   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
503   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
504   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
505   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
506   #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
507   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
508   #else
509   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
510   #endif
511   #else
512   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
513   #endif
514 #else
515   #define CYTHON_PEP393_ENABLED 0
516   #define PyUnicode_1BYTE_KIND  1
517   #define PyUnicode_2BYTE_KIND  2
518   #define PyUnicode_4BYTE_KIND  4
519   #define __Pyx_PyUnicode_READY(op)       (0)
520   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
521   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
522   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
523   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
524   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
525   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
526   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
527   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
528 #endif
529 #if CYTHON_COMPILING_IN_PYPY
530   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
531   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
532 #else
533   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
534   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
535       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
536 #endif
537 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
538   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
539 #endif
540 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
541   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
542 #endif
543 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
544   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
545 #endif
546 #define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
547 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
548 #if PY_MAJOR_VERSION >= 3
549   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
550 #else
551   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
552 #endif
553 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
554   #define PyObject_ASCII(o)            PyObject_Repr(o)
555 #endif
556 #if PY_MAJOR_VERSION >= 3
557   #define PyBaseString_Type            PyUnicode_Type
558   #define PyStringObject               PyUnicodeObject
559   #define PyString_Type                PyUnicode_Type
560   #define PyString_Check               PyUnicode_Check
561   #define PyString_CheckExact          PyUnicode_CheckExact
562 #ifndef PyObject_Unicode
563   #define PyObject_Unicode             PyObject_Str
564 #endif
565 #endif
566 #if PY_MAJOR_VERSION >= 3
567   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
568   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
569 #else
570   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
571   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
572 #endif
573 #ifndef PySet_CheckExact
574   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
575 #endif
576 #if PY_VERSION_HEX >= 0x030900A4
577   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
578   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
579 #else
580   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
581   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
582 #endif
583 #if CYTHON_ASSUME_SAFE_MACROS
584   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
585 #else
586   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
587 #endif
588 #if PY_MAJOR_VERSION >= 3
589   #define PyIntObject                  PyLongObject
590   #define PyInt_Type                   PyLong_Type
591   #define PyInt_Check(op)              PyLong_Check(op)
592   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
593   #define PyInt_FromString             PyLong_FromString
594   #define PyInt_FromUnicode            PyLong_FromUnicode
595   #define PyInt_FromLong               PyLong_FromLong
596   #define PyInt_FromSize_t             PyLong_FromSize_t
597   #define PyInt_FromSsize_t            PyLong_FromSsize_t
598   #define PyInt_AsLong                 PyLong_AsLong
599   #define PyInt_AS_LONG                PyLong_AS_LONG
600   #define PyInt_AsSsize_t              PyLong_AsSsize_t
601   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
602   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
603   #define PyNumber_Int                 PyNumber_Long
604 #endif
605 #if PY_MAJOR_VERSION >= 3
606   #define PyBoolObject                 PyLongObject
607 #endif
608 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
609   #ifndef PyUnicode_InternFromString
610     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
611   #endif
612 #endif
613 #if PY_VERSION_HEX < 0x030200A4
614   typedef long Py_hash_t;
615   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
616   #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsHash_t
617 #else
618   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
619   #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsSsize_t
620 #endif
621 #if PY_MAJOR_VERSION >= 3
622   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
623 #else
624   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
625 #endif
626 #if CYTHON_USE_ASYNC_SLOTS
627   #if PY_VERSION_HEX >= 0x030500B1
628     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
629     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
630   #else
631     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
632   #endif
633 #else
634   #define __Pyx_PyType_AsAsync(obj) NULL
635 #endif
636 #ifndef __Pyx_PyAsyncMethodsStruct
637     typedef struct {
638         unaryfunc am_await;
639         unaryfunc am_aiter;
640         unaryfunc am_anext;
641     } __Pyx_PyAsyncMethodsStruct;
642 #endif
643 
644 #if defined(WIN32) || defined(MS_WINDOWS)
645   #define _USE_MATH_DEFINES
646 #endif
647 #include <math.h>
648 #ifdef NAN
649 #define __PYX_NAN() ((float) NAN)
650 #else
__PYX_NAN()651 static CYTHON_INLINE float __PYX_NAN() {
652   float value;
653   memset(&value, 0xFF, sizeof(value));
654   return value;
655 }
656 #endif
657 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
658 #define __Pyx_truncl trunc
659 #else
660 #define __Pyx_truncl truncl
661 #endif
662 
663 #define __PYX_MARK_ERR_POS(f_index, lineno) \
664     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
665 #define __PYX_ERR(f_index, lineno, Ln_error) \
666     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
667 
668 #ifndef __PYX_EXTERN_C
669   #ifdef __cplusplus
670     #define __PYX_EXTERN_C extern "C"
671   #else
672     #define __PYX_EXTERN_C extern
673   #endif
674 #endif
675 
676 #define __PYX_HAVE__bx__intervals__cluster
677 #define __PYX_HAVE_API__bx__intervals__cluster
678 /* Early includes */
679 #include "cluster.h"
680 #ifdef _OPENMP
681 #include <omp.h>
682 #endif /* _OPENMP */
683 
684 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
685 #define CYTHON_WITHOUT_ASSERTIONS
686 #endif
687 
688 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
689                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
690 
691 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
692 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
693 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
694 #define __PYX_DEFAULT_STRING_ENCODING ""
695 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
696 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
697 #define __Pyx_uchar_cast(c) ((unsigned char)c)
698 #define __Pyx_long_cast(x) ((long)x)
699 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
700     (sizeof(type) < sizeof(Py_ssize_t))  ||\
701     (sizeof(type) > sizeof(Py_ssize_t) &&\
702           likely(v < (type)PY_SSIZE_T_MAX ||\
703                  v == (type)PY_SSIZE_T_MAX)  &&\
704           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
705                                 v == (type)PY_SSIZE_T_MIN)))  ||\
706     (sizeof(type) == sizeof(Py_ssize_t) &&\
707           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
708                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)709 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
710     return (size_t) i < (size_t) limit;
711 }
712 #if defined (__cplusplus) && __cplusplus >= 201103L
713     #include <cstdlib>
714     #define __Pyx_sst_abs(value) std::abs(value)
715 #elif SIZEOF_INT >= SIZEOF_SIZE_T
716     #define __Pyx_sst_abs(value) abs(value)
717 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
718     #define __Pyx_sst_abs(value) labs(value)
719 #elif defined (_MSC_VER)
720     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
721 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
722     #define __Pyx_sst_abs(value) llabs(value)
723 #elif defined (__GNUC__)
724     #define __Pyx_sst_abs(value) __builtin_llabs(value)
725 #else
726     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
727 #endif
728 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
729 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
730 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
731 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
732 #define __Pyx_PyBytes_FromString        PyBytes_FromString
733 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
734 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
735 #if PY_MAJOR_VERSION < 3
736     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
737     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
738 #else
739     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
740     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
741 #endif
742 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
743 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
744 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
745 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
746 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
747 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
748 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
749 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
750 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
751 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
752 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
753 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
754 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
755 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
756 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
757 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)758 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
759     const Py_UNICODE *u_end = u;
760     while (*u_end++) ;
761     return (size_t)(u_end - u - 1);
762 }
763 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
764 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
765 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
766 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
767 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
768 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
769 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
770 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
771 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
772 #define __Pyx_PySequence_Tuple(obj)\
773     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
774 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
775 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
776 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
777 #if CYTHON_ASSUME_SAFE_MACROS
778 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
779 #else
780 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
781 #endif
782 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
783 #if PY_MAJOR_VERSION >= 3
784 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
785 #else
786 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
787 #endif
788 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
789 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
790 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)791 static int __Pyx_init_sys_getdefaultencoding_params(void) {
792     PyObject* sys;
793     PyObject* default_encoding = NULL;
794     PyObject* ascii_chars_u = NULL;
795     PyObject* ascii_chars_b = NULL;
796     const char* default_encoding_c;
797     sys = PyImport_ImportModule("sys");
798     if (!sys) goto bad;
799     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
800     Py_DECREF(sys);
801     if (!default_encoding) goto bad;
802     default_encoding_c = PyBytes_AsString(default_encoding);
803     if (!default_encoding_c) goto bad;
804     if (strcmp(default_encoding_c, "ascii") == 0) {
805         __Pyx_sys_getdefaultencoding_not_ascii = 0;
806     } else {
807         char ascii_chars[128];
808         int c;
809         for (c = 0; c < 128; c++) {
810             ascii_chars[c] = c;
811         }
812         __Pyx_sys_getdefaultencoding_not_ascii = 1;
813         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
814         if (!ascii_chars_u) goto bad;
815         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
816         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
817             PyErr_Format(
818                 PyExc_ValueError,
819                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
820                 default_encoding_c);
821             goto bad;
822         }
823         Py_DECREF(ascii_chars_u);
824         Py_DECREF(ascii_chars_b);
825     }
826     Py_DECREF(default_encoding);
827     return 0;
828 bad:
829     Py_XDECREF(default_encoding);
830     Py_XDECREF(ascii_chars_u);
831     Py_XDECREF(ascii_chars_b);
832     return -1;
833 }
834 #endif
835 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
836 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
837 #else
838 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
839 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
840 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)841 static int __Pyx_init_sys_getdefaultencoding_params(void) {
842     PyObject* sys;
843     PyObject* default_encoding = NULL;
844     char* default_encoding_c;
845     sys = PyImport_ImportModule("sys");
846     if (!sys) goto bad;
847     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
848     Py_DECREF(sys);
849     if (!default_encoding) goto bad;
850     default_encoding_c = PyBytes_AsString(default_encoding);
851     if (!default_encoding_c) goto bad;
852     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
853     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
854     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
855     Py_DECREF(default_encoding);
856     return 0;
857 bad:
858     Py_XDECREF(default_encoding);
859     return -1;
860 }
861 #endif
862 #endif
863 
864 
865 /* Test for GCC > 2.95 */
866 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
867   #define likely(x)   __builtin_expect(!!(x), 1)
868   #define unlikely(x) __builtin_expect(!!(x), 0)
869 #else /* !__GNUC__ or GCC < 2.95 */
870   #define likely(x)   (x)
871   #define unlikely(x) (x)
872 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)873 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
874 
875 static PyObject *__pyx_m = NULL;
876 static PyObject *__pyx_d;
877 static PyObject *__pyx_b;
878 static PyObject *__pyx_cython_runtime = NULL;
879 static PyObject *__pyx_empty_tuple;
880 static PyObject *__pyx_empty_bytes;
881 static PyObject *__pyx_empty_unicode;
882 static int __pyx_lineno;
883 static int __pyx_clineno = 0;
884 static const char * __pyx_cfilenm= __FILE__;
885 static const char *__pyx_filename;
886 
887 
888 static const char *__pyx_f[] = {
889   "lib/bx/intervals/cluster.pyx",
890   "stringsource",
891 };
892 
893 /*--- Type declarations ---*/
894 struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree;
895 
896 /* "bx/intervals/cluster.pyx":57
897  *     void free_tree(clustertree *tree)
898  *
899  * cdef class ClusterTree:             # <<<<<<<<<<<<<<
900  *     cdef clustertree *tree
901  *     cdef int mincols
902  */
903 struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree {
904   PyObject_HEAD
905   clustertree *tree;
906   int mincols;
907   int minregions;
908 };
909 
910 
911 /* --- Runtime support code (head) --- */
912 /* Refnanny.proto */
913 #ifndef CYTHON_REFNANNY
914   #define CYTHON_REFNANNY 0
915 #endif
916 #if CYTHON_REFNANNY
917   typedef struct {
918     void (*INCREF)(void*, PyObject*, int);
919     void (*DECREF)(void*, PyObject*, int);
920     void (*GOTREF)(void*, PyObject*, int);
921     void (*GIVEREF)(void*, PyObject*, int);
922     void* (*SetupContext)(const char*, int, const char*);
923     void (*FinishContext)(void**);
924   } __Pyx_RefNannyAPIStruct;
925   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
926   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
927   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
928 #ifdef WITH_THREAD
929   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
930           if (acquire_gil) {\
931               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
932               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
933               PyGILState_Release(__pyx_gilstate_save);\
934           } else {\
935               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
936           }
937 #else
938   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
939           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
940 #endif
941   #define __Pyx_RefNannyFinishContext()\
942           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
943   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
944   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
945   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
946   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
947   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
948   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
949   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
950   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
951 #else
952   #define __Pyx_RefNannyDeclarations
953   #define __Pyx_RefNannySetupContext(name, acquire_gil)
954   #define __Pyx_RefNannyFinishContext()
955   #define __Pyx_INCREF(r) Py_INCREF(r)
956   #define __Pyx_DECREF(r) Py_DECREF(r)
957   #define __Pyx_GOTREF(r)
958   #define __Pyx_GIVEREF(r)
959   #define __Pyx_XINCREF(r) Py_XINCREF(r)
960   #define __Pyx_XDECREF(r) Py_XDECREF(r)
961   #define __Pyx_XGOTREF(r)
962   #define __Pyx_XGIVEREF(r)
963 #endif
964 #define __Pyx_XDECREF_SET(r, v) do {\
965         PyObject *tmp = (PyObject *) r;\
966         r = v; __Pyx_XDECREF(tmp);\
967     } while (0)
968 #define __Pyx_DECREF_SET(r, v) do {\
969         PyObject *tmp = (PyObject *) r;\
970         r = v; __Pyx_DECREF(tmp);\
971     } while (0)
972 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
973 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
974 
975 /* PyObjectGetAttrStr.proto */
976 #if CYTHON_USE_TYPE_SLOTS
977 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
978 #else
979 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
980 #endif
981 
982 /* GetBuiltinName.proto */
983 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
984 
985 /* RaiseArgTupleInvalid.proto */
986 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
987     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
988 
989 /* RaiseDoubleKeywords.proto */
990 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
991 
992 /* ParseKeywords.proto */
993 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
994     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
995     const char* function_name);
996 
997 /* PyObjectCall.proto */
998 #if CYTHON_COMPILING_IN_CPYTHON
999 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1000 #else
1001 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1002 #endif
1003 
1004 /* PyThreadStateGet.proto */
1005 #if CYTHON_FAST_THREAD_STATE
1006 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1007 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1008 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1009 #else
1010 #define __Pyx_PyThreadState_declare
1011 #define __Pyx_PyThreadState_assign
1012 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1013 #endif
1014 
1015 /* PyErrFetchRestore.proto */
1016 #if CYTHON_FAST_THREAD_STATE
1017 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1018 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1019 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1020 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1021 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1022 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1023 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1024 #if CYTHON_COMPILING_IN_CPYTHON
1025 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1026 #else
1027 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1028 #endif
1029 #else
1030 #define __Pyx_PyErr_Clear() PyErr_Clear()
1031 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1032 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1033 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1034 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1035 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1036 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1037 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1038 #endif
1039 
1040 /* RaiseException.proto */
1041 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1042 
1043 /* ListAppend.proto */
1044 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1045 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1046     PyListObject* L = (PyListObject*) list;
1047     Py_ssize_t len = Py_SIZE(list);
1048     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1049         Py_INCREF(x);
1050         PyList_SET_ITEM(list, len, x);
1051         __Pyx_SET_SIZE(list, len + 1);
1052         return 0;
1053     }
1054     return PyList_Append(list, x);
1055 }
1056 #else
1057 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1058 #endif
1059 
1060 /* ListExtend.proto */
__Pyx_PyList_Extend(PyObject * L,PyObject * v)1061 static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
1062 #if CYTHON_COMPILING_IN_CPYTHON
1063     PyObject* none = _PyList_Extend((PyListObject*)L, v);
1064     if (unlikely(!none))
1065         return -1;
1066     Py_DECREF(none);
1067     return 0;
1068 #else
1069     return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
1070 #endif
1071 }
1072 
1073 /* PyObject_GenericGetAttrNoDict.proto */
1074 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1075 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1076 #else
1077 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1078 #endif
1079 
1080 /* PyObject_GenericGetAttr.proto */
1081 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1082 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1083 #else
1084 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1085 #endif
1086 
1087 /* PyErrExceptionMatches.proto */
1088 #if CYTHON_FAST_THREAD_STATE
1089 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1090 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1091 #else
1092 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1093 #endif
1094 
1095 /* PyObjectGetAttrStrNoError.proto */
1096 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1097 
1098 /* SetupReduce.proto */
1099 static int __Pyx_setup_reduce(PyObject* type_obj);
1100 
1101 /* PyDictVersioning.proto */
1102 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1103 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1104 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1105 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1106     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1107     (cache_var) = (value);
1108 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1109     static PY_UINT64_T __pyx_dict_version = 0;\
1110     static PyObject *__pyx_dict_cached_value = NULL;\
1111     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1112         (VAR) = __pyx_dict_cached_value;\
1113     } else {\
1114         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1115         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1116     }\
1117 }
1118 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1119 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1120 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1121 #else
1122 #define __PYX_GET_DICT_VERSION(dict)  (0)
1123 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1124 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1125 #endif
1126 
1127 /* CLineInTraceback.proto */
1128 #ifdef CYTHON_CLINE_IN_TRACEBACK
1129 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1130 #else
1131 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1132 #endif
1133 
1134 /* CodeObjectCache.proto */
1135 typedef struct {
1136     PyCodeObject* code_object;
1137     int code_line;
1138 } __Pyx_CodeObjectCacheEntry;
1139 struct __Pyx_CodeObjectCache {
1140     int count;
1141     int max_count;
1142     __Pyx_CodeObjectCacheEntry* entries;
1143 };
1144 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1145 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1146 static PyCodeObject *__pyx_find_code_object(int code_line);
1147 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1148 
1149 /* AddTraceback.proto */
1150 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1151                                int py_line, const char *filename);
1152 
1153 /* GCCDiagnostics.proto */
1154 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1155 #define __Pyx_HAS_GCC_DIAGNOSTIC
1156 #endif
1157 
1158 /* CIntFromPy.proto */
1159 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1160 
1161 /* CIntToPy.proto */
1162 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1163 
1164 /* CIntToPy.proto */
1165 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1166 
1167 /* CIntFromPy.proto */
1168 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1169 
1170 /* FastTypeChecks.proto */
1171 #if CYTHON_COMPILING_IN_CPYTHON
1172 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1173 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1174 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1175 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1176 #else
1177 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1178 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1179 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1180 #endif
1181 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1182 
1183 /* CheckBinaryVersion.proto */
1184 static int __Pyx_check_binary_version(void);
1185 
1186 /* InitStrings.proto */
1187 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1188 
1189 
1190 /* Module declarations from 'bx.intervals.cluster' */
1191 static PyTypeObject *__pyx_ptype_2bx_9intervals_7cluster_ClusterTree = 0;
1192 #define __Pyx_MODULE_NAME "bx.intervals.cluster"
1193 extern int __pyx_module_is_main_bx__intervals__cluster;
1194 int __pyx_module_is_main_bx__intervals__cluster = 0;
1195 
1196 /* Implementation of 'bx.intervals.cluster' */
1197 static PyObject *__pyx_builtin_ValueError;
1198 static PyObject *__pyx_builtin_TypeError;
1199 static const char __pyx_k_e[] = "e";
1200 static const char __pyx_k_s[] = "s";
1201 static const char __pyx_k_id[] = "id";
1202 static const char __pyx_k_main[] = "__main__";
1203 static const char __pyx_k_name[] = "__name__";
1204 static const char __pyx_k_test[] = "__test__";
1205 static const char __pyx_k_reduce[] = "__reduce__";
1206 static const char __pyx_k_mincols[] = "mincols";
1207 static const char __pyx_k_getstate[] = "__getstate__";
1208 static const char __pyx_k_setstate[] = "__setstate__";
1209 static const char __pyx_k_TypeError[] = "TypeError";
1210 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1211 static const char __pyx_k_ValueError[] = "ValueError";
1212 static const char __pyx_k_minregions[] = "minregions";
1213 static const char __pyx_k_ClusterTree[] = "ClusterTree";
1214 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1215 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1216 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1217 static const char __pyx_k_Kanwei_Li_2009_Inspired_by_prev[] = "\nKanwei Li, 2009\nInspired by previous ClusterTree\n\nProvides a ClusterTree data structure that supports efficient finding of \nclusters of intervals that are within a certain distance apart.\n\nThis clustering algorithm uses a binary tree structure. Nodes correspond to \nnon-overlapping intervals, where overlapping means that the distance between\ntwo intervals is less or equal to the max separation.\n\nThe tree self-balances using rotations based on the binomial sequence. Merges\namong nodes are performed whenever a node is changed/added that will cause other\nnodes to form a new cluster.\n\nC source code is in src/cluster.c\n";
1218 static const char __pyx_k_Interval_start_must_be_before_en[] = "Interval start must be before end";
1219 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
1220 static PyObject *__pyx_n_s_ClusterTree;
1221 static PyObject *__pyx_kp_s_Interval_start_must_be_before_en;
1222 static PyObject *__pyx_n_s_TypeError;
1223 static PyObject *__pyx_n_s_ValueError;
1224 static PyObject *__pyx_n_s_cline_in_traceback;
1225 static PyObject *__pyx_n_s_e;
1226 static PyObject *__pyx_n_s_getstate;
1227 static PyObject *__pyx_n_s_id;
1228 static PyObject *__pyx_n_s_main;
1229 static PyObject *__pyx_n_s_mincols;
1230 static PyObject *__pyx_n_s_minregions;
1231 static PyObject *__pyx_n_s_name;
1232 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
1233 static PyObject *__pyx_n_s_reduce;
1234 static PyObject *__pyx_n_s_reduce_cython;
1235 static PyObject *__pyx_n_s_reduce_ex;
1236 static PyObject *__pyx_n_s_s;
1237 static PyObject *__pyx_n_s_setstate;
1238 static PyObject *__pyx_n_s_setstate_cython;
1239 static PyObject *__pyx_n_s_test;
1240 static int __pyx_pf_2bx_9intervals_7cluster_11ClusterTree___cinit__(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self, PyObject *__pyx_v_mincols, PyObject *__pyx_v_minregions); /* proto */
1241 static void __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_2__dealloc__(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self); /* proto */
1242 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_4insert(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self, PyObject *__pyx_v_s, PyObject *__pyx_v_e, PyObject *__pyx_v_id); /* proto */
1243 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_6getregions(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self); /* proto */
1244 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_8getlines(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self); /* proto */
1245 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self); /* proto */
1246 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1247 static PyObject *__pyx_tp_new_2bx_9intervals_7cluster_ClusterTree(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1248 static PyObject *__pyx_tuple_;
1249 static PyObject *__pyx_tuple__2;
1250 static PyObject *__pyx_tuple__3;
1251 /* Late includes */
1252 
1253 /* "bx/intervals/cluster.pyx":62
1254  *     cdef int minregions
1255  *
1256  *     def __cinit__(self, mincols, minregions):             # <<<<<<<<<<<<<<
1257  *         self.tree = create_clustertree(mincols, minregions)
1258  *         self.mincols = mincols
1259  */
1260 
1261 /* Python wrapper */
1262 static int __pyx_pw_2bx_9intervals_7cluster_11ClusterTree_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_1__cinit__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1263 static int __pyx_pw_2bx_9intervals_7cluster_11ClusterTree_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1264   PyObject *__pyx_v_mincols = 0;
1265   PyObject *__pyx_v_minregions = 0;
1266   int __pyx_lineno = 0;
1267   const char *__pyx_filename = NULL;
1268   int __pyx_clineno = 0;
1269   int __pyx_r;
1270   __Pyx_RefNannyDeclarations
1271   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
1272   {
1273     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mincols,&__pyx_n_s_minregions,0};
1274     PyObject* values[2] = {0,0};
1275     if (unlikely(__pyx_kwds)) {
1276       Py_ssize_t kw_args;
1277       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1278       switch (pos_args) {
1279         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1280         CYTHON_FALLTHROUGH;
1281         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1282         CYTHON_FALLTHROUGH;
1283         case  0: break;
1284         default: goto __pyx_L5_argtuple_error;
1285       }
1286       kw_args = PyDict_Size(__pyx_kwds);
1287       switch (pos_args) {
1288         case  0:
1289         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mincols)) != 0)) kw_args--;
1290         else goto __pyx_L5_argtuple_error;
1291         CYTHON_FALLTHROUGH;
1292         case  1:
1293         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_minregions)) != 0)) kw_args--;
1294         else {
1295           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 62, __pyx_L3_error)
1296         }
1297       }
1298       if (unlikely(kw_args > 0)) {
1299         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 62, __pyx_L3_error)
1300       }
1301     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
1302       goto __pyx_L5_argtuple_error;
1303     } else {
1304       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1305       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1306     }
1307     __pyx_v_mincols = values[0];
1308     __pyx_v_minregions = values[1];
1309   }
1310   goto __pyx_L4_argument_unpacking_done;
1311   __pyx_L5_argtuple_error:;
1312   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 62, __pyx_L3_error)
1313   __pyx_L3_error:;
1314   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1315   __Pyx_RefNannyFinishContext();
1316   return -1;
1317   __pyx_L4_argument_unpacking_done:;
1318   __pyx_r = __pyx_pf_2bx_9intervals_7cluster_11ClusterTree___cinit__(((struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *)__pyx_v_self), __pyx_v_mincols, __pyx_v_minregions);
1319 
1320   /* function exit code */
1321   __Pyx_RefNannyFinishContext();
1322   return __pyx_r;
1323 }
1324 
__pyx_pf_2bx_9intervals_7cluster_11ClusterTree___cinit__(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree * __pyx_v_self,PyObject * __pyx_v_mincols,PyObject * __pyx_v_minregions)1325 static int __pyx_pf_2bx_9intervals_7cluster_11ClusterTree___cinit__(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self, PyObject *__pyx_v_mincols, PyObject *__pyx_v_minregions) {
1326   int __pyx_r;
1327   __Pyx_RefNannyDeclarations
1328   int __pyx_t_1;
1329   int __pyx_t_2;
1330   int __pyx_lineno = 0;
1331   const char *__pyx_filename = NULL;
1332   int __pyx_clineno = 0;
1333   __Pyx_RefNannySetupContext("__cinit__", 0);
1334 
1335   /* "bx/intervals/cluster.pyx":63
1336  *
1337  *     def __cinit__(self, mincols, minregions):
1338  *         self.tree = create_clustertree(mincols, minregions)             # <<<<<<<<<<<<<<
1339  *         self.mincols = mincols
1340  *         self.minregions = minregions
1341  */
1342   __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_mincols); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 63, __pyx_L1_error)
1343   __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_minregions); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 63, __pyx_L1_error)
1344   __pyx_v_self->tree = create_clustertree(__pyx_t_1, __pyx_t_2);
1345 
1346   /* "bx/intervals/cluster.pyx":64
1347  *     def __cinit__(self, mincols, minregions):
1348  *         self.tree = create_clustertree(mincols, minregions)
1349  *         self.mincols = mincols             # <<<<<<<<<<<<<<
1350  *         self.minregions = minregions
1351  *
1352  */
1353   __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_mincols); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 64, __pyx_L1_error)
1354   __pyx_v_self->mincols = __pyx_t_2;
1355 
1356   /* "bx/intervals/cluster.pyx":65
1357  *         self.tree = create_clustertree(mincols, minregions)
1358  *         self.mincols = mincols
1359  *         self.minregions = minregions             # <<<<<<<<<<<<<<
1360  *
1361  *     def __dealloc__(self):
1362  */
1363   __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_minregions); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 65, __pyx_L1_error)
1364   __pyx_v_self->minregions = __pyx_t_2;
1365 
1366   /* "bx/intervals/cluster.pyx":62
1367  *     cdef int minregions
1368  *
1369  *     def __cinit__(self, mincols, minregions):             # <<<<<<<<<<<<<<
1370  *         self.tree = create_clustertree(mincols, minregions)
1371  *         self.mincols = mincols
1372  */
1373 
1374   /* function exit code */
1375   __pyx_r = 0;
1376   goto __pyx_L0;
1377   __pyx_L1_error:;
1378   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1379   __pyx_r = -1;
1380   __pyx_L0:;
1381   __Pyx_RefNannyFinishContext();
1382   return __pyx_r;
1383 }
1384 
1385 /* "bx/intervals/cluster.pyx":67
1386  *         self.minregions = minregions
1387  *
1388  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1389  *         free_tree(self.tree)
1390  *
1391  */
1392 
1393 /* Python wrapper */
1394 static void __pyx_pw_2bx_9intervals_7cluster_11ClusterTree_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_3__dealloc__(PyObject * __pyx_v_self)1395 static void __pyx_pw_2bx_9intervals_7cluster_11ClusterTree_3__dealloc__(PyObject *__pyx_v_self) {
1396   __Pyx_RefNannyDeclarations
1397   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
1398   __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_2__dealloc__(((struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *)__pyx_v_self));
1399 
1400   /* function exit code */
1401   __Pyx_RefNannyFinishContext();
1402 }
1403 
__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_2__dealloc__(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree * __pyx_v_self)1404 static void __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_2__dealloc__(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self) {
1405   __Pyx_RefNannyDeclarations
1406   __Pyx_RefNannySetupContext("__dealloc__", 0);
1407 
1408   /* "bx/intervals/cluster.pyx":68
1409  *
1410  *     def __dealloc__(self):
1411  *         free_tree(self.tree)             # <<<<<<<<<<<<<<
1412  *
1413  *     def insert(self, s, e, id):
1414  */
1415   free_tree(__pyx_v_self->tree);
1416 
1417   /* "bx/intervals/cluster.pyx":67
1418  *         self.minregions = minregions
1419  *
1420  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1421  *         free_tree(self.tree)
1422  *
1423  */
1424 
1425   /* function exit code */
1426   __Pyx_RefNannyFinishContext();
1427 }
1428 
1429 /* "bx/intervals/cluster.pyx":70
1430  *         free_tree(self.tree)
1431  *
1432  *     def insert(self, s, e, id):             # <<<<<<<<<<<<<<
1433  *         ''' Insert an interval with start, end, id as parameters'''
1434  *         if s > e: raise ValueError("Interval start must be before end")
1435  */
1436 
1437 /* Python wrapper */
1438 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_5insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1439 static char __pyx_doc_2bx_9intervals_7cluster_11ClusterTree_4insert[] = " Insert an interval with start, end, id as parameters";
__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_5insert(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1440 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_5insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1441   PyObject *__pyx_v_s = 0;
1442   PyObject *__pyx_v_e = 0;
1443   PyObject *__pyx_v_id = 0;
1444   int __pyx_lineno = 0;
1445   const char *__pyx_filename = NULL;
1446   int __pyx_clineno = 0;
1447   PyObject *__pyx_r = 0;
1448   __Pyx_RefNannyDeclarations
1449   __Pyx_RefNannySetupContext("insert (wrapper)", 0);
1450   {
1451     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_s,&__pyx_n_s_e,&__pyx_n_s_id,0};
1452     PyObject* values[3] = {0,0,0};
1453     if (unlikely(__pyx_kwds)) {
1454       Py_ssize_t kw_args;
1455       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1456       switch (pos_args) {
1457         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1458         CYTHON_FALLTHROUGH;
1459         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1460         CYTHON_FALLTHROUGH;
1461         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1462         CYTHON_FALLTHROUGH;
1463         case  0: break;
1464         default: goto __pyx_L5_argtuple_error;
1465       }
1466       kw_args = PyDict_Size(__pyx_kwds);
1467       switch (pos_args) {
1468         case  0:
1469         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_s)) != 0)) kw_args--;
1470         else goto __pyx_L5_argtuple_error;
1471         CYTHON_FALLTHROUGH;
1472         case  1:
1473         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_e)) != 0)) kw_args--;
1474         else {
1475           __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, 1); __PYX_ERR(0, 70, __pyx_L3_error)
1476         }
1477         CYTHON_FALLTHROUGH;
1478         case  2:
1479         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_id)) != 0)) kw_args--;
1480         else {
1481           __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, 2); __PYX_ERR(0, 70, __pyx_L3_error)
1482         }
1483       }
1484       if (unlikely(kw_args > 0)) {
1485         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "insert") < 0)) __PYX_ERR(0, 70, __pyx_L3_error)
1486       }
1487     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
1488       goto __pyx_L5_argtuple_error;
1489     } else {
1490       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1491       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1492       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1493     }
1494     __pyx_v_s = values[0];
1495     __pyx_v_e = values[1];
1496     __pyx_v_id = values[2];
1497   }
1498   goto __pyx_L4_argument_unpacking_done;
1499   __pyx_L5_argtuple_error:;
1500   __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 70, __pyx_L3_error)
1501   __pyx_L3_error:;
1502   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.insert", __pyx_clineno, __pyx_lineno, __pyx_filename);
1503   __Pyx_RefNannyFinishContext();
1504   return NULL;
1505   __pyx_L4_argument_unpacking_done:;
1506   __pyx_r = __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_4insert(((struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *)__pyx_v_self), __pyx_v_s, __pyx_v_e, __pyx_v_id);
1507 
1508   /* function exit code */
1509   __Pyx_RefNannyFinishContext();
1510   return __pyx_r;
1511 }
1512 
__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_4insert(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree * __pyx_v_self,PyObject * __pyx_v_s,PyObject * __pyx_v_e,PyObject * __pyx_v_id)1513 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_4insert(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self, PyObject *__pyx_v_s, PyObject *__pyx_v_e, PyObject *__pyx_v_id) {
1514   PyObject *__pyx_r = NULL;
1515   __Pyx_RefNannyDeclarations
1516   PyObject *__pyx_t_1 = NULL;
1517   int __pyx_t_2;
1518   int __pyx_t_3;
1519   int __pyx_t_4;
1520   int __pyx_t_5;
1521   int __pyx_lineno = 0;
1522   const char *__pyx_filename = NULL;
1523   int __pyx_clineno = 0;
1524   __Pyx_RefNannySetupContext("insert", 0);
1525 
1526   /* "bx/intervals/cluster.pyx":72
1527  *     def insert(self, s, e, id):
1528  *         ''' Insert an interval with start, end, id as parameters'''
1529  *         if s > e: raise ValueError("Interval start must be before end")             # <<<<<<<<<<<<<<
1530  *         self.tree.root = clusternode_insert(self.tree, self.tree.root, s, e, id)
1531  *
1532  */
1533   __pyx_t_1 = PyObject_RichCompare(__pyx_v_s, __pyx_v_e, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
1534   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 72, __pyx_L1_error)
1535   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1536   if (unlikely(__pyx_t_2)) {
1537     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
1538     __Pyx_GOTREF(__pyx_t_1);
1539     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
1540     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1541     __PYX_ERR(0, 72, __pyx_L1_error)
1542   }
1543 
1544   /* "bx/intervals/cluster.pyx":73
1545  *         ''' Insert an interval with start, end, id as parameters'''
1546  *         if s > e: raise ValueError("Interval start must be before end")
1547  *         self.tree.root = clusternode_insert(self.tree, self.tree.root, s, e, id)             # <<<<<<<<<<<<<<
1548  *
1549  *     def getregions(self):
1550  */
1551   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_s); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L1_error)
1552   __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_e); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L1_error)
1553   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_id); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L1_error)
1554   __pyx_v_self->tree->root = clusternode_insert(__pyx_v_self->tree, __pyx_v_self->tree->root, __pyx_t_3, __pyx_t_4, __pyx_t_5);
1555 
1556   /* "bx/intervals/cluster.pyx":70
1557  *         free_tree(self.tree)
1558  *
1559  *     def insert(self, s, e, id):             # <<<<<<<<<<<<<<
1560  *         ''' Insert an interval with start, end, id as parameters'''
1561  *         if s > e: raise ValueError("Interval start must be before end")
1562  */
1563 
1564   /* function exit code */
1565   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1566   goto __pyx_L0;
1567   __pyx_L1_error:;
1568   __Pyx_XDECREF(__pyx_t_1);
1569   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.insert", __pyx_clineno, __pyx_lineno, __pyx_filename);
1570   __pyx_r = NULL;
1571   __pyx_L0:;
1572   __Pyx_XGIVEREF(__pyx_r);
1573   __Pyx_RefNannyFinishContext();
1574   return __pyx_r;
1575 }
1576 
1577 /* "bx/intervals/cluster.pyx":75
1578  *         self.tree.root = clusternode_insert(self.tree, self.tree.root, s, e, id)
1579  *
1580  *     def getregions(self):             # <<<<<<<<<<<<<<
1581  *         ''' Returns a list clusters in ascending order of starting position.
1582  *             Each cluster is a tuple of (start, end, [sorted ids of intervals in cluster])
1583  */
1584 
1585 /* Python wrapper */
1586 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_7getregions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1587 static char __pyx_doc_2bx_9intervals_7cluster_11ClusterTree_6getregions[] = " Returns a list clusters in ascending order of starting position.\n            Each cluster is a tuple of (start, end, [sorted ids of intervals in cluster])\n        \n        tree = ClusterTree(0, 0)\n        Insert (6, 7, 1), (1, 2, 3), (9, 10, 2), (3, 4, 0), (3, 8, 4)\n        tree.getregions() returns [(1, 2, [3]), (3, 8, [0, 1, 4]), (9, 10, [2])]\n        ";
__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_7getregions(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1588 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_7getregions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1589   PyObject *__pyx_r = 0;
1590   __Pyx_RefNannyDeclarations
1591   __Pyx_RefNannySetupContext("getregions (wrapper)", 0);
1592   __pyx_r = __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_6getregions(((struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *)__pyx_v_self));
1593 
1594   /* function exit code */
1595   __Pyx_RefNannyFinishContext();
1596   return __pyx_r;
1597 }
1598 
__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_6getregions(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree * __pyx_v_self)1599 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_6getregions(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self) {
1600   treeitr *__pyx_v_itr;
1601   interval *__pyx_v_ival;
1602   PyObject *__pyx_v_regions = NULL;
1603   PyObject *__pyx_v_ids = NULL;
1604   PyObject *__pyx_r = NULL;
1605   __Pyx_RefNannyDeclarations
1606   PyObject *__pyx_t_1 = NULL;
1607   int __pyx_t_2;
1608   struct struct_interval *__pyx_t_3;
1609   int __pyx_t_4;
1610   PyObject *__pyx_t_5 = NULL;
1611   PyObject *__pyx_t_6 = NULL;
1612   PyObject *__pyx_t_7 = NULL;
1613   struct struct_treeitr *__pyx_t_8;
1614   int __pyx_lineno = 0;
1615   const char *__pyx_filename = NULL;
1616   int __pyx_clineno = 0;
1617   __Pyx_RefNannySetupContext("getregions", 0);
1618 
1619   /* "bx/intervals/cluster.pyx":86
1620  *         cdef interval *ival
1621  *
1622  *         regions = []             # <<<<<<<<<<<<<<
1623  *         itr = clusteritr(self.tree)
1624  *
1625  */
1626   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
1627   __Pyx_GOTREF(__pyx_t_1);
1628   __pyx_v_regions = ((PyObject*)__pyx_t_1);
1629   __pyx_t_1 = 0;
1630 
1631   /* "bx/intervals/cluster.pyx":87
1632  *
1633  *         regions = []
1634  *         itr = clusteritr(self.tree)             # <<<<<<<<<<<<<<
1635  *
1636  *         while (itr):
1637  */
1638   __pyx_v_itr = clusteritr(__pyx_v_self->tree);
1639 
1640   /* "bx/intervals/cluster.pyx":89
1641  *         itr = clusteritr(self.tree)
1642  *
1643  *         while (itr):             # <<<<<<<<<<<<<<
1644  *             ids = []
1645  *             ival = itr.node.interval_head
1646  */
1647   while (1) {
1648     __pyx_t_2 = (__pyx_v_itr != 0);
1649     if (!__pyx_t_2) break;
1650 
1651     /* "bx/intervals/cluster.pyx":90
1652  *
1653  *         while (itr):
1654  *             ids = []             # <<<<<<<<<<<<<<
1655  *             ival = itr.node.interval_head
1656  *             while (ival):
1657  */
1658     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
1659     __Pyx_GOTREF(__pyx_t_1);
1660     __Pyx_XDECREF_SET(__pyx_v_ids, ((PyObject*)__pyx_t_1));
1661     __pyx_t_1 = 0;
1662 
1663     /* "bx/intervals/cluster.pyx":91
1664  *         while (itr):
1665  *             ids = []
1666  *             ival = itr.node.interval_head             # <<<<<<<<<<<<<<
1667  *             while (ival):
1668  *                 ids.append(ival.id)
1669  */
1670     __pyx_t_3 = __pyx_v_itr->node->interval_head;
1671     __pyx_v_ival = __pyx_t_3;
1672 
1673     /* "bx/intervals/cluster.pyx":92
1674  *             ids = []
1675  *             ival = itr.node.interval_head
1676  *             while (ival):             # <<<<<<<<<<<<<<
1677  *                 ids.append(ival.id)
1678  *                 ival = ival.next
1679  */
1680     while (1) {
1681       __pyx_t_2 = (__pyx_v_ival != 0);
1682       if (!__pyx_t_2) break;
1683 
1684       /* "bx/intervals/cluster.pyx":93
1685  *             ival = itr.node.interval_head
1686  *             while (ival):
1687  *                 ids.append(ival.id)             # <<<<<<<<<<<<<<
1688  *                 ival = ival.next
1689  *
1690  */
1691       __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ival->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
1692       __Pyx_GOTREF(__pyx_t_1);
1693       __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_ids, __pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 93, __pyx_L1_error)
1694       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1695 
1696       /* "bx/intervals/cluster.pyx":94
1697  *             while (ival):
1698  *                 ids.append(ival.id)
1699  *                 ival = ival.next             # <<<<<<<<<<<<<<
1700  *
1701  *             regions.append( (itr.node.start, itr.node.end, sorted(ids)) )
1702  */
1703       __pyx_t_3 = __pyx_v_ival->next;
1704       __pyx_v_ival = __pyx_t_3;
1705     }
1706 
1707     /* "bx/intervals/cluster.pyx":96
1708  *                 ival = ival.next
1709  *
1710  *             regions.append( (itr.node.start, itr.node.end, sorted(ids)) )             # <<<<<<<<<<<<<<
1711  *             itr = itr.next
1712  *         freeclusteritr(itr)
1713  */
1714     __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_itr->node->start); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
1715     __Pyx_GOTREF(__pyx_t_1);
1716     __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_itr->node->end); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error)
1717     __Pyx_GOTREF(__pyx_t_5);
1718     __pyx_t_7 = PySequence_List(__pyx_v_ids); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 96, __pyx_L1_error)
1719     __Pyx_GOTREF(__pyx_t_7);
1720     __pyx_t_6 = ((PyObject*)__pyx_t_7);
1721     __pyx_t_7 = 0;
1722     __pyx_t_4 = PyList_Sort(__pyx_t_6); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 96, __pyx_L1_error)
1723     __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 96, __pyx_L1_error)
1724     __Pyx_GOTREF(__pyx_t_7);
1725     __Pyx_GIVEREF(__pyx_t_1);
1726     PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
1727     __Pyx_GIVEREF(__pyx_t_5);
1728     PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
1729     __Pyx_GIVEREF(__pyx_t_6);
1730     PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
1731     __pyx_t_1 = 0;
1732     __pyx_t_5 = 0;
1733     __pyx_t_6 = 0;
1734     __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_regions, __pyx_t_7); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 96, __pyx_L1_error)
1735     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1736 
1737     /* "bx/intervals/cluster.pyx":97
1738  *
1739  *             regions.append( (itr.node.start, itr.node.end, sorted(ids)) )
1740  *             itr = itr.next             # <<<<<<<<<<<<<<
1741  *         freeclusteritr(itr)
1742  *         return regions
1743  */
1744     __pyx_t_8 = __pyx_v_itr->next;
1745     __pyx_v_itr = __pyx_t_8;
1746   }
1747 
1748   /* "bx/intervals/cluster.pyx":98
1749  *             regions.append( (itr.node.start, itr.node.end, sorted(ids)) )
1750  *             itr = itr.next
1751  *         freeclusteritr(itr)             # <<<<<<<<<<<<<<
1752  *         return regions
1753  *
1754  */
1755   freeclusteritr(__pyx_v_itr);
1756 
1757   /* "bx/intervals/cluster.pyx":99
1758  *             itr = itr.next
1759  *         freeclusteritr(itr)
1760  *         return regions             # <<<<<<<<<<<<<<
1761  *
1762  *     def getlines(self):
1763  */
1764   __Pyx_XDECREF(__pyx_r);
1765   __Pyx_INCREF(__pyx_v_regions);
1766   __pyx_r = __pyx_v_regions;
1767   goto __pyx_L0;
1768 
1769   /* "bx/intervals/cluster.pyx":75
1770  *         self.tree.root = clusternode_insert(self.tree, self.tree.root, s, e, id)
1771  *
1772  *     def getregions(self):             # <<<<<<<<<<<<<<
1773  *         ''' Returns a list clusters in ascending order of starting position.
1774  *             Each cluster is a tuple of (start, end, [sorted ids of intervals in cluster])
1775  */
1776 
1777   /* function exit code */
1778   __pyx_L1_error:;
1779   __Pyx_XDECREF(__pyx_t_1);
1780   __Pyx_XDECREF(__pyx_t_5);
1781   __Pyx_XDECREF(__pyx_t_6);
1782   __Pyx_XDECREF(__pyx_t_7);
1783   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.getregions", __pyx_clineno, __pyx_lineno, __pyx_filename);
1784   __pyx_r = NULL;
1785   __pyx_L0:;
1786   __Pyx_XDECREF(__pyx_v_regions);
1787   __Pyx_XDECREF(__pyx_v_ids);
1788   __Pyx_XGIVEREF(__pyx_r);
1789   __Pyx_RefNannyFinishContext();
1790   return __pyx_r;
1791 }
1792 
1793 /* "bx/intervals/cluster.pyx":101
1794  *         return regions
1795  *
1796  *     def getlines(self):             # <<<<<<<<<<<<<<
1797  *         ''' Similar to getregions except it just returns a list of ids of intervals
1798  *             The above example would return [3, 0, 1, 4, 2]
1799  */
1800 
1801 /* Python wrapper */
1802 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_9getlines(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1803 static char __pyx_doc_2bx_9intervals_7cluster_11ClusterTree_8getlines[] = " Similar to getregions except it just returns a list of ids of intervals\n            The above example would return [3, 0, 1, 4, 2]\n         ";
__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_9getlines(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1804 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_9getlines(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1805   PyObject *__pyx_r = 0;
1806   __Pyx_RefNannyDeclarations
1807   __Pyx_RefNannySetupContext("getlines (wrapper)", 0);
1808   __pyx_r = __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_8getlines(((struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *)__pyx_v_self));
1809 
1810   /* function exit code */
1811   __Pyx_RefNannyFinishContext();
1812   return __pyx_r;
1813 }
1814 
__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_8getlines(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree * __pyx_v_self)1815 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_8getlines(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self) {
1816   treeitr *__pyx_v_itr;
1817   interval *__pyx_v_ival;
1818   PyObject *__pyx_v_lines = NULL;
1819   PyObject *__pyx_v_ids = NULL;
1820   PyObject *__pyx_r = NULL;
1821   __Pyx_RefNannyDeclarations
1822   PyObject *__pyx_t_1 = NULL;
1823   int __pyx_t_2;
1824   struct struct_interval *__pyx_t_3;
1825   int __pyx_t_4;
1826   PyObject *__pyx_t_5 = NULL;
1827   struct struct_treeitr *__pyx_t_6;
1828   int __pyx_lineno = 0;
1829   const char *__pyx_filename = NULL;
1830   int __pyx_clineno = 0;
1831   __Pyx_RefNannySetupContext("getlines", 0);
1832 
1833   /* "bx/intervals/cluster.pyx":108
1834  *         cdef interval *ival
1835  *
1836  *         lines = []             # <<<<<<<<<<<<<<
1837  *         itr = clusteritr(self.tree)
1838  *
1839  */
1840   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error)
1841   __Pyx_GOTREF(__pyx_t_1);
1842   __pyx_v_lines = ((PyObject*)__pyx_t_1);
1843   __pyx_t_1 = 0;
1844 
1845   /* "bx/intervals/cluster.pyx":109
1846  *
1847  *         lines = []
1848  *         itr = clusteritr(self.tree)             # <<<<<<<<<<<<<<
1849  *
1850  *         while (itr):
1851  */
1852   __pyx_v_itr = clusteritr(__pyx_v_self->tree);
1853 
1854   /* "bx/intervals/cluster.pyx":111
1855  *         itr = clusteritr(self.tree)
1856  *
1857  *         while (itr):             # <<<<<<<<<<<<<<
1858  *             ids = []
1859  *             ival = itr.node.interval_head
1860  */
1861   while (1) {
1862     __pyx_t_2 = (__pyx_v_itr != 0);
1863     if (!__pyx_t_2) break;
1864 
1865     /* "bx/intervals/cluster.pyx":112
1866  *
1867  *         while (itr):
1868  *             ids = []             # <<<<<<<<<<<<<<
1869  *             ival = itr.node.interval_head
1870  *             while (ival):
1871  */
1872     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
1873     __Pyx_GOTREF(__pyx_t_1);
1874     __Pyx_XDECREF_SET(__pyx_v_ids, ((PyObject*)__pyx_t_1));
1875     __pyx_t_1 = 0;
1876 
1877     /* "bx/intervals/cluster.pyx":113
1878  *         while (itr):
1879  *             ids = []
1880  *             ival = itr.node.interval_head             # <<<<<<<<<<<<<<
1881  *             while (ival):
1882  *                 ids.append(ival.id)
1883  */
1884     __pyx_t_3 = __pyx_v_itr->node->interval_head;
1885     __pyx_v_ival = __pyx_t_3;
1886 
1887     /* "bx/intervals/cluster.pyx":114
1888  *             ids = []
1889  *             ival = itr.node.interval_head
1890  *             while (ival):             # <<<<<<<<<<<<<<
1891  *                 ids.append(ival.id)
1892  *                 ival = ival.next
1893  */
1894     while (1) {
1895       __pyx_t_2 = (__pyx_v_ival != 0);
1896       if (!__pyx_t_2) break;
1897 
1898       /* "bx/intervals/cluster.pyx":115
1899  *             ival = itr.node.interval_head
1900  *             while (ival):
1901  *                 ids.append(ival.id)             # <<<<<<<<<<<<<<
1902  *                 ival = ival.next
1903  *
1904  */
1905       __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ival->id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
1906       __Pyx_GOTREF(__pyx_t_1);
1907       __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_ids, __pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 115, __pyx_L1_error)
1908       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1909 
1910       /* "bx/intervals/cluster.pyx":116
1911  *             while (ival):
1912  *                 ids.append(ival.id)
1913  *                 ival = ival.next             # <<<<<<<<<<<<<<
1914  *
1915  *             lines.extend(sorted(ids))
1916  */
1917       __pyx_t_3 = __pyx_v_ival->next;
1918       __pyx_v_ival = __pyx_t_3;
1919     }
1920 
1921     /* "bx/intervals/cluster.pyx":118
1922  *                 ival = ival.next
1923  *
1924  *             lines.extend(sorted(ids))             # <<<<<<<<<<<<<<
1925  *             itr = itr.next
1926  *         freeclusteritr(itr)
1927  */
1928     __pyx_t_5 = PySequence_List(__pyx_v_ids); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error)
1929     __Pyx_GOTREF(__pyx_t_5);
1930     __pyx_t_1 = ((PyObject*)__pyx_t_5);
1931     __pyx_t_5 = 0;
1932     __pyx_t_4 = PyList_Sort(__pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 118, __pyx_L1_error)
1933     __pyx_t_4 = __Pyx_PyList_Extend(__pyx_v_lines, __pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 118, __pyx_L1_error)
1934     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1935 
1936     /* "bx/intervals/cluster.pyx":119
1937  *
1938  *             lines.extend(sorted(ids))
1939  *             itr = itr.next             # <<<<<<<<<<<<<<
1940  *         freeclusteritr(itr)
1941  *         return lines
1942  */
1943     __pyx_t_6 = __pyx_v_itr->next;
1944     __pyx_v_itr = __pyx_t_6;
1945   }
1946 
1947   /* "bx/intervals/cluster.pyx":120
1948  *             lines.extend(sorted(ids))
1949  *             itr = itr.next
1950  *         freeclusteritr(itr)             # <<<<<<<<<<<<<<
1951  *         return lines
1952  *
1953  */
1954   freeclusteritr(__pyx_v_itr);
1955 
1956   /* "bx/intervals/cluster.pyx":121
1957  *             itr = itr.next
1958  *         freeclusteritr(itr)
1959  *         return lines             # <<<<<<<<<<<<<<
1960  *
1961  */
1962   __Pyx_XDECREF(__pyx_r);
1963   __Pyx_INCREF(__pyx_v_lines);
1964   __pyx_r = __pyx_v_lines;
1965   goto __pyx_L0;
1966 
1967   /* "bx/intervals/cluster.pyx":101
1968  *         return regions
1969  *
1970  *     def getlines(self):             # <<<<<<<<<<<<<<
1971  *         ''' Similar to getregions except it just returns a list of ids of intervals
1972  *             The above example would return [3, 0, 1, 4, 2]
1973  */
1974 
1975   /* function exit code */
1976   __pyx_L1_error:;
1977   __Pyx_XDECREF(__pyx_t_1);
1978   __Pyx_XDECREF(__pyx_t_5);
1979   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.getlines", __pyx_clineno, __pyx_lineno, __pyx_filename);
1980   __pyx_r = NULL;
1981   __pyx_L0:;
1982   __Pyx_XDECREF(__pyx_v_lines);
1983   __Pyx_XDECREF(__pyx_v_ids);
1984   __Pyx_XGIVEREF(__pyx_r);
1985   __Pyx_RefNannyFinishContext();
1986   return __pyx_r;
1987 }
1988 
1989 /* "(tree fragment)":1
1990  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
1991  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1992  * def __setstate_cython__(self, __pyx_state):
1993  */
1994 
1995 /* Python wrapper */
1996 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_11__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1997 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1998   PyObject *__pyx_r = 0;
1999   __Pyx_RefNannyDeclarations
2000   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
2001   __pyx_r = __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_10__reduce_cython__(((struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *)__pyx_v_self));
2002 
2003   /* function exit code */
2004   __Pyx_RefNannyFinishContext();
2005   return __pyx_r;
2006 }
2007 
__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree * __pyx_v_self)2008 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self) {
2009   PyObject *__pyx_r = NULL;
2010   __Pyx_RefNannyDeclarations
2011   PyObject *__pyx_t_1 = NULL;
2012   int __pyx_lineno = 0;
2013   const char *__pyx_filename = NULL;
2014   int __pyx_clineno = 0;
2015   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
2016 
2017   /* "(tree fragment)":2
2018  * def __reduce_cython__(self):
2019  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
2020  * def __setstate_cython__(self, __pyx_state):
2021  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2022  */
2023   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
2024   __Pyx_GOTREF(__pyx_t_1);
2025   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2026   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2027   __PYX_ERR(1, 2, __pyx_L1_error)
2028 
2029   /* "(tree fragment)":1
2030  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
2031  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2032  * def __setstate_cython__(self, __pyx_state):
2033  */
2034 
2035   /* function exit code */
2036   __pyx_L1_error:;
2037   __Pyx_XDECREF(__pyx_t_1);
2038   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2039   __pyx_r = NULL;
2040   __Pyx_XGIVEREF(__pyx_r);
2041   __Pyx_RefNannyFinishContext();
2042   return __pyx_r;
2043 }
2044 
2045 /* "(tree fragment)":3
2046  * def __reduce_cython__(self):
2047  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2048  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
2049  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2050  */
2051 
2052 /* Python wrapper */
2053 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_13__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)2054 static PyObject *__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
2055   PyObject *__pyx_r = 0;
2056   __Pyx_RefNannyDeclarations
2057   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
2058   __pyx_r = __pyx_pf_2bx_9intervals_7cluster_11ClusterTree_12__setstate_cython__(((struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
2059 
2060   /* function exit code */
2061   __Pyx_RefNannyFinishContext();
2062   return __pyx_r;
2063 }
2064 
__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)2065 static PyObject *__pyx_pf_2bx_9intervals_7cluster_11ClusterTree_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
2066   PyObject *__pyx_r = NULL;
2067   __Pyx_RefNannyDeclarations
2068   PyObject *__pyx_t_1 = NULL;
2069   int __pyx_lineno = 0;
2070   const char *__pyx_filename = NULL;
2071   int __pyx_clineno = 0;
2072   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
2073 
2074   /* "(tree fragment)":4
2075  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2076  * def __setstate_cython__(self, __pyx_state):
2077  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
2078  */
2079   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
2080   __Pyx_GOTREF(__pyx_t_1);
2081   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2082   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2083   __PYX_ERR(1, 4, __pyx_L1_error)
2084 
2085   /* "(tree fragment)":3
2086  * def __reduce_cython__(self):
2087  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2088  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
2089  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2090  */
2091 
2092   /* function exit code */
2093   __pyx_L1_error:;
2094   __Pyx_XDECREF(__pyx_t_1);
2095   __Pyx_AddTraceback("bx.intervals.cluster.ClusterTree.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2096   __pyx_r = NULL;
2097   __Pyx_XGIVEREF(__pyx_r);
2098   __Pyx_RefNannyFinishContext();
2099   return __pyx_r;
2100 }
2101 
__pyx_tp_new_2bx_9intervals_7cluster_ClusterTree(PyTypeObject * t,PyObject * a,PyObject * k)2102 static PyObject *__pyx_tp_new_2bx_9intervals_7cluster_ClusterTree(PyTypeObject *t, PyObject *a, PyObject *k) {
2103   PyObject *o;
2104   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
2105     o = (*t->tp_alloc)(t, 0);
2106   } else {
2107     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
2108   }
2109   if (unlikely(!o)) return 0;
2110   if (unlikely(__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_1__cinit__(o, a, k) < 0)) goto bad;
2111   return o;
2112   bad:
2113   Py_DECREF(o); o = 0;
2114   return NULL;
2115 }
2116 
__pyx_tp_dealloc_2bx_9intervals_7cluster_ClusterTree(PyObject * o)2117 static void __pyx_tp_dealloc_2bx_9intervals_7cluster_ClusterTree(PyObject *o) {
2118   #if CYTHON_USE_TP_FINALIZE
2119   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
2120     if (PyObject_CallFinalizerFromDealloc(o)) return;
2121   }
2122   #endif
2123   {
2124     PyObject *etype, *eval, *etb;
2125     PyErr_Fetch(&etype, &eval, &etb);
2126     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
2127     __pyx_pw_2bx_9intervals_7cluster_11ClusterTree_3__dealloc__(o);
2128     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
2129     PyErr_Restore(etype, eval, etb);
2130   }
2131   (*Py_TYPE(o)->tp_free)(o);
2132 }
2133 
2134 static PyMethodDef __pyx_methods_2bx_9intervals_7cluster_ClusterTree[] = {
2135   {"insert", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_5insert, METH_VARARGS|METH_KEYWORDS, __pyx_doc_2bx_9intervals_7cluster_11ClusterTree_4insert},
2136   {"getregions", (PyCFunction)__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_7getregions, METH_NOARGS, __pyx_doc_2bx_9intervals_7cluster_11ClusterTree_6getregions},
2137   {"getlines", (PyCFunction)__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_9getlines, METH_NOARGS, __pyx_doc_2bx_9intervals_7cluster_11ClusterTree_8getlines},
2138   {"__reduce_cython__", (PyCFunction)__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_11__reduce_cython__, METH_NOARGS, 0},
2139   {"__setstate_cython__", (PyCFunction)__pyx_pw_2bx_9intervals_7cluster_11ClusterTree_13__setstate_cython__, METH_O, 0},
2140   {0, 0, 0, 0}
2141 };
2142 
2143 static PyTypeObject __pyx_type_2bx_9intervals_7cluster_ClusterTree = {
2144   PyVarObject_HEAD_INIT(0, 0)
2145   "bx.intervals.cluster.ClusterTree", /*tp_name*/
2146   sizeof(struct __pyx_obj_2bx_9intervals_7cluster_ClusterTree), /*tp_basicsize*/
2147   0, /*tp_itemsize*/
2148   __pyx_tp_dealloc_2bx_9intervals_7cluster_ClusterTree, /*tp_dealloc*/
2149   #if PY_VERSION_HEX < 0x030800b4
2150   0, /*tp_print*/
2151   #endif
2152   #if PY_VERSION_HEX >= 0x030800b4
2153   0, /*tp_vectorcall_offset*/
2154   #endif
2155   0, /*tp_getattr*/
2156   0, /*tp_setattr*/
2157   #if PY_MAJOR_VERSION < 3
2158   0, /*tp_compare*/
2159   #endif
2160   #if PY_MAJOR_VERSION >= 3
2161   0, /*tp_as_async*/
2162   #endif
2163   0, /*tp_repr*/
2164   0, /*tp_as_number*/
2165   0, /*tp_as_sequence*/
2166   0, /*tp_as_mapping*/
2167   0, /*tp_hash*/
2168   0, /*tp_call*/
2169   0, /*tp_str*/
2170   0, /*tp_getattro*/
2171   0, /*tp_setattro*/
2172   0, /*tp_as_buffer*/
2173   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
2174   0, /*tp_doc*/
2175   0, /*tp_traverse*/
2176   0, /*tp_clear*/
2177   0, /*tp_richcompare*/
2178   0, /*tp_weaklistoffset*/
2179   0, /*tp_iter*/
2180   0, /*tp_iternext*/
2181   __pyx_methods_2bx_9intervals_7cluster_ClusterTree, /*tp_methods*/
2182   0, /*tp_members*/
2183   0, /*tp_getset*/
2184   0, /*tp_base*/
2185   0, /*tp_dict*/
2186   0, /*tp_descr_get*/
2187   0, /*tp_descr_set*/
2188   0, /*tp_dictoffset*/
2189   0, /*tp_init*/
2190   0, /*tp_alloc*/
2191   __pyx_tp_new_2bx_9intervals_7cluster_ClusterTree, /*tp_new*/
2192   0, /*tp_free*/
2193   0, /*tp_is_gc*/
2194   0, /*tp_bases*/
2195   0, /*tp_mro*/
2196   0, /*tp_cache*/
2197   0, /*tp_subclasses*/
2198   0, /*tp_weaklist*/
2199   0, /*tp_del*/
2200   0, /*tp_version_tag*/
2201   #if PY_VERSION_HEX >= 0x030400a1
2202   0, /*tp_finalize*/
2203   #endif
2204   #if PY_VERSION_HEX >= 0x030800b1
2205   0, /*tp_vectorcall*/
2206   #endif
2207   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2208   0, /*tp_print*/
2209   #endif
2210   #if PY_VERSION_HEX >= 0x030B00A2
2211   0, /*tp_inline_values_offset*/
2212   #endif
2213 };
2214 
2215 static PyMethodDef __pyx_methods[] = {
2216   {0, 0, 0, 0}
2217 };
2218 
2219 #if PY_MAJOR_VERSION >= 3
2220 #if CYTHON_PEP489_MULTI_PHASE_INIT
2221 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
2222 static int __pyx_pymod_exec_cluster(PyObject* module); /*proto*/
2223 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
2224   {Py_mod_create, (void*)__pyx_pymod_create},
2225   {Py_mod_exec, (void*)__pyx_pymod_exec_cluster},
2226   {0, NULL}
2227 };
2228 #endif
2229 
2230 static struct PyModuleDef __pyx_moduledef = {
2231     PyModuleDef_HEAD_INIT,
2232     "cluster",
2233     __pyx_k_Kanwei_Li_2009_Inspired_by_prev, /* m_doc */
2234   #if CYTHON_PEP489_MULTI_PHASE_INIT
2235     0, /* m_size */
2236   #else
2237     -1, /* m_size */
2238   #endif
2239     __pyx_methods /* m_methods */,
2240   #if CYTHON_PEP489_MULTI_PHASE_INIT
2241     __pyx_moduledef_slots, /* m_slots */
2242   #else
2243     NULL, /* m_reload */
2244   #endif
2245     NULL, /* m_traverse */
2246     NULL, /* m_clear */
2247     NULL /* m_free */
2248 };
2249 #endif
2250 #ifndef CYTHON_SMALL_CODE
2251 #if defined(__clang__)
2252     #define CYTHON_SMALL_CODE
2253 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
2254     #define CYTHON_SMALL_CODE __attribute__((cold))
2255 #else
2256     #define CYTHON_SMALL_CODE
2257 #endif
2258 #endif
2259 
2260 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2261   {&__pyx_n_s_ClusterTree, __pyx_k_ClusterTree, sizeof(__pyx_k_ClusterTree), 0, 0, 1, 1},
2262   {&__pyx_kp_s_Interval_start_must_be_before_en, __pyx_k_Interval_start_must_be_before_en, sizeof(__pyx_k_Interval_start_must_be_before_en), 0, 0, 1, 0},
2263   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
2264   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
2265   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2266   {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
2267   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
2268   {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
2269   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2270   {&__pyx_n_s_mincols, __pyx_k_mincols, sizeof(__pyx_k_mincols), 0, 0, 1, 1},
2271   {&__pyx_n_s_minregions, __pyx_k_minregions, sizeof(__pyx_k_minregions), 0, 0, 1, 1},
2272   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
2273   {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
2274   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
2275   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
2276   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
2277   {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
2278   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
2279   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
2280   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2281   {0, 0, 0, 0, 0, 0, 0}
2282 };
__Pyx_InitCachedBuiltins(void)2283 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
2284   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 72, __pyx_L1_error)
2285   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
2286   return 0;
2287   __pyx_L1_error:;
2288   return -1;
2289 }
2290 
__Pyx_InitCachedConstants(void)2291 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
2292   __Pyx_RefNannyDeclarations
2293   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2294 
2295   /* "bx/intervals/cluster.pyx":72
2296  *     def insert(self, s, e, id):
2297  *         ''' Insert an interval with start, end, id as parameters'''
2298  *         if s > e: raise ValueError("Interval start must be before end")             # <<<<<<<<<<<<<<
2299  *         self.tree.root = clusternode_insert(self.tree, self.tree.root, s, e, id)
2300  *
2301  */
2302   __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Interval_start_must_be_before_en); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 72, __pyx_L1_error)
2303   __Pyx_GOTREF(__pyx_tuple_);
2304   __Pyx_GIVEREF(__pyx_tuple_);
2305 
2306   /* "(tree fragment)":2
2307  * def __reduce_cython__(self):
2308  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
2309  * def __setstate_cython__(self, __pyx_state):
2310  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2311  */
2312   __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 2, __pyx_L1_error)
2313   __Pyx_GOTREF(__pyx_tuple__2);
2314   __Pyx_GIVEREF(__pyx_tuple__2);
2315 
2316   /* "(tree fragment)":4
2317  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2318  * def __setstate_cython__(self, __pyx_state):
2319  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
2320  */
2321   __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 4, __pyx_L1_error)
2322   __Pyx_GOTREF(__pyx_tuple__3);
2323   __Pyx_GIVEREF(__pyx_tuple__3);
2324   __Pyx_RefNannyFinishContext();
2325   return 0;
2326   __pyx_L1_error:;
2327   __Pyx_RefNannyFinishContext();
2328   return -1;
2329 }
2330 
__Pyx_InitGlobals(void)2331 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
2332   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2333   return 0;
2334   __pyx_L1_error:;
2335   return -1;
2336 }
2337 
2338 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
2339 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
2340 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
2341 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
2342 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
2343 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
2344 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
2345 
__Pyx_modinit_global_init_code(void)2346 static int __Pyx_modinit_global_init_code(void) {
2347   __Pyx_RefNannyDeclarations
2348   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
2349   /*--- Global init code ---*/
2350   __Pyx_RefNannyFinishContext();
2351   return 0;
2352 }
2353 
__Pyx_modinit_variable_export_code(void)2354 static int __Pyx_modinit_variable_export_code(void) {
2355   __Pyx_RefNannyDeclarations
2356   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
2357   /*--- Variable export code ---*/
2358   __Pyx_RefNannyFinishContext();
2359   return 0;
2360 }
2361 
__Pyx_modinit_function_export_code(void)2362 static int __Pyx_modinit_function_export_code(void) {
2363   __Pyx_RefNannyDeclarations
2364   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
2365   /*--- Function export code ---*/
2366   __Pyx_RefNannyFinishContext();
2367   return 0;
2368 }
2369 
__Pyx_modinit_type_init_code(void)2370 static int __Pyx_modinit_type_init_code(void) {
2371   __Pyx_RefNannyDeclarations
2372   int __pyx_lineno = 0;
2373   const char *__pyx_filename = NULL;
2374   int __pyx_clineno = 0;
2375   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
2376   /*--- Type init code ---*/
2377   if (PyType_Ready(&__pyx_type_2bx_9intervals_7cluster_ClusterTree) < 0) __PYX_ERR(0, 57, __pyx_L1_error)
2378   #if PY_VERSION_HEX < 0x030800B1
2379   __pyx_type_2bx_9intervals_7cluster_ClusterTree.tp_print = 0;
2380   #endif
2381   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_2bx_9intervals_7cluster_ClusterTree.tp_dictoffset && __pyx_type_2bx_9intervals_7cluster_ClusterTree.tp_getattro == PyObject_GenericGetAttr)) {
2382     __pyx_type_2bx_9intervals_7cluster_ClusterTree.tp_getattro = __Pyx_PyObject_GenericGetAttr;
2383   }
2384   if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ClusterTree, (PyObject *)&__pyx_type_2bx_9intervals_7cluster_ClusterTree) < 0) __PYX_ERR(0, 57, __pyx_L1_error)
2385   if (__Pyx_setup_reduce((PyObject*)&__pyx_type_2bx_9intervals_7cluster_ClusterTree) < 0) __PYX_ERR(0, 57, __pyx_L1_error)
2386   __pyx_ptype_2bx_9intervals_7cluster_ClusterTree = &__pyx_type_2bx_9intervals_7cluster_ClusterTree;
2387   __Pyx_RefNannyFinishContext();
2388   return 0;
2389   __pyx_L1_error:;
2390   __Pyx_RefNannyFinishContext();
2391   return -1;
2392 }
2393 
__Pyx_modinit_type_import_code(void)2394 static int __Pyx_modinit_type_import_code(void) {
2395   __Pyx_RefNannyDeclarations
2396   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
2397   /*--- Type import code ---*/
2398   __Pyx_RefNannyFinishContext();
2399   return 0;
2400 }
2401 
__Pyx_modinit_variable_import_code(void)2402 static int __Pyx_modinit_variable_import_code(void) {
2403   __Pyx_RefNannyDeclarations
2404   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
2405   /*--- Variable import code ---*/
2406   __Pyx_RefNannyFinishContext();
2407   return 0;
2408 }
2409 
__Pyx_modinit_function_import_code(void)2410 static int __Pyx_modinit_function_import_code(void) {
2411   __Pyx_RefNannyDeclarations
2412   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
2413   /*--- Function import code ---*/
2414   __Pyx_RefNannyFinishContext();
2415   return 0;
2416 }
2417 
2418 
2419 #ifndef CYTHON_NO_PYINIT_EXPORT
2420 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
2421 #elif PY_MAJOR_VERSION < 3
2422 #ifdef __cplusplus
2423 #define __Pyx_PyMODINIT_FUNC extern "C" void
2424 #else
2425 #define __Pyx_PyMODINIT_FUNC void
2426 #endif
2427 #else
2428 #ifdef __cplusplus
2429 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
2430 #else
2431 #define __Pyx_PyMODINIT_FUNC PyObject *
2432 #endif
2433 #endif
2434 
2435 
2436 #if PY_MAJOR_VERSION < 3
2437 __Pyx_PyMODINIT_FUNC initcluster(void) CYTHON_SMALL_CODE; /*proto*/
initcluster(void)2438 __Pyx_PyMODINIT_FUNC initcluster(void)
2439 #else
2440 __Pyx_PyMODINIT_FUNC PyInit_cluster(void) CYTHON_SMALL_CODE; /*proto*/
2441 __Pyx_PyMODINIT_FUNC PyInit_cluster(void)
2442 #if CYTHON_PEP489_MULTI_PHASE_INIT
2443 {
2444   return PyModuleDef_Init(&__pyx_moduledef);
2445 }
2446 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
2447     #if PY_VERSION_HEX >= 0x030700A1
2448     static PY_INT64_T main_interpreter_id = -1;
2449     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
2450     if (main_interpreter_id == -1) {
2451         main_interpreter_id = current_id;
2452         return (unlikely(current_id == -1)) ? -1 : 0;
2453     } else if (unlikely(main_interpreter_id != current_id))
2454     #else
2455     static PyInterpreterState *main_interpreter = NULL;
2456     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
2457     if (!main_interpreter) {
2458         main_interpreter = current_interpreter;
2459     } else if (unlikely(main_interpreter != current_interpreter))
2460     #endif
2461     {
2462         PyErr_SetString(
2463             PyExc_ImportError,
2464             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
2465         return -1;
2466     }
2467     return 0;
2468 }
2469 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
2470     PyObject *value = PyObject_GetAttrString(spec, from_name);
2471     int result = 0;
2472     if (likely(value)) {
2473         if (allow_none || value != Py_None) {
2474             result = PyDict_SetItemString(moddict, to_name, value);
2475         }
2476         Py_DECREF(value);
2477     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
2478         PyErr_Clear();
2479     } else {
2480         result = -1;
2481     }
2482     return result;
2483 }
2484 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
2485     PyObject *module = NULL, *moddict, *modname;
2486     if (__Pyx_check_single_interpreter())
2487         return NULL;
2488     if (__pyx_m)
2489         return __Pyx_NewRef(__pyx_m);
2490     modname = PyObject_GetAttrString(spec, "name");
2491     if (unlikely(!modname)) goto bad;
2492     module = PyModule_NewObject(modname);
2493     Py_DECREF(modname);
2494     if (unlikely(!module)) goto bad;
2495     moddict = PyModule_GetDict(module);
2496     if (unlikely(!moddict)) goto bad;
2497     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
2498     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
2499     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
2500     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
2501     return module;
2502 bad:
2503     Py_XDECREF(module);
2504     return NULL;
2505 }
2506 
2507 
2508 static CYTHON_SMALL_CODE int __pyx_pymod_exec_cluster(PyObject *__pyx_pyinit_module)
2509 #endif
2510 #endif
2511 {
2512   PyObject *__pyx_t_1 = NULL;
2513   int __pyx_lineno = 0;
2514   const char *__pyx_filename = NULL;
2515   int __pyx_clineno = 0;
2516   __Pyx_RefNannyDeclarations
2517   #if CYTHON_PEP489_MULTI_PHASE_INIT
2518   if (__pyx_m) {
2519     if (__pyx_m == __pyx_pyinit_module) return 0;
2520     PyErr_SetString(PyExc_RuntimeError, "Module 'cluster' has already been imported. Re-initialisation is not supported.");
2521     return -1;
2522   }
2523   #elif PY_MAJOR_VERSION >= 3
2524   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
2525   #endif
2526   #if CYTHON_REFNANNY
2527 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2528 if (!__Pyx_RefNanny) {
2529   PyErr_Clear();
2530   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2531   if (!__Pyx_RefNanny)
2532       Py_FatalError("failed to import 'refnanny' module");
2533 }
2534 #endif
2535   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cluster(void)", 0);
2536   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2537   #ifdef __Pxy_PyFrame_Initialize_Offsets
2538   __Pxy_PyFrame_Initialize_Offsets();
2539   #endif
2540   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
2541   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
2542   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
2543   #ifdef __Pyx_CyFunction_USED
2544   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2545   #endif
2546   #ifdef __Pyx_FusedFunction_USED
2547   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2548   #endif
2549   #ifdef __Pyx_Coroutine_USED
2550   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2551   #endif
2552   #ifdef __Pyx_Generator_USED
2553   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2554   #endif
2555   #ifdef __Pyx_AsyncGen_USED
2556   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2557   #endif
2558   #ifdef __Pyx_StopAsyncIteration_USED
2559   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2560   #endif
2561   /*--- Library function declarations ---*/
2562   /*--- Threads initialization code ---*/
2563   #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
2564   PyEval_InitThreads();
2565   #endif
2566   /*--- Module creation code ---*/
2567   #if CYTHON_PEP489_MULTI_PHASE_INIT
2568   __pyx_m = __pyx_pyinit_module;
2569   Py_INCREF(__pyx_m);
2570   #else
2571   #if PY_MAJOR_VERSION < 3
2572   __pyx_m = Py_InitModule4("cluster", __pyx_methods, __pyx_k_Kanwei_Li_2009_Inspired_by_prev, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
2573   #else
2574   __pyx_m = PyModule_Create(&__pyx_moduledef);
2575   #endif
2576   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
2577   #endif
2578   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
2579   Py_INCREF(__pyx_d);
2580   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
2581   Py_INCREF(__pyx_b);
2582   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
2583   Py_INCREF(__pyx_cython_runtime);
2584   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2585   /*--- Initialize various global constants etc. ---*/
2586   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2587   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
2588   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2589   #endif
2590   if (__pyx_module_is_main_bx__intervals__cluster) {
2591     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2592   }
2593   #if PY_MAJOR_VERSION >= 3
2594   {
2595     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
2596     if (!PyDict_GetItemString(modules, "bx.intervals.cluster")) {
2597       if (unlikely(PyDict_SetItemString(modules, "bx.intervals.cluster", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2598     }
2599   }
2600   #endif
2601   /*--- Builtin init code ---*/
2602   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2603   /*--- Constants init code ---*/
2604   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2605   /*--- Global type/function init code ---*/
2606   (void)__Pyx_modinit_global_init_code();
2607   (void)__Pyx_modinit_variable_export_code();
2608   (void)__Pyx_modinit_function_export_code();
2609   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2610   (void)__Pyx_modinit_type_import_code();
2611   (void)__Pyx_modinit_variable_import_code();
2612   (void)__Pyx_modinit_function_import_code();
2613   /*--- Execution code ---*/
2614   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
2615   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2616   #endif
2617 
2618   /* "bx/intervals/cluster.pyx":1
2619  * """             # <<<<<<<<<<<<<<
2620  * Kanwei Li, 2009
2621  * Inspired by previous ClusterTree
2622  */
2623   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
2624   __Pyx_GOTREF(__pyx_t_1);
2625   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2626   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2627 
2628   /*--- Wrapped vars code ---*/
2629 
2630   goto __pyx_L0;
2631   __pyx_L1_error:;
2632   __Pyx_XDECREF(__pyx_t_1);
2633   if (__pyx_m) {
2634     if (__pyx_d) {
2635       __Pyx_AddTraceback("init bx.intervals.cluster", __pyx_clineno, __pyx_lineno, __pyx_filename);
2636     }
2637     Py_CLEAR(__pyx_m);
2638   } else if (!PyErr_Occurred()) {
2639     PyErr_SetString(PyExc_ImportError, "init bx.intervals.cluster");
2640   }
2641   __pyx_L0:;
2642   __Pyx_RefNannyFinishContext();
2643   #if CYTHON_PEP489_MULTI_PHASE_INIT
2644   return (__pyx_m != NULL) ? 0 : -1;
2645   #elif PY_MAJOR_VERSION >= 3
2646   return __pyx_m;
2647   #else
2648   return;
2649   #endif
2650 }
2651 
2652 /* --- Runtime support code --- */
2653 /* Refnanny */
2654 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)2655 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2656     PyObject *m = NULL, *p = NULL;
2657     void *r = NULL;
2658     m = PyImport_ImportModule(modname);
2659     if (!m) goto end;
2660     p = PyObject_GetAttrString(m, "RefNannyAPI");
2661     if (!p) goto end;
2662     r = PyLong_AsVoidPtr(p);
2663 end:
2664     Py_XDECREF(p);
2665     Py_XDECREF(m);
2666     return (__Pyx_RefNannyAPIStruct *)r;
2667 }
2668 #endif
2669 
2670 /* PyObjectGetAttrStr */
2671 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)2672 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
2673     PyTypeObject* tp = Py_TYPE(obj);
2674     if (likely(tp->tp_getattro))
2675         return tp->tp_getattro(obj, attr_name);
2676 #if PY_MAJOR_VERSION < 3
2677     if (likely(tp->tp_getattr))
2678         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
2679 #endif
2680     return PyObject_GetAttr(obj, attr_name);
2681 }
2682 #endif
2683 
2684 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)2685 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2686     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2687     if (unlikely(!result)) {
2688         PyErr_Format(PyExc_NameError,
2689 #if PY_MAJOR_VERSION >= 3
2690             "name '%U' is not defined", name);
2691 #else
2692             "name '%.200s' is not defined", PyString_AS_STRING(name));
2693 #endif
2694     }
2695     return result;
2696 }
2697 
2698 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)2699 static void __Pyx_RaiseArgtupleInvalid(
2700     const char* func_name,
2701     int exact,
2702     Py_ssize_t num_min,
2703     Py_ssize_t num_max,
2704     Py_ssize_t num_found)
2705 {
2706     Py_ssize_t num_expected;
2707     const char *more_or_less;
2708     if (num_found < num_min) {
2709         num_expected = num_min;
2710         more_or_less = "at least";
2711     } else {
2712         num_expected = num_max;
2713         more_or_less = "at most";
2714     }
2715     if (exact) {
2716         more_or_less = "exactly";
2717     }
2718     PyErr_Format(PyExc_TypeError,
2719                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2720                  func_name, more_or_less, num_expected,
2721                  (num_expected == 1) ? "" : "s", num_found);
2722 }
2723 
2724 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)2725 static void __Pyx_RaiseDoubleKeywordsError(
2726     const char* func_name,
2727     PyObject* kw_name)
2728 {
2729     PyErr_Format(PyExc_TypeError,
2730         #if PY_MAJOR_VERSION >= 3
2731         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
2732         #else
2733         "%s() got multiple values for keyword argument '%s'", func_name,
2734         PyString_AsString(kw_name));
2735         #endif
2736 }
2737 
2738 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)2739 static int __Pyx_ParseOptionalKeywords(
2740     PyObject *kwds,
2741     PyObject **argnames[],
2742     PyObject *kwds2,
2743     PyObject *values[],
2744     Py_ssize_t num_pos_args,
2745     const char* function_name)
2746 {
2747     PyObject *key = 0, *value = 0;
2748     Py_ssize_t pos = 0;
2749     PyObject*** name;
2750     PyObject*** first_kw_arg = argnames + num_pos_args;
2751     while (PyDict_Next(kwds, &pos, &key, &value)) {
2752         name = first_kw_arg;
2753         while (*name && (**name != key)) name++;
2754         if (*name) {
2755             values[name-argnames] = value;
2756             continue;
2757         }
2758         name = first_kw_arg;
2759         #if PY_MAJOR_VERSION < 3
2760         if (likely(PyString_Check(key))) {
2761             while (*name) {
2762                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
2763                         && _PyString_Eq(**name, key)) {
2764                     values[name-argnames] = value;
2765                     break;
2766                 }
2767                 name++;
2768             }
2769             if (*name) continue;
2770             else {
2771                 PyObject*** argname = argnames;
2772                 while (argname != first_kw_arg) {
2773                     if ((**argname == key) || (
2774                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
2775                              && _PyString_Eq(**argname, key))) {
2776                         goto arg_passed_twice;
2777                     }
2778                     argname++;
2779                 }
2780             }
2781         } else
2782         #endif
2783         if (likely(PyUnicode_Check(key))) {
2784             while (*name) {
2785                 int cmp = (**name == key) ? 0 :
2786                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2787                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2788                 #endif
2789                     PyUnicode_Compare(**name, key);
2790                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2791                 if (cmp == 0) {
2792                     values[name-argnames] = value;
2793                     break;
2794                 }
2795                 name++;
2796             }
2797             if (*name) continue;
2798             else {
2799                 PyObject*** argname = argnames;
2800                 while (argname != first_kw_arg) {
2801                     int cmp = (**argname == key) ? 0 :
2802                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2803                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2804                     #endif
2805                         PyUnicode_Compare(**argname, key);
2806                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2807                     if (cmp == 0) goto arg_passed_twice;
2808                     argname++;
2809                 }
2810             }
2811         } else
2812             goto invalid_keyword_type;
2813         if (kwds2) {
2814             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
2815         } else {
2816             goto invalid_keyword;
2817         }
2818     }
2819     return 0;
2820 arg_passed_twice:
2821     __Pyx_RaiseDoubleKeywordsError(function_name, key);
2822     goto bad;
2823 invalid_keyword_type:
2824     PyErr_Format(PyExc_TypeError,
2825         "%.200s() keywords must be strings", function_name);
2826     goto bad;
2827 invalid_keyword:
2828     PyErr_Format(PyExc_TypeError,
2829     #if PY_MAJOR_VERSION < 3
2830         "%.200s() got an unexpected keyword argument '%.200s'",
2831         function_name, PyString_AsString(key));
2832     #else
2833         "%s() got an unexpected keyword argument '%U'",
2834         function_name, key);
2835     #endif
2836 bad:
2837     return -1;
2838 }
2839 
2840 /* PyObjectCall */
2841 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)2842 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
2843     PyObject *result;
2844     ternaryfunc call = Py_TYPE(func)->tp_call;
2845     if (unlikely(!call))
2846         return PyObject_Call(func, arg, kw);
2847     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2848         return NULL;
2849     result = (*call)(func, arg, kw);
2850     Py_LeaveRecursiveCall();
2851     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2852         PyErr_SetString(
2853             PyExc_SystemError,
2854             "NULL result without error in PyObject_Call");
2855     }
2856     return result;
2857 }
2858 #endif
2859 
2860 /* PyErrFetchRestore */
2861 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)2862 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
2863     PyObject *tmp_type, *tmp_value, *tmp_tb;
2864     tmp_type = tstate->curexc_type;
2865     tmp_value = tstate->curexc_value;
2866     tmp_tb = tstate->curexc_traceback;
2867     tstate->curexc_type = type;
2868     tstate->curexc_value = value;
2869     tstate->curexc_traceback = tb;
2870     Py_XDECREF(tmp_type);
2871     Py_XDECREF(tmp_value);
2872     Py_XDECREF(tmp_tb);
2873 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)2874 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
2875     *type = tstate->curexc_type;
2876     *value = tstate->curexc_value;
2877     *tb = tstate->curexc_traceback;
2878     tstate->curexc_type = 0;
2879     tstate->curexc_value = 0;
2880     tstate->curexc_traceback = 0;
2881 }
2882 #endif
2883 
2884 /* RaiseException */
2885 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)2886 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
2887                         CYTHON_UNUSED PyObject *cause) {
2888     __Pyx_PyThreadState_declare
2889     Py_XINCREF(type);
2890     if (!value || value == Py_None)
2891         value = NULL;
2892     else
2893         Py_INCREF(value);
2894     if (!tb || tb == Py_None)
2895         tb = NULL;
2896     else {
2897         Py_INCREF(tb);
2898         if (!PyTraceBack_Check(tb)) {
2899             PyErr_SetString(PyExc_TypeError,
2900                 "raise: arg 3 must be a traceback or None");
2901             goto raise_error;
2902         }
2903     }
2904     if (PyType_Check(type)) {
2905 #if CYTHON_COMPILING_IN_PYPY
2906         if (!value) {
2907             Py_INCREF(Py_None);
2908             value = Py_None;
2909         }
2910 #endif
2911         PyErr_NormalizeException(&type, &value, &tb);
2912     } else {
2913         if (value) {
2914             PyErr_SetString(PyExc_TypeError,
2915                 "instance exception may not have a separate value");
2916             goto raise_error;
2917         }
2918         value = type;
2919         type = (PyObject*) Py_TYPE(type);
2920         Py_INCREF(type);
2921         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
2922             PyErr_SetString(PyExc_TypeError,
2923                 "raise: exception class must be a subclass of BaseException");
2924             goto raise_error;
2925         }
2926     }
2927     __Pyx_PyThreadState_assign
2928     __Pyx_ErrRestore(type, value, tb);
2929     return;
2930 raise_error:
2931     Py_XDECREF(value);
2932     Py_XDECREF(type);
2933     Py_XDECREF(tb);
2934     return;
2935 }
2936 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)2937 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
2938     PyObject* owned_instance = NULL;
2939     if (tb == Py_None) {
2940         tb = 0;
2941     } else if (tb && !PyTraceBack_Check(tb)) {
2942         PyErr_SetString(PyExc_TypeError,
2943             "raise: arg 3 must be a traceback or None");
2944         goto bad;
2945     }
2946     if (value == Py_None)
2947         value = 0;
2948     if (PyExceptionInstance_Check(type)) {
2949         if (value) {
2950             PyErr_SetString(PyExc_TypeError,
2951                 "instance exception may not have a separate value");
2952             goto bad;
2953         }
2954         value = type;
2955         type = (PyObject*) Py_TYPE(value);
2956     } else if (PyExceptionClass_Check(type)) {
2957         PyObject *instance_class = NULL;
2958         if (value && PyExceptionInstance_Check(value)) {
2959             instance_class = (PyObject*) Py_TYPE(value);
2960             if (instance_class != type) {
2961                 int is_subclass = PyObject_IsSubclass(instance_class, type);
2962                 if (!is_subclass) {
2963                     instance_class = NULL;
2964                 } else if (unlikely(is_subclass == -1)) {
2965                     goto bad;
2966                 } else {
2967                     type = instance_class;
2968                 }
2969             }
2970         }
2971         if (!instance_class) {
2972             PyObject *args;
2973             if (!value)
2974                 args = PyTuple_New(0);
2975             else if (PyTuple_Check(value)) {
2976                 Py_INCREF(value);
2977                 args = value;
2978             } else
2979                 args = PyTuple_Pack(1, value);
2980             if (!args)
2981                 goto bad;
2982             owned_instance = PyObject_Call(type, args, NULL);
2983             Py_DECREF(args);
2984             if (!owned_instance)
2985                 goto bad;
2986             value = owned_instance;
2987             if (!PyExceptionInstance_Check(value)) {
2988                 PyErr_Format(PyExc_TypeError,
2989                              "calling %R should have returned an instance of "
2990                              "BaseException, not %R",
2991                              type, Py_TYPE(value));
2992                 goto bad;
2993             }
2994         }
2995     } else {
2996         PyErr_SetString(PyExc_TypeError,
2997             "raise: exception class must be a subclass of BaseException");
2998         goto bad;
2999     }
3000     if (cause) {
3001         PyObject *fixed_cause;
3002         if (cause == Py_None) {
3003             fixed_cause = NULL;
3004         } else if (PyExceptionClass_Check(cause)) {
3005             fixed_cause = PyObject_CallObject(cause, NULL);
3006             if (fixed_cause == NULL)
3007                 goto bad;
3008         } else if (PyExceptionInstance_Check(cause)) {
3009             fixed_cause = cause;
3010             Py_INCREF(fixed_cause);
3011         } else {
3012             PyErr_SetString(PyExc_TypeError,
3013                             "exception causes must derive from "
3014                             "BaseException");
3015             goto bad;
3016         }
3017         PyException_SetCause(value, fixed_cause);
3018     }
3019     PyErr_SetObject(type, value);
3020     if (tb) {
3021 #if CYTHON_COMPILING_IN_PYPY
3022         PyObject *tmp_type, *tmp_value, *tmp_tb;
3023         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
3024         Py_INCREF(tb);
3025         PyErr_Restore(tmp_type, tmp_value, tb);
3026         Py_XDECREF(tmp_tb);
3027 #else
3028         PyThreadState *tstate = __Pyx_PyThreadState_Current;
3029         PyObject* tmp_tb = tstate->curexc_traceback;
3030         if (tb != tmp_tb) {
3031             Py_INCREF(tb);
3032             tstate->curexc_traceback = tb;
3033             Py_XDECREF(tmp_tb);
3034         }
3035 #endif
3036     }
3037 bad:
3038     Py_XDECREF(owned_instance);
3039     return;
3040 }
3041 #endif
3042 
3043 /* PyObject_GenericGetAttrNoDict */
3044 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)3045 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
3046     PyErr_Format(PyExc_AttributeError,
3047 #if PY_MAJOR_VERSION >= 3
3048                  "'%.50s' object has no attribute '%U'",
3049                  tp->tp_name, attr_name);
3050 #else
3051                  "'%.50s' object has no attribute '%.400s'",
3052                  tp->tp_name, PyString_AS_STRING(attr_name));
3053 #endif
3054     return NULL;
3055 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)3056 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
3057     PyObject *descr;
3058     PyTypeObject *tp = Py_TYPE(obj);
3059     if (unlikely(!PyString_Check(attr_name))) {
3060         return PyObject_GenericGetAttr(obj, attr_name);
3061     }
3062     assert(!tp->tp_dictoffset);
3063     descr = _PyType_Lookup(tp, attr_name);
3064     if (unlikely(!descr)) {
3065         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
3066     }
3067     Py_INCREF(descr);
3068     #if PY_MAJOR_VERSION < 3
3069     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
3070     #endif
3071     {
3072         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
3073         if (unlikely(f)) {
3074             PyObject *res = f(descr, obj, (PyObject *)tp);
3075             Py_DECREF(descr);
3076             return res;
3077         }
3078     }
3079     return descr;
3080 }
3081 #endif
3082 
3083 /* PyObject_GenericGetAttr */
3084 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)3085 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
3086     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
3087         return PyObject_GenericGetAttr(obj, attr_name);
3088     }
3089     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
3090 }
3091 #endif
3092 
3093 /* PyErrExceptionMatches */
3094 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)3095 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3096     Py_ssize_t i, n;
3097     n = PyTuple_GET_SIZE(tuple);
3098 #if PY_MAJOR_VERSION >= 3
3099     for (i=0; i<n; i++) {
3100         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3101     }
3102 #endif
3103     for (i=0; i<n; i++) {
3104         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
3105     }
3106     return 0;
3107 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)3108 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
3109     PyObject *exc_type = tstate->curexc_type;
3110     if (exc_type == err) return 1;
3111     if (unlikely(!exc_type)) return 0;
3112     if (unlikely(PyTuple_Check(err)))
3113         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
3114     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
3115 }
3116 #endif
3117 
3118 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)3119 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
3120     __Pyx_PyThreadState_declare
3121     __Pyx_PyThreadState_assign
3122     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
3123         __Pyx_PyErr_Clear();
3124 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)3125 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
3126     PyObject *result;
3127 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
3128     PyTypeObject* tp = Py_TYPE(obj);
3129     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
3130         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
3131     }
3132 #endif
3133     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
3134     if (unlikely(!result)) {
3135         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
3136     }
3137     return result;
3138 }
3139 
3140 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)3141 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
3142   int ret;
3143   PyObject *name_attr;
3144   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
3145   if (likely(name_attr)) {
3146       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
3147   } else {
3148       ret = -1;
3149   }
3150   if (unlikely(ret < 0)) {
3151       PyErr_Clear();
3152       ret = 0;
3153   }
3154   Py_XDECREF(name_attr);
3155   return ret;
3156 }
__Pyx_setup_reduce(PyObject * type_obj)3157 static int __Pyx_setup_reduce(PyObject* type_obj) {
3158     int ret = 0;
3159     PyObject *object_reduce = NULL;
3160     PyObject *object_reduce_ex = NULL;
3161     PyObject *reduce = NULL;
3162     PyObject *reduce_ex = NULL;
3163     PyObject *reduce_cython = NULL;
3164     PyObject *setstate = NULL;
3165     PyObject *setstate_cython = NULL;
3166 #if CYTHON_USE_PYTYPE_LOOKUP
3167     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
3168 #else
3169     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
3170 #endif
3171 #if CYTHON_USE_PYTYPE_LOOKUP
3172     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
3173 #else
3174     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
3175 #endif
3176     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
3177     if (reduce_ex == object_reduce_ex) {
3178 #if CYTHON_USE_PYTYPE_LOOKUP
3179         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
3180 #else
3181         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
3182 #endif
3183         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
3184         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
3185             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
3186             if (likely(reduce_cython)) {
3187                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3188                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3189             } else if (reduce == object_reduce || PyErr_Occurred()) {
3190                 goto __PYX_BAD;
3191             }
3192             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
3193             if (!setstate) PyErr_Clear();
3194             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
3195                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
3196                 if (likely(setstate_cython)) {
3197                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3198                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3199                 } else if (!setstate || PyErr_Occurred()) {
3200                     goto __PYX_BAD;
3201                 }
3202             }
3203             PyType_Modified((PyTypeObject*)type_obj);
3204         }
3205     }
3206     goto __PYX_GOOD;
3207 __PYX_BAD:
3208     if (!PyErr_Occurred())
3209         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
3210     ret = -1;
3211 __PYX_GOOD:
3212 #if !CYTHON_USE_PYTYPE_LOOKUP
3213     Py_XDECREF(object_reduce);
3214     Py_XDECREF(object_reduce_ex);
3215 #endif
3216     Py_XDECREF(reduce);
3217     Py_XDECREF(reduce_ex);
3218     Py_XDECREF(reduce_cython);
3219     Py_XDECREF(setstate);
3220     Py_XDECREF(setstate_cython);
3221     return ret;
3222 }
3223 
3224 /* PyDictVersioning */
3225 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)3226 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
3227     PyObject *dict = Py_TYPE(obj)->tp_dict;
3228     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
3229 }
__Pyx_get_object_dict_version(PyObject * obj)3230 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
3231     PyObject **dictptr = NULL;
3232     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
3233     if (offset) {
3234 #if CYTHON_COMPILING_IN_CPYTHON
3235         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
3236 #else
3237         dictptr = _PyObject_GetDictPtr(obj);
3238 #endif
3239     }
3240     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
3241 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)3242 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
3243     PyObject *dict = Py_TYPE(obj)->tp_dict;
3244     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
3245         return 0;
3246     return obj_dict_version == __Pyx_get_object_dict_version(obj);
3247 }
3248 #endif
3249 
3250 /* CLineInTraceback */
3251 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)3252 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
3253     PyObject *use_cline;
3254     PyObject *ptype, *pvalue, *ptraceback;
3255 #if CYTHON_COMPILING_IN_CPYTHON
3256     PyObject **cython_runtime_dict;
3257 #endif
3258     if (unlikely(!__pyx_cython_runtime)) {
3259         return c_line;
3260     }
3261     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
3262 #if CYTHON_COMPILING_IN_CPYTHON
3263     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
3264     if (likely(cython_runtime_dict)) {
3265         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
3266             use_cline, *cython_runtime_dict,
3267             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
3268     } else
3269 #endif
3270     {
3271       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
3272       if (use_cline_obj) {
3273         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
3274         Py_DECREF(use_cline_obj);
3275       } else {
3276         PyErr_Clear();
3277         use_cline = NULL;
3278       }
3279     }
3280     if (!use_cline) {
3281         c_line = 0;
3282         (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
3283     }
3284     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
3285         c_line = 0;
3286     }
3287     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
3288     return c_line;
3289 }
3290 #endif
3291 
3292 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)3293 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3294     int start = 0, mid = 0, end = count - 1;
3295     if (end >= 0 && code_line > entries[end].code_line) {
3296         return count;
3297     }
3298     while (start < end) {
3299         mid = start + (end - start) / 2;
3300         if (code_line < entries[mid].code_line) {
3301             end = mid;
3302         } else if (code_line > entries[mid].code_line) {
3303              start = mid + 1;
3304         } else {
3305             return mid;
3306         }
3307     }
3308     if (code_line <= entries[mid].code_line) {
3309         return mid;
3310     } else {
3311         return mid + 1;
3312     }
3313 }
__pyx_find_code_object(int code_line)3314 static PyCodeObject *__pyx_find_code_object(int code_line) {
3315     PyCodeObject* code_object;
3316     int pos;
3317     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
3318         return NULL;
3319     }
3320     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3321     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
3322         return NULL;
3323     }
3324     code_object = __pyx_code_cache.entries[pos].code_object;
3325     Py_INCREF(code_object);
3326     return code_object;
3327 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)3328 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
3329     int pos, i;
3330     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
3331     if (unlikely(!code_line)) {
3332         return;
3333     }
3334     if (unlikely(!entries)) {
3335         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
3336         if (likely(entries)) {
3337             __pyx_code_cache.entries = entries;
3338             __pyx_code_cache.max_count = 64;
3339             __pyx_code_cache.count = 1;
3340             entries[0].code_line = code_line;
3341             entries[0].code_object = code_object;
3342             Py_INCREF(code_object);
3343         }
3344         return;
3345     }
3346     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3347     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
3348         PyCodeObject* tmp = entries[pos].code_object;
3349         entries[pos].code_object = code_object;
3350         Py_DECREF(tmp);
3351         return;
3352     }
3353     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
3354         int new_max = __pyx_code_cache.max_count + 64;
3355         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
3356             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
3357         if (unlikely(!entries)) {
3358             return;
3359         }
3360         __pyx_code_cache.entries = entries;
3361         __pyx_code_cache.max_count = new_max;
3362     }
3363     for (i=__pyx_code_cache.count; i>pos; i--) {
3364         entries[i] = entries[i-1];
3365     }
3366     entries[pos].code_line = code_line;
3367     entries[pos].code_object = code_object;
3368     __pyx_code_cache.count++;
3369     Py_INCREF(code_object);
3370 }
3371 
3372 /* AddTraceback */
3373 #include "compile.h"
3374 #include "frameobject.h"
3375 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)3376 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
3377             const char *funcname, int c_line,
3378             int py_line, const char *filename) {
3379     PyCodeObject *py_code = NULL;
3380     PyObject *py_funcname = NULL;
3381     #if PY_MAJOR_VERSION < 3
3382     PyObject *py_srcfile = NULL;
3383     py_srcfile = PyString_FromString(filename);
3384     if (!py_srcfile) goto bad;
3385     #endif
3386     if (c_line) {
3387         #if PY_MAJOR_VERSION < 3
3388         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3389         if (!py_funcname) goto bad;
3390         #else
3391         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3392         if (!py_funcname) goto bad;
3393         funcname = PyUnicode_AsUTF8(py_funcname);
3394         if (!funcname) goto bad;
3395         #endif
3396     }
3397     else {
3398         #if PY_MAJOR_VERSION < 3
3399         py_funcname = PyString_FromString(funcname);
3400         if (!py_funcname) goto bad;
3401         #endif
3402     }
3403     #if PY_MAJOR_VERSION < 3
3404     py_code = __Pyx_PyCode_New(
3405         0,
3406         0,
3407         0,
3408         0,
3409         0,
3410         __pyx_empty_bytes, /*PyObject *code,*/
3411         __pyx_empty_tuple, /*PyObject *consts,*/
3412         __pyx_empty_tuple, /*PyObject *names,*/
3413         __pyx_empty_tuple, /*PyObject *varnames,*/
3414         __pyx_empty_tuple, /*PyObject *freevars,*/
3415         __pyx_empty_tuple, /*PyObject *cellvars,*/
3416         py_srcfile,   /*PyObject *filename,*/
3417         py_funcname,  /*PyObject *name,*/
3418         py_line,
3419         __pyx_empty_bytes  /*PyObject *lnotab*/
3420     );
3421     Py_DECREF(py_srcfile);
3422     #else
3423     py_code = PyCode_NewEmpty(filename, funcname, py_line);
3424     #endif
3425     Py_XDECREF(py_funcname);  // XDECREF since it's only set on Py3 if cline
3426     return py_code;
3427 bad:
3428     Py_XDECREF(py_funcname);
3429     #if PY_MAJOR_VERSION < 3
3430     Py_XDECREF(py_srcfile);
3431     #endif
3432     return NULL;
3433 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)3434 static void __Pyx_AddTraceback(const char *funcname, int c_line,
3435                                int py_line, const char *filename) {
3436     PyCodeObject *py_code = 0;
3437     PyFrameObject *py_frame = 0;
3438     PyThreadState *tstate = __Pyx_PyThreadState_Current;
3439     if (c_line) {
3440         c_line = __Pyx_CLineForTraceback(tstate, c_line);
3441     }
3442     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
3443     if (!py_code) {
3444         py_code = __Pyx_CreateCodeObjectForTraceback(
3445             funcname, c_line, py_line, filename);
3446         if (!py_code) goto bad;
3447         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
3448     }
3449     py_frame = PyFrame_New(
3450         tstate,            /*PyThreadState *tstate,*/
3451         py_code,           /*PyCodeObject *code,*/
3452         __pyx_d,    /*PyObject *globals,*/
3453         0                  /*PyObject *locals*/
3454     );
3455     if (!py_frame) goto bad;
3456     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
3457     PyTraceBack_Here(py_frame);
3458 bad:
3459     Py_XDECREF(py_code);
3460     Py_XDECREF(py_frame);
3461 }
3462 
3463 /* CIntFromPyVerify */
3464 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
3465     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
3466 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
3467     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
3468 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
3469     {\
3470         func_type value = func_value;\
3471         if (sizeof(target_type) < sizeof(func_type)) {\
3472             if (unlikely(value != (func_type) (target_type) value)) {\
3473                 func_type zero = 0;\
3474                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
3475                     return (target_type) -1;\
3476                 if (is_unsigned && unlikely(value < zero))\
3477                     goto raise_neg_overflow;\
3478                 else\
3479                     goto raise_overflow;\
3480             }\
3481         }\
3482         return (target_type) value;\
3483     }
3484 
3485 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)3486 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
3487 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3488 #pragma GCC diagnostic push
3489 #pragma GCC diagnostic ignored "-Wconversion"
3490 #endif
3491     const int neg_one = (int) -1, const_zero = (int) 0;
3492 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3493 #pragma GCC diagnostic pop
3494 #endif
3495     const int is_unsigned = neg_one > const_zero;
3496 #if PY_MAJOR_VERSION < 3
3497     if (likely(PyInt_Check(x))) {
3498         if (sizeof(int) < sizeof(long)) {
3499             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3500         } else {
3501             long val = PyInt_AS_LONG(x);
3502             if (is_unsigned && unlikely(val < 0)) {
3503                 goto raise_neg_overflow;
3504             }
3505             return (int) val;
3506         }
3507     } else
3508 #endif
3509     if (likely(PyLong_Check(x))) {
3510         if (is_unsigned) {
3511 #if CYTHON_USE_PYLONG_INTERNALS
3512             const digit* digits = ((PyLongObject*)x)->ob_digit;
3513             switch (Py_SIZE(x)) {
3514                 case  0: return (int) 0;
3515                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
3516                 case 2:
3517                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3518                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3519                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3520                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
3521                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3522                         }
3523                     }
3524                     break;
3525                 case 3:
3526                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3527                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3528                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3529                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
3530                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3531                         }
3532                     }
3533                     break;
3534                 case 4:
3535                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3536                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3537                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3538                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
3539                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3540                         }
3541                     }
3542                     break;
3543             }
3544 #endif
3545 #if CYTHON_COMPILING_IN_CPYTHON
3546             if (unlikely(Py_SIZE(x) < 0)) {
3547                 goto raise_neg_overflow;
3548             }
3549 #else
3550             {
3551                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3552                 if (unlikely(result < 0))
3553                     return (int) -1;
3554                 if (unlikely(result == 1))
3555                     goto raise_neg_overflow;
3556             }
3557 #endif
3558             if (sizeof(int) <= sizeof(unsigned long)) {
3559                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
3560 #ifdef HAVE_LONG_LONG
3561             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3562                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3563 #endif
3564             }
3565         } else {
3566 #if CYTHON_USE_PYLONG_INTERNALS
3567             const digit* digits = ((PyLongObject*)x)->ob_digit;
3568             switch (Py_SIZE(x)) {
3569                 case  0: return (int) 0;
3570                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
3571                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
3572                 case -2:
3573                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
3574                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3575                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3576                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3577                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3578                         }
3579                     }
3580                     break;
3581                 case 2:
3582                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3583                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3584                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3585                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3586                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3587                         }
3588                     }
3589                     break;
3590                 case -3:
3591                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3592                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3593                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3594                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3595                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3596                         }
3597                     }
3598                     break;
3599                 case 3:
3600                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3601                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3602                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3603                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3604                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3605                         }
3606                     }
3607                     break;
3608                 case -4:
3609                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3610                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3611                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3612                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3613                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3614                         }
3615                     }
3616                     break;
3617                 case 4:
3618                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3619                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3620                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3621                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3622                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3623                         }
3624                     }
3625                     break;
3626             }
3627 #endif
3628             if (sizeof(int) <= sizeof(long)) {
3629                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
3630 #ifdef HAVE_LONG_LONG
3631             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3632                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
3633 #endif
3634             }
3635         }
3636         {
3637 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3638             PyErr_SetString(PyExc_RuntimeError,
3639                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3640 #else
3641             int val;
3642             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3643  #if PY_MAJOR_VERSION < 3
3644             if (likely(v) && !PyLong_Check(v)) {
3645                 PyObject *tmp = v;
3646                 v = PyNumber_Long(tmp);
3647                 Py_DECREF(tmp);
3648             }
3649  #endif
3650             if (likely(v)) {
3651                 int one = 1; int is_little = (int)*(unsigned char *)&one;
3652                 unsigned char *bytes = (unsigned char *)&val;
3653                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3654                                               bytes, sizeof(val),
3655                                               is_little, !is_unsigned);
3656                 Py_DECREF(v);
3657                 if (likely(!ret))
3658                     return val;
3659             }
3660 #endif
3661             return (int) -1;
3662         }
3663     } else {
3664         int val;
3665         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3666         if (!tmp) return (int) -1;
3667         val = __Pyx_PyInt_As_int(tmp);
3668         Py_DECREF(tmp);
3669         return val;
3670     }
3671 raise_overflow:
3672     PyErr_SetString(PyExc_OverflowError,
3673         "value too large to convert to int");
3674     return (int) -1;
3675 raise_neg_overflow:
3676     PyErr_SetString(PyExc_OverflowError,
3677         "can't convert negative value to int");
3678     return (int) -1;
3679 }
3680 
3681 /* CIntToPy */
__Pyx_PyInt_From_int(int value)3682 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
3683 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3684 #pragma GCC diagnostic push
3685 #pragma GCC diagnostic ignored "-Wconversion"
3686 #endif
3687     const int neg_one = (int) -1, const_zero = (int) 0;
3688 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3689 #pragma GCC diagnostic pop
3690 #endif
3691     const int is_unsigned = neg_one > const_zero;
3692     if (is_unsigned) {
3693         if (sizeof(int) < sizeof(long)) {
3694             return PyInt_FromLong((long) value);
3695         } else if (sizeof(int) <= sizeof(unsigned long)) {
3696             return PyLong_FromUnsignedLong((unsigned long) value);
3697 #ifdef HAVE_LONG_LONG
3698         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3699             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3700 #endif
3701         }
3702     } else {
3703         if (sizeof(int) <= sizeof(long)) {
3704             return PyInt_FromLong((long) value);
3705 #ifdef HAVE_LONG_LONG
3706         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3707             return PyLong_FromLongLong((PY_LONG_LONG) value);
3708 #endif
3709         }
3710     }
3711     {
3712         int one = 1; int little = (int)*(unsigned char *)&one;
3713         unsigned char *bytes = (unsigned char *)&value;
3714         return _PyLong_FromByteArray(bytes, sizeof(int),
3715                                      little, !is_unsigned);
3716     }
3717 }
3718 
3719 /* CIntToPy */
__Pyx_PyInt_From_long(long value)3720 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
3721 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3722 #pragma GCC diagnostic push
3723 #pragma GCC diagnostic ignored "-Wconversion"
3724 #endif
3725     const long neg_one = (long) -1, const_zero = (long) 0;
3726 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3727 #pragma GCC diagnostic pop
3728 #endif
3729     const int is_unsigned = neg_one > const_zero;
3730     if (is_unsigned) {
3731         if (sizeof(long) < sizeof(long)) {
3732             return PyInt_FromLong((long) value);
3733         } else if (sizeof(long) <= sizeof(unsigned long)) {
3734             return PyLong_FromUnsignedLong((unsigned long) value);
3735 #ifdef HAVE_LONG_LONG
3736         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
3737             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3738 #endif
3739         }
3740     } else {
3741         if (sizeof(long) <= sizeof(long)) {
3742             return PyInt_FromLong((long) value);
3743 #ifdef HAVE_LONG_LONG
3744         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
3745             return PyLong_FromLongLong((PY_LONG_LONG) value);
3746 #endif
3747         }
3748     }
3749     {
3750         int one = 1; int little = (int)*(unsigned char *)&one;
3751         unsigned char *bytes = (unsigned char *)&value;
3752         return _PyLong_FromByteArray(bytes, sizeof(long),
3753                                      little, !is_unsigned);
3754     }
3755 }
3756 
3757 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)3758 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
3759 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3760 #pragma GCC diagnostic push
3761 #pragma GCC diagnostic ignored "-Wconversion"
3762 #endif
3763     const long neg_one = (long) -1, const_zero = (long) 0;
3764 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3765 #pragma GCC diagnostic pop
3766 #endif
3767     const int is_unsigned = neg_one > const_zero;
3768 #if PY_MAJOR_VERSION < 3
3769     if (likely(PyInt_Check(x))) {
3770         if (sizeof(long) < sizeof(long)) {
3771             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
3772         } else {
3773             long val = PyInt_AS_LONG(x);
3774             if (is_unsigned && unlikely(val < 0)) {
3775                 goto raise_neg_overflow;
3776             }
3777             return (long) val;
3778         }
3779     } else
3780 #endif
3781     if (likely(PyLong_Check(x))) {
3782         if (is_unsigned) {
3783 #if CYTHON_USE_PYLONG_INTERNALS
3784             const digit* digits = ((PyLongObject*)x)->ob_digit;
3785             switch (Py_SIZE(x)) {
3786                 case  0: return (long) 0;
3787                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
3788                 case 2:
3789                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
3790                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3791                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3792                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
3793                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3794                         }
3795                     }
3796                     break;
3797                 case 3:
3798                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
3799                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3800                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3801                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
3802                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3803                         }
3804                     }
3805                     break;
3806                 case 4:
3807                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
3808                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3809                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3810                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
3811                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3812                         }
3813                     }
3814                     break;
3815             }
3816 #endif
3817 #if CYTHON_COMPILING_IN_CPYTHON
3818             if (unlikely(Py_SIZE(x) < 0)) {
3819                 goto raise_neg_overflow;
3820             }
3821 #else
3822             {
3823                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3824                 if (unlikely(result < 0))
3825                     return (long) -1;
3826                 if (unlikely(result == 1))
3827                     goto raise_neg_overflow;
3828             }
3829 #endif
3830             if (sizeof(long) <= sizeof(unsigned long)) {
3831                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
3832 #ifdef HAVE_LONG_LONG
3833             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
3834                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3835 #endif
3836             }
3837         } else {
3838 #if CYTHON_USE_PYLONG_INTERNALS
3839             const digit* digits = ((PyLongObject*)x)->ob_digit;
3840             switch (Py_SIZE(x)) {
3841                 case  0: return (long) 0;
3842                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
3843                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
3844                 case -2:
3845                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
3846                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3847                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3848                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3849                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3850                         }
3851                     }
3852                     break;
3853                 case 2:
3854                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
3855                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3856                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3857                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3858                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3859                         }
3860                     }
3861                     break;
3862                 case -3:
3863                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3864                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3865                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3866                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3867                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3868                         }
3869                     }
3870                     break;
3871                 case 3:
3872                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
3873                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3874                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3875                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3876                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3877                         }
3878                     }
3879                     break;
3880                 case -4:
3881                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3882                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3883                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3884                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3885                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3886                         }
3887                     }
3888                     break;
3889                 case 4:
3890                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
3891                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3892                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3893                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3894                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3895                         }
3896                     }
3897                     break;
3898             }
3899 #endif
3900             if (sizeof(long) <= sizeof(long)) {
3901                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
3902 #ifdef HAVE_LONG_LONG
3903             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
3904                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
3905 #endif
3906             }
3907         }
3908         {
3909 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3910             PyErr_SetString(PyExc_RuntimeError,
3911                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3912 #else
3913             long val;
3914             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3915  #if PY_MAJOR_VERSION < 3
3916             if (likely(v) && !PyLong_Check(v)) {
3917                 PyObject *tmp = v;
3918                 v = PyNumber_Long(tmp);
3919                 Py_DECREF(tmp);
3920             }
3921  #endif
3922             if (likely(v)) {
3923                 int one = 1; int is_little = (int)*(unsigned char *)&one;
3924                 unsigned char *bytes = (unsigned char *)&val;
3925                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3926                                               bytes, sizeof(val),
3927                                               is_little, !is_unsigned);
3928                 Py_DECREF(v);
3929                 if (likely(!ret))
3930                     return val;
3931             }
3932 #endif
3933             return (long) -1;
3934         }
3935     } else {
3936         long val;
3937         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3938         if (!tmp) return (long) -1;
3939         val = __Pyx_PyInt_As_long(tmp);
3940         Py_DECREF(tmp);
3941         return val;
3942     }
3943 raise_overflow:
3944     PyErr_SetString(PyExc_OverflowError,
3945         "value too large to convert to long");
3946     return (long) -1;
3947 raise_neg_overflow:
3948     PyErr_SetString(PyExc_OverflowError,
3949         "can't convert negative value to long");
3950     return (long) -1;
3951 }
3952 
3953 /* FastTypeChecks */
3954 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)3955 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
3956     while (a) {
3957         a = a->tp_base;
3958         if (a == b)
3959             return 1;
3960     }
3961     return b == &PyBaseObject_Type;
3962 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)3963 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
3964     PyObject *mro;
3965     if (a == b) return 1;
3966     mro = a->tp_mro;
3967     if (likely(mro)) {
3968         Py_ssize_t i, n;
3969         n = PyTuple_GET_SIZE(mro);
3970         for (i = 0; i < n; i++) {
3971             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
3972                 return 1;
3973         }
3974         return 0;
3975     }
3976     return __Pyx_InBases(a, b);
3977 }
3978 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)3979 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
3980     PyObject *exception, *value, *tb;
3981     int res;
3982     __Pyx_PyThreadState_declare
3983     __Pyx_PyThreadState_assign
3984     __Pyx_ErrFetch(&exception, &value, &tb);
3985     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
3986     if (unlikely(res == -1)) {
3987         PyErr_WriteUnraisable(err);
3988         res = 0;
3989     }
3990     if (!res) {
3991         res = PyObject_IsSubclass(err, exc_type2);
3992         if (unlikely(res == -1)) {
3993             PyErr_WriteUnraisable(err);
3994             res = 0;
3995         }
3996     }
3997     __Pyx_ErrRestore(exception, value, tb);
3998     return res;
3999 }
4000 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4001 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
4002     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
4003     if (!res) {
4004         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
4005     }
4006     return res;
4007 }
4008 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)4009 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
4010     Py_ssize_t i, n;
4011     assert(PyExceptionClass_Check(exc_type));
4012     n = PyTuple_GET_SIZE(tuple);
4013 #if PY_MAJOR_VERSION >= 3
4014     for (i=0; i<n; i++) {
4015         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
4016     }
4017 #endif
4018     for (i=0; i<n; i++) {
4019         PyObject *t = PyTuple_GET_ITEM(tuple, i);
4020         #if PY_MAJOR_VERSION < 3
4021         if (likely(exc_type == t)) return 1;
4022         #endif
4023         if (likely(PyExceptionClass_Check(t))) {
4024             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
4025         } else {
4026         }
4027     }
4028     return 0;
4029 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)4030 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
4031     if (likely(err == exc_type)) return 1;
4032     if (likely(PyExceptionClass_Check(err))) {
4033         if (likely(PyExceptionClass_Check(exc_type))) {
4034             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
4035         } else if (likely(PyTuple_Check(exc_type))) {
4036             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
4037         } else {
4038         }
4039     }
4040     return PyErr_GivenExceptionMatches(err, exc_type);
4041 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4042 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
4043     assert(PyExceptionClass_Check(exc_type1));
4044     assert(PyExceptionClass_Check(exc_type2));
4045     if (likely(err == exc_type1 || err == exc_type2)) return 1;
4046     if (likely(PyExceptionClass_Check(err))) {
4047         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
4048     }
4049     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
4050 }
4051 #endif
4052 
4053 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)4054 static int __Pyx_check_binary_version(void) {
4055     char ctversion[4], rtversion[4];
4056     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
4057     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
4058     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
4059         char message[200];
4060         PyOS_snprintf(message, sizeof(message),
4061                       "compiletime version %s of module '%.100s' "
4062                       "does not match runtime version %s",
4063                       ctversion, __Pyx_MODULE_NAME, rtversion);
4064         return PyErr_WarnEx(NULL, message, 1);
4065     }
4066     return 0;
4067 }
4068 
4069 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)4070 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
4071     while (t->p) {
4072         #if PY_MAJOR_VERSION < 3
4073         if (t->is_unicode) {
4074             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
4075         } else if (t->intern) {
4076             *t->p = PyString_InternFromString(t->s);
4077         } else {
4078             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
4079         }
4080         #else
4081         if (t->is_unicode | t->is_str) {
4082             if (t->intern) {
4083                 *t->p = PyUnicode_InternFromString(t->s);
4084             } else if (t->encoding) {
4085                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
4086             } else {
4087                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
4088             }
4089         } else {
4090             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
4091         }
4092         #endif
4093         if (!*t->p)
4094             return -1;
4095         if (PyObject_Hash(*t->p) == -1)
4096             return -1;
4097         ++t;
4098     }
4099     return 0;
4100 }
4101 
__Pyx_PyUnicode_FromString(const char * c_str)4102 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
4103     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
4104 }
__Pyx_PyObject_AsString(PyObject * o)4105 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
4106     Py_ssize_t ignore;
4107     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
4108 }
4109 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
4110 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)4111 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4112     char* defenc_c;
4113     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
4114     if (!defenc) return NULL;
4115     defenc_c = PyBytes_AS_STRING(defenc);
4116 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4117     {
4118         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
4119         char* c;
4120         for (c = defenc_c; c < end; c++) {
4121             if ((unsigned char) (*c) >= 128) {
4122                 PyUnicode_AsASCIIString(o);
4123                 return NULL;
4124             }
4125         }
4126     }
4127 #endif
4128     *length = PyBytes_GET_SIZE(defenc);
4129     return defenc_c;
4130 }
4131 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)4132 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4133     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
4134 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4135     if (likely(PyUnicode_IS_ASCII(o))) {
4136         *length = PyUnicode_GET_LENGTH(o);
4137         return PyUnicode_AsUTF8(o);
4138     } else {
4139         PyUnicode_AsASCIIString(o);
4140         return NULL;
4141     }
4142 #else
4143     return PyUnicode_AsUTF8AndSize(o, length);
4144 #endif
4145 }
4146 #endif
4147 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)4148 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4149 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
4150     if (
4151 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4152             __Pyx_sys_getdefaultencoding_not_ascii &&
4153 #endif
4154             PyUnicode_Check(o)) {
4155         return __Pyx_PyUnicode_AsStringAndSize(o, length);
4156     } else
4157 #endif
4158 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
4159     if (PyByteArray_Check(o)) {
4160         *length = PyByteArray_GET_SIZE(o);
4161         return PyByteArray_AS_STRING(o);
4162     } else
4163 #endif
4164     {
4165         char* result;
4166         int r = PyBytes_AsStringAndSize(o, &result, length);
4167         if (unlikely(r < 0)) {
4168             return NULL;
4169         } else {
4170             return result;
4171         }
4172     }
4173 }
__Pyx_PyObject_IsTrue(PyObject * x)4174 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
4175    int is_true = x == Py_True;
4176    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
4177    else return PyObject_IsTrue(x);
4178 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)4179 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
4180     int retval;
4181     if (unlikely(!x)) return -1;
4182     retval = __Pyx_PyObject_IsTrue(x);
4183     Py_DECREF(x);
4184     return retval;
4185 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)4186 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
4187 #if PY_MAJOR_VERSION >= 3
4188     if (PyLong_Check(result)) {
4189         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
4190                 "__int__ returned non-int (type %.200s).  "
4191                 "The ability to return an instance of a strict subclass of int "
4192                 "is deprecated, and may be removed in a future version of Python.",
4193                 Py_TYPE(result)->tp_name)) {
4194             Py_DECREF(result);
4195             return NULL;
4196         }
4197         return result;
4198     }
4199 #endif
4200     PyErr_Format(PyExc_TypeError,
4201                  "__%.4s__ returned non-%.4s (type %.200s)",
4202                  type_name, type_name, Py_TYPE(result)->tp_name);
4203     Py_DECREF(result);
4204     return NULL;
4205 }
__Pyx_PyNumber_IntOrLong(PyObject * x)4206 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
4207 #if CYTHON_USE_TYPE_SLOTS
4208   PyNumberMethods *m;
4209 #endif
4210   const char *name = NULL;
4211   PyObject *res = NULL;
4212 #if PY_MAJOR_VERSION < 3
4213   if (likely(PyInt_Check(x) || PyLong_Check(x)))
4214 #else
4215   if (likely(PyLong_Check(x)))
4216 #endif
4217     return __Pyx_NewRef(x);
4218 #if CYTHON_USE_TYPE_SLOTS
4219   m = Py_TYPE(x)->tp_as_number;
4220   #if PY_MAJOR_VERSION < 3
4221   if (m && m->nb_int) {
4222     name = "int";
4223     res = m->nb_int(x);
4224   }
4225   else if (m && m->nb_long) {
4226     name = "long";
4227     res = m->nb_long(x);
4228   }
4229   #else
4230   if (likely(m && m->nb_int)) {
4231     name = "int";
4232     res = m->nb_int(x);
4233   }
4234   #endif
4235 #else
4236   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
4237     res = PyNumber_Int(x);
4238   }
4239 #endif
4240   if (likely(res)) {
4241 #if PY_MAJOR_VERSION < 3
4242     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
4243 #else
4244     if (unlikely(!PyLong_CheckExact(res))) {
4245 #endif
4246         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
4247     }
4248   }
4249   else if (!PyErr_Occurred()) {
4250     PyErr_SetString(PyExc_TypeError,
4251                     "an integer is required");
4252   }
4253   return res;
4254 }
4255 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
4256   Py_ssize_t ival;
4257   PyObject *x;
4258 #if PY_MAJOR_VERSION < 3
4259   if (likely(PyInt_CheckExact(b))) {
4260     if (sizeof(Py_ssize_t) >= sizeof(long))
4261         return PyInt_AS_LONG(b);
4262     else
4263         return PyInt_AsSsize_t(b);
4264   }
4265 #endif
4266   if (likely(PyLong_CheckExact(b))) {
4267     #if CYTHON_USE_PYLONG_INTERNALS
4268     const digit* digits = ((PyLongObject*)b)->ob_digit;
4269     const Py_ssize_t size = Py_SIZE(b);
4270     if (likely(__Pyx_sst_abs(size) <= 1)) {
4271         ival = likely(size) ? digits[0] : 0;
4272         if (size == -1) ival = -ival;
4273         return ival;
4274     } else {
4275       switch (size) {
4276          case 2:
4277            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
4278              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4279            }
4280            break;
4281          case -2:
4282            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
4283              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4284            }
4285            break;
4286          case 3:
4287            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
4288              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4289            }
4290            break;
4291          case -3:
4292            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
4293              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4294            }
4295            break;
4296          case 4:
4297            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
4298              return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4299            }
4300            break;
4301          case -4:
4302            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
4303              return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4304            }
4305            break;
4306       }
4307     }
4308     #endif
4309     return PyLong_AsSsize_t(b);
4310   }
4311   x = PyNumber_Index(b);
4312   if (!x) return -1;
4313   ival = PyInt_AsSsize_t(x);
4314   Py_DECREF(x);
4315   return ival;
4316 }
4317 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
4318   if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
4319     return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
4320 #if PY_MAJOR_VERSION < 3
4321   } else if (likely(PyInt_CheckExact(o))) {
4322     return PyInt_AS_LONG(o);
4323 #endif
4324   } else {
4325     Py_ssize_t ival;
4326     PyObject *x;
4327     x = PyNumber_Index(o);
4328     if (!x) return -1;
4329     ival = PyInt_AsLong(x);
4330     Py_DECREF(x);
4331     return ival;
4332   }
4333 }
4334 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
4335   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
4336 }
4337 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
4338     return PyInt_FromSize_t(ival);
4339 }
4340 
4341 
4342 #endif /* Py_PYTHON_H */
4343