diff --git a/docs/conf.py b/docs/conf.py index 56fc545..b447708 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,6 +10,7 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +import rainforest import os import sys sys.path.insert(0, os.path.abspath('.')) @@ -31,7 +32,7 @@ # ones. extensions = ['sphinx.ext.napoleon'] master_doc = 'index' - +version = rainforest.__version__ # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/rainforest/__init__.py b/rainforest/__init__.py index 99b7be3..18422a0 100644 --- a/rainforest/__init__.py +++ b/rainforest/__init__.py @@ -2,4 +2,6 @@ from . import common from . import database from . import ml -from . import performance \ No newline at end of file +from . import performance + +__version__ = common.utils.get_version() diff --git a/rainforest/common/add_at.c b/rainforest/common/add_at.c index 59bffb4..04be795 100644 --- a/rainforest/common/add_at.c +++ b/rainforest/common/add_at.c @@ -1,17 +1,17 @@ -/* Generated by Cython 3.0.0 */ +/* Generated by Cython 3.0.10 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ - "/store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h", - "/store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/core/include/numpy/arrayscalars.h", - "/store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h", - "/store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h", - "/store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/core/include/numpy/ufuncobject.h" + "/tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/core/include/numpy/arrayobject.h", + "/tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/core/include/numpy/arrayscalars.h", + "/tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/core/include/numpy/ndarrayobject.h", + "/tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/core/include/numpy/ndarraytypes.h", + "/tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/core/include/numpy/ufuncobject.h" ], "include_dirs": [ - "/store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/core/include" + "/tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/core/include" ], "name": "rainforest.common.add_at", "sources": [ @@ -41,10 +41,15 @@ END: Cython Metadata */ #elif PY_VERSION_HEX < 0x02070000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.7+ or Python 3.3+. #else -#define CYTHON_ABI "3_0_0" +#if defined(CYTHON_LIMITED_API) && CYTHON_LIMITED_API +#define __PYX_EXTRA_ABI_MODULE_NAME "limited" +#else +#define __PYX_EXTRA_ABI_MODULE_NAME "" +#endif +#define CYTHON_ABI "3_0_10" __PYX_EXTRA_ABI_MODULE_NAME #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." -#define CYTHON_HEX_VERSION 0x030000F0 +#define CYTHON_HEX_VERSION 0x03000AF0 #define CYTHON_FUTURE_DIVISION 1 #include #ifndef offsetof @@ -77,6 +82,7 @@ END: Cython Metadata */ #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif +#define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ @@ -135,6 +141,8 @@ END: Cython Metadata */ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif + #undef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 @@ -143,8 +151,9 @@ END: Cython Metadata */ #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_TYPE_SPECS - #define CYTHON_USE_TYPE_SPECS 0 + #ifndef CYTHON_USE_TYPE_SPECS + #define CYTHON_USE_TYPE_SPECS 0 + #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 @@ -195,7 +204,13 @@ END: Cython Metadata */ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif + #undef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 #elif defined(CYTHON_LIMITED_API) + #ifdef Py_LIMITED_API + #undef __PYX_LIMITED_VERSION_HEX + #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API + #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 @@ -243,7 +258,7 @@ END: Cython Metadata */ #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 1 #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 1 + #define CYTHON_USE_TP_FINALIZE 0 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 @@ -252,7 +267,9 @@ END: Cython Metadata */ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif -#elif defined(PY_NOGIL) + #undef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 +#elif defined(Py_GIL_DISABLED) || defined(Py_NOGIL) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 @@ -261,11 +278,17 @@ END: Cython Metadata */ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #ifndef CYTHON_USE_TYPE_SPECS + #define CYTHON_USE_TYPE_SPECS 0 + #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #ifndef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 1 #endif + #ifndef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS @@ -273,8 +296,6 @@ END: Cython Metadata */ #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif @@ -286,11 +307,22 @@ END: Cython Metadata */ #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_GIL + #define CYTHON_FAST_GIL 0 + #ifndef CYTHON_METH_FASTCALL + #define CYTHON_METH_FASTCALL 1 + #endif #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #ifndef CYTHON_PEP487_INIT_SUBCLASS + #define CYTHON_PEP487_INIT_SUBCLASS 1 + #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif + #ifndef CYTHON_USE_MODULE_STATE + #define CYTHON_USE_MODULE_STATE 0 + #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif @@ -298,6 +330,12 @@ END: Cython Metadata */ #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 + #endif + #ifndef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 0 + #endif #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 @@ -388,6 +426,9 @@ END: Cython Metadata */ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif + #ifndef CYTHON_USE_FREELISTS + #define CYTHON_USE_FREELISTS 1 + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -465,6 +506,14 @@ END: Cython Metadata */ # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif +#ifndef CYTHON_USE_CPP_STD_MOVE + #if defined(__cplusplus) && (\ + __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) + #define CYTHON_USE_CPP_STD_MOVE 1 + #else + #define CYTHON_USE_CPP_STD_MOVE 0 + #endif +#endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ @@ -564,59 +613,91 @@ END: Cython Metadata */ #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type -#if PY_VERSION_HEX >= 0x030B00A1 - static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, +#if CYTHON_COMPILING_IN_LIMITED_API + static CYTHON_INLINE PyObject* __Pyx_PyCode_New(int a, int p, 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) { - PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; - PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *empty=NULL; - const char *fn_cstr=NULL; - const char *name_cstr=NULL; - PyCodeObject *co=NULL, *result=NULL; + PyObject *exception_table = NULL; + PyObject *types_module=NULL, *code_type=NULL, *result=NULL; + #if __PYX_LIMITED_VERSION_HEX < 0x030B0000 + PyObject *version_info; + PyObject *py_minor_version = NULL; + #endif + long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); - if (!(kwds=PyDict_New())) goto end; - if (!(argcount=PyLong_FromLong(a))) goto end; - if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; - if (!(posonlyargcount=PyLong_FromLong(p))) goto end; - if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; - if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; - if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; - if (!(nlocals=PyLong_FromLong(l))) goto end; - if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; - if (!(stacksize=PyLong_FromLong(s))) goto end; - if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; - if (!(flags=PyLong_FromLong(f))) goto end; - if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; - if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; - if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; - if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; - if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto end; - if (!(empty = PyTuple_New(0))) goto end; - result = (PyCodeObject*) PyObject_Call(replace, empty, kwds); + #if __PYX_LIMITED_VERSION_HEX >= 0x030B0000 + minor_version = 11; + #else + if (!(version_info = PySys_GetObject("version_info"))) goto end; + if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; + minor_version = PyLong_AsLong(py_minor_version); + Py_DECREF(py_minor_version); + if (minor_version == -1 && PyErr_Occurred()) goto end; + #endif + if (!(types_module = PyImport_ImportModule("types"))) goto end; + if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; + if (minor_version <= 7) { + (void)p; + result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOO", a, k, l, s, f, code, + c, n, v, fn, name, fline, lnos, fv, cell); + } else if (minor_version <= 10) { + result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOO", a,p, k, l, s, f, code, + c, n, v, fn, name, fline, lnos, fv, cell); + } else { + if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; + result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOO", a,p, k, l, s, f, code, + c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); + } end: - Py_XDECREF((PyObject*) co); - Py_XDECREF(kwds); - Py_XDECREF(argcount); - Py_XDECREF(posonlyargcount); - Py_XDECREF(kwonlyargcount); - Py_XDECREF(nlocals); - Py_XDECREF(stacksize); - Py_XDECREF(replace); - Py_XDECREF(empty); + Py_XDECREF(code_type); + Py_XDECREF(exception_table); + Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } + #ifndef CO_OPTIMIZED + #define CO_OPTIMIZED 0x0001 + #endif + #ifndef CO_NEWLOCALS + #define CO_NEWLOCALS 0x0002 + #endif + #ifndef CO_VARARGS + #define CO_VARARGS 0x0004 + #endif + #ifndef CO_VARKEYWORDS + #define CO_VARKEYWORDS 0x0008 + #endif + #ifndef CO_ASYNC_GENERATOR + #define CO_ASYNC_GENERATOR 0x0200 + #endif + #ifndef CO_GENERATOR + #define CO_GENERATOR 0x0020 + #endif + #ifndef CO_COROUTINE + #define CO_COROUTINE 0x0080 + #endif +#elif PY_VERSION_HEX >= 0x030B0000 + static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, 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) { + PyCodeObject *result; + PyObject *empty_bytes = PyBytes_FromStringAndSize("", 0); + if (!empty_bytes) return NULL; + result = + #if PY_VERSION_HEX >= 0x030C0000 + PyUnstable_Code_NewWithPosOnlyArgs + #else + PyCode_NewWithPosOnlyArgs + #endif + (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, empty_bytes); + Py_DECREF(empty_bytes); + return result; + } #elif PY_VERSION_HEX >= 0x030800B2 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) @@ -691,8 +772,13 @@ END: Cython Metadata */ typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords + #if PY_VERSION_HEX >= 0x030d00A4 + # define __Pyx_PyCFunctionFast PyCFunctionFast + # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords + #else + # define __Pyx_PyCFunctionFast _PyCFunctionFast + # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords + #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL @@ -716,7 +802,32 @@ END: Cython Metadata */ #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif -#if PY_VERSION_HEX < 0x030900B1 +#if PY_MAJOR_VERSION >= 0x030900B1 +#define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) +#else +#define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) +#endif +#define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) +#elif !CYTHON_COMPILING_IN_LIMITED_API +#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) +#endif +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) +static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { + return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; +} +#endif +static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void *cfunc) { +#if CYTHON_COMPILING_IN_LIMITED_API + return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; +#else + return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; +#endif +} +#define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) +#if __PYX_LIMITED_VERSION_HEX < 0x030900B1 #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else @@ -742,6 +853,8 @@ END: Cython Metadata */ #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x030d00A1 + #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 @@ -817,7 +930,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { } #endif #endif -#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() @@ -829,7 +942,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B4 && CYTHON_USE_UNICODE_INTERNALS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B4 && PY_VERSION_HEX < 0x030d0000 && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); @@ -866,9 +979,14 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #define __Pyx_PyObject_GetIterNextFunc(obj) PyIter_Next #endif +#if CYTHON_COMPILING_IN_LIMITED_API + #define __Pyx_SetItemOnTypeDict(tp, k, v) PyObject_GenericSetAttr((PyObject*)tp, k, v) +#else + #define __Pyx_SetItemOnTypeDict(tp, k, v) PyDict_SetItem(tp->tp_dict, k, v) +#endif #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX >= 0x03080000 #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ - PyTypeObject *type = Py_TYPE(obj);\ + PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ @@ -992,9 +1110,34 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif #if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) -#else + #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) + #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) + #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) + #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) + #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) + #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) + #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) +#else + #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) + #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) + #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) + #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) + #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) + #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) + #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) + #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) +#endif +#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 + #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) +#else + static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { + PyObject *module = PyImport_AddModule(name); + Py_XINCREF(module); + return module; + } #endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -1074,7 +1217,7 @@ static CYTHON_INLINE float __PYX_NAN() { #endif #define __PYX_MARK_ERR_POS(f_index, lineno) \ - { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } + { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } @@ -1156,9 +1299,10 @@ static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif +static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize @@ -1186,24 +1330,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -#if CYTHON_COMPILING_IN_LIMITED_API -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const wchar_t *u) -{ - const wchar_t *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#else -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) -{ - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#endif #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) @@ -1253,7 +1380,7 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; - #else // Py < 3.12 + #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) @@ -1274,6 +1401,7 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #endif #endif #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +#include static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; @@ -1324,6 +1452,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#include static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; @@ -1371,7 +1500,7 @@ static const char *__pyx_filename; #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 - #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__)) + #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__) && !defined(_MSC_VER)) #define CYTHON_CCOMPLEX 1 #else #define CYTHON_CCOMPLEX 0 @@ -1397,6 +1526,11 @@ static const char *__pyx_f[] = { "type.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /* BufferFormatStructs.proto */ struct __Pyx_StructField_; #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) @@ -1434,7 +1568,7 @@ typedef struct { /* #### Code section: numeric_typedefs ### */ -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":731 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":730 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -1443,7 +1577,7 @@ typedef struct { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":732 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":731 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -1452,7 +1586,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":733 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":732 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -1461,7 +1595,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":734 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":733 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -1470,7 +1604,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":738 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":737 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -1479,7 +1613,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":739 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":738 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -1488,7 +1622,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":740 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":739 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -1497,7 +1631,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":741 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":740 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -1506,7 +1640,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":745 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":744 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -1515,7 +1649,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":746 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":745 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -1524,61 +1658,43 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":755 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":754 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t + * */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":756 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":755 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t - * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong longlong_t - * - */ -typedef npy_longlong __pyx_t_5numpy_long_t; - -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":757 - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< * * ctypedef npy_ulong uint_t */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":759 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":757 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t + * */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":760 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":758 * * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulonglong_t - * - */ -typedef npy_ulonglong __pyx_t_5numpy_ulong_t; - -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":761 - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< * * ctypedef npy_intp intp_t */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":763 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":760 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -1587,7 +1703,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":764 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":761 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -1596,7 +1712,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":766 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":763 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -1605,7 +1721,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":767 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":764 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -1614,7 +1730,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":768 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":765 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -1678,7 +1794,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do /*--- Type declarations ---*/ -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":770 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":767 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -1687,7 +1803,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":771 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":768 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -1696,7 +1812,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":772 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":769 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -1705,7 +1821,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":774 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":771 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1909,7 +2025,20 @@ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int eq static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* fastcall.proto */ -#define __Pyx_Arg_VARARGS(args, i) PyTuple_GET_ITEM(args, i) +#if CYTHON_AVOID_BORROWED_REFS + #define __Pyx_Arg_VARARGS(args, i) PySequence_GetItem(args, i) +#elif CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_Arg_VARARGS(args, i) PyTuple_GET_ITEM(args, i) +#else + #define __Pyx_Arg_VARARGS(args, i) PyTuple_GetItem(args, i) +#endif +#if CYTHON_AVOID_BORROWED_REFS + #define __Pyx_Arg_NewRef_VARARGS(arg) __Pyx_NewRef(arg) + #define __Pyx_Arg_XDECREF_VARARGS(arg) Py_XDECREF(arg) +#else + #define __Pyx_Arg_NewRef_VARARGS(arg) arg + #define __Pyx_Arg_XDECREF_VARARGS(arg) +#endif #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) #define __Pyx_KwValues_VARARGS(args, nargs) NULL #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) @@ -1919,15 +2048,24 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int #define __Pyx_NumKwargs_FASTCALL(kwds) PyTuple_GET_SIZE(kwds) #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 + CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); + #else #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) + #endif + #define __Pyx_Arg_NewRef_FASTCALL(arg) arg /* no-op, __Pyx_Arg_FASTCALL is direct and this needs + to have the same reference counting */ + #define __Pyx_Arg_XDECREF_FASTCALL(arg) #else #define __Pyx_Arg_FASTCALL __Pyx_Arg_VARARGS #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS + #define __Pyx_Arg_NewRef_FASTCALL(arg) __Pyx_Arg_NewRef_VARARGS(arg) + #define __Pyx_Arg_XDECREF_FASTCALL(arg) __Pyx_Arg_XDECREF_VARARGS(arg) #endif -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS #define __Pyx_ArgsSlice_VARARGS(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_VARARGS(args, start), stop - start) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_FASTCALL(args, start), stop - start) #else @@ -1981,22 +2119,22 @@ static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static void __Pyx_RaiseBufferIndexError(int axis); /* TypeImport.proto */ -#ifndef __PYX_HAVE_RT_ImportType_proto_3_0_0 -#define __PYX_HAVE_RT_ImportType_proto_3_0_0 +#ifndef __PYX_HAVE_RT_ImportType_proto_3_0_10 +#define __PYX_HAVE_RT_ImportType_proto_3_0_10 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L -#define __PYX_GET_STRUCT_ALIGNMENT_3_0_0(s) alignof(s) +#define __PYX_GET_STRUCT_ALIGNMENT_3_0_10(s) alignof(s) #else -#define __PYX_GET_STRUCT_ALIGNMENT_3_0_0(s) sizeof(void*) +#define __PYX_GET_STRUCT_ALIGNMENT_3_0_10(s) sizeof(void*) #endif -enum __Pyx_ImportType_CheckSize_3_0_0 { - __Pyx_ImportType_CheckSize_Error_3_0_0 = 0, - __Pyx_ImportType_CheckSize_Warn_3_0_0 = 1, - __Pyx_ImportType_CheckSize_Ignore_3_0_0 = 2 +enum __Pyx_ImportType_CheckSize_3_0_10 { + __Pyx_ImportType_CheckSize_Error_3_0_10 = 0, + __Pyx_ImportType_CheckSize_Warn_3_0_10 = 1, + __Pyx_ImportType_CheckSize_Ignore_3_0_10 = 2 }; -static PyTypeObject *__Pyx_ImportType_3_0_0(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_0 check_size); +static PyTypeObject *__Pyx_ImportType_3_0_10(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_10 check_size); #endif /* Import.proto */ @@ -2027,7 +2165,22 @@ static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec #endif /* PyMethodNew.proto */ -#if PY_MAJOR_VERSION >= 3 +#if CYTHON_COMPILING_IN_LIMITED_API +static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { + PyObject *typesModule=NULL, *methodType=NULL, *result=NULL; + CYTHON_UNUSED_VAR(typ); + if (!self) + return __Pyx_NewRef(func); + typesModule = PyImport_ImportModule("types"); + if (!typesModule) return NULL; + methodType = PyObject_GetAttrString(typesModule, "MethodType"); + Py_DECREF(typesModule); + if (!methodType) return NULL; + result = PyObject_CallFunctionObjArgs(methodType, func, self, NULL); + Py_DECREF(methodType); + return result; +} +#elif PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { CYTHON_UNUSED_VAR(typ); if (!self) @@ -2051,7 +2204,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, _ #define __Pyx_CYFUNCTION_COROUTINE 0x08 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) -#if PY_VERSION_HEX < 0x030900B1 +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #else @@ -2065,7 +2218,10 @@ static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, _ #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { -#if PY_VERSION_HEX < 0x030900B1 +#if CYTHON_COMPILING_IN_LIMITED_API + PyObject_HEAD + PyObject *func; +#elif PY_VERSION_HEX < 0x030900B1 PyCFunctionObject func; #else PyCMethodObject func; @@ -2073,7 +2229,7 @@ typedef struct { #if CYTHON_BACKPORT_VECTORCALL __pyx_vectorcallfunc func_vectorcall; #endif -#if PY_VERSION_HEX < 0x030500A0 +#if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_weakreflist; #endif PyObject *func_dict; @@ -2083,12 +2239,12 @@ typedef struct { PyObject *func_globals; PyObject *func_code; PyObject *func_closure; -#if PY_VERSION_HEX < 0x030900B1 +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_classobj; #endif void *defaults; int defaults_pyobjects; - size_t defaults_size; // used by FusedFunction for copying defaults + size_t defaults_size; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; @@ -2096,9 +2252,13 @@ typedef struct { PyObject *func_annotations; PyObject *func_is_coroutine; } __pyx_CyFunctionObject; +#undef __Pyx_CyOrPyCFunction_Check #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_CyFunctionType) -#define __Pyx_IsCyOrPyCFunction(obj) __Pyx_TypeCheck2(obj, __pyx_CyFunctionType, &PyCFunction_Type) +#define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_CyFunctionType, &PyCFunction_Type) #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_CyFunctionType) +static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc); +#undef __Pyx_IsSameCFunction +#define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, @@ -2357,7 +2517,8 @@ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObj #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) /* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); +static unsigned long __Pyx_get_runtime_version(void); +static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); @@ -2791,7 +2952,7 @@ static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { #define __pyx_codeobj__7 __pyx_mstate_global->__pyx_codeobj__7 /* #### Code section: module_code ### */ -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":245 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":245 * * @property * cdef inline PyObject* base(self) nogil: # <<<<<<<<<<<<<< @@ -2802,7 +2963,7 @@ static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { static CYTHON_INLINE PyObject *__pyx_f_5numpy_7ndarray_4base_base(PyArrayObject *__pyx_v_self) { PyObject *__pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":248 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":248 * """Returns a borrowed reference to the object owning the data/memory. * """ * return PyArray_BASE(self) # <<<<<<<<<<<<<< @@ -2812,7 +2973,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_7ndarray_4base_base(PyArrayObject __pyx_r = PyArray_BASE(__pyx_v_self); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":245 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":245 * * @property * cdef inline PyObject* base(self) nogil: # <<<<<<<<<<<<<< @@ -2825,7 +2986,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_7ndarray_4base_base(PyArrayObject return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":251 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":251 * * @property * cdef inline dtype descr(self): # <<<<<<<<<<<<<< @@ -2837,9 +2998,9 @@ static CYTHON_INLINE PyArray_Descr *__pyx_f_5numpy_7ndarray_5descr_descr(PyArray PyArray_Descr *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyArray_Descr *__pyx_t_1; - __Pyx_RefNannySetupContext("descr", 0); + __Pyx_RefNannySetupContext("descr", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":254 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":254 * """Returns an owned reference to the dtype of the array. * """ * return PyArray_DESCR(self) # <<<<<<<<<<<<<< @@ -2852,7 +3013,7 @@ static CYTHON_INLINE PyArray_Descr *__pyx_f_5numpy_7ndarray_5descr_descr(PyArray __pyx_r = ((PyArray_Descr *)__pyx_t_1); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":251 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":251 * * @property * cdef inline dtype descr(self): # <<<<<<<<<<<<<< @@ -2867,7 +3028,7 @@ static CYTHON_INLINE PyArray_Descr *__pyx_f_5numpy_7ndarray_5descr_descr(PyArray return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":257 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":257 * * @property * cdef inline int ndim(self) nogil: # <<<<<<<<<<<<<< @@ -2878,7 +3039,7 @@ static CYTHON_INLINE PyArray_Descr *__pyx_f_5numpy_7ndarray_5descr_descr(PyArray static CYTHON_INLINE int __pyx_f_5numpy_7ndarray_4ndim_ndim(PyArrayObject *__pyx_v_self) { int __pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":260 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":260 * """Returns the number of dimensions in the array. * """ * return PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -2888,7 +3049,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_7ndarray_4ndim_ndim(PyArrayObject *__pyx __pyx_r = PyArray_NDIM(__pyx_v_self); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":257 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":257 * * @property * cdef inline int ndim(self) nogil: # <<<<<<<<<<<<<< @@ -2901,7 +3062,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_7ndarray_4ndim_ndim(PyArrayObject *__pyx return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":263 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":263 * * @property * cdef inline npy_intp *shape(self) nogil: # <<<<<<<<<<<<<< @@ -2912,7 +3073,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_7ndarray_4ndim_ndim(PyArrayObject *__pyx static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_5shape_shape(PyArrayObject *__pyx_v_self) { npy_intp *__pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":268 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":268 * Can return NULL for 0-dimensional arrays. * """ * return PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -2922,7 +3083,7 @@ static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_5shape_shape(PyArrayObjec __pyx_r = PyArray_DIMS(__pyx_v_self); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":263 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":263 * * @property * cdef inline npy_intp *shape(self) nogil: # <<<<<<<<<<<<<< @@ -2935,7 +3096,7 @@ static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_5shape_shape(PyArrayObjec return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":271 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":271 * * @property * cdef inline npy_intp *strides(self) nogil: # <<<<<<<<<<<<<< @@ -2946,7 +3107,7 @@ static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_5shape_shape(PyArrayObjec static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_7strides_strides(PyArrayObject *__pyx_v_self) { npy_intp *__pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":275 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":275 * The number of elements matches the number of dimensions of the array (ndim). * """ * return PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -2956,7 +3117,7 @@ static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_7strides_strides(PyArrayO __pyx_r = PyArray_STRIDES(__pyx_v_self); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":271 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":271 * * @property * cdef inline npy_intp *strides(self) nogil: # <<<<<<<<<<<<<< @@ -2969,7 +3130,7 @@ static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_7strides_strides(PyArrayO return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":278 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":278 * * @property * cdef inline npy_intp size(self) nogil: # <<<<<<<<<<<<<< @@ -2980,7 +3141,7 @@ static CYTHON_INLINE npy_intp *__pyx_f_5numpy_7ndarray_7strides_strides(PyArrayO static CYTHON_INLINE npy_intp __pyx_f_5numpy_7ndarray_4size_size(PyArrayObject *__pyx_v_self) { npy_intp __pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":281 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":281 * """Returns the total size (in number of elements) of the array. * """ * return PyArray_SIZE(self) # <<<<<<<<<<<<<< @@ -2990,7 +3151,7 @@ static CYTHON_INLINE npy_intp __pyx_f_5numpy_7ndarray_4size_size(PyArrayObject * __pyx_r = PyArray_SIZE(__pyx_v_self); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":278 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":278 * * @property * cdef inline npy_intp size(self) nogil: # <<<<<<<<<<<<<< @@ -3003,7 +3164,7 @@ static CYTHON_INLINE npy_intp __pyx_f_5numpy_7ndarray_4size_size(PyArrayObject * return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":284 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":284 * * @property * cdef inline char* data(self) nogil: # <<<<<<<<<<<<<< @@ -3014,7 +3175,7 @@ static CYTHON_INLINE npy_intp __pyx_f_5numpy_7ndarray_4size_size(PyArrayObject * static CYTHON_INLINE char *__pyx_f_5numpy_7ndarray_4data_data(PyArrayObject *__pyx_v_self) { char *__pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":290 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":290 * of `PyArray_DATA()` instead, which returns a 'void*'. * """ * return PyArray_BYTES(self) # <<<<<<<<<<<<<< @@ -3024,7 +3185,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy_7ndarray_4data_data(PyArrayObject *__p __pyx_r = PyArray_BYTES(__pyx_v_self); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":284 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":284 * * @property * cdef inline char* data(self) nogil: # <<<<<<<<<<<<<< @@ -3037,7 +3198,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy_7ndarray_4data_data(PyArrayObject *__p return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":776 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":773 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3052,9 +3213,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":777 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":774 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -3062,13 +3223,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":776 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":773 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3087,7 +3248,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":779 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":776 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -3102,9 +3263,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":780 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":777 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -3112,13 +3273,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":779 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":776 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -3137,7 +3298,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":782 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":779 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -3152,9 +3313,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":783 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":780 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -3162,13 +3323,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":782 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":779 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -3187,7 +3348,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":785 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":782 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -3202,9 +3363,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":786 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":783 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -3212,13 +3373,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 786, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":785 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":782 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -3237,7 +3398,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":788 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":785 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -3252,9 +3413,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":789 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":786 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -3262,13 +3423,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ * cdef inline tuple PyDataType_SHAPE(dtype d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 789, __pyx_L1_error) + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":788 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":785 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -3287,7 +3448,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":791 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":788 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -3299,9 +3460,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; - __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); + __Pyx_RefNannySetupContext("PyDataType_SHAPE", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":792 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":789 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -3311,7 +3472,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_t_1 = PyDataType_HASSUBARRAY(__pyx_v_d); if (__pyx_t_1) { - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":793 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":790 * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): * return d.subarray.shape # <<<<<<<<<<<<<< @@ -3323,7 +3484,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":792 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":789 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -3332,7 +3493,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ */ } - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":795 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":792 * return d.subarray.shape * else: * return () # <<<<<<<<<<<<<< @@ -3346,7 +3507,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ goto __pyx_L0; } - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":791 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":788 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -3361,7 +3522,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":970 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":968 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -3370,10 +3531,12 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_array_base", 0); + int __pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":971 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":969 * * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< @@ -3382,16 +3545,16 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":972 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":970 * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ - (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); + __pyx_t_1 = PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 970, __pyx_L1_error) - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":970 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":968 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -3400,10 +3563,13 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ /* function exit code */ - __Pyx_RefNannyFinishContext(); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("numpy.set_array_base", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":974 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":972 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -3416,9 +3582,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); + __Pyx_RefNannySetupContext("get_array_base", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":975 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":973 * * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< @@ -3427,7 +3593,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ __pyx_v_base = PyArray_BASE(__pyx_v_arr); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":976 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":974 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -3437,7 +3603,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = (__pyx_v_base == NULL); if (__pyx_t_1) { - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":977 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":975 * base = PyArray_BASE(arr) * if base is NULL: * return None # <<<<<<<<<<<<<< @@ -3448,7 +3614,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":976 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":974 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -3457,7 +3623,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ } - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":978 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":976 * if base is NULL: * return None * return base # <<<<<<<<<<<<<< @@ -3469,7 +3635,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = ((PyObject *)__pyx_v_base); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":974 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":972 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -3484,7 +3650,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":982 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":980 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -3506,9 +3672,9 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_array", 0); + __Pyx_RefNannySetupContext("import_array", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":983 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":981 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -3524,16 +3690,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":984 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":982 * cdef inline int import_array() except -1: * try: * __pyx_import_array() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.multiarray failed to import") */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 984, __pyx_L3_error) + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 982, __pyx_L3_error) - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":983 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":981 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -3547,7 +3713,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":985 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":983 * try: * __pyx_import_array() * except Exception: # <<<<<<<<<<<<<< @@ -3557,27 +3723,27 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 985, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 983, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":986 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":984 * __pyx_import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 986, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 984, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 986, __pyx_L5_except_error) + __PYX_ERR(1, 984, __pyx_L5_except_error) } goto __pyx_L5_except_error; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":983 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":981 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -3593,7 +3759,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_L8_try_end:; } - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":982 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":980 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -3616,7 +3782,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":988 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":986 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -3638,9 +3804,9 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_umath", 0); + __Pyx_RefNannySetupContext("import_umath", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":989 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":987 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -3656,16 +3822,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":990 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":988 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 990, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 988, __pyx_L3_error) - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":989 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":987 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -3679,7 +3845,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":991 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":989 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -3689,27 +3855,27 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 991, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 989, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":992 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":990 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 992, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 990, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 992, __pyx_L5_except_error) + __PYX_ERR(1, 990, __pyx_L5_except_error) } goto __pyx_L5_except_error; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":989 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":987 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -3725,7 +3891,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_L8_try_end:; } - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":988 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":986 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -3748,7 +3914,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":994 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":992 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -3770,9 +3936,9 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_ufunc", 0); + __Pyx_RefNannySetupContext("import_ufunc", 1); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":995 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":993 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -3788,16 +3954,16 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":996 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":994 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 996, __pyx_L3_error) + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 994, __pyx_L3_error) - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":995 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":993 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -3811,7 +3977,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":997 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":995 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -3821,27 +3987,27 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 997, __pyx_L5_except_error) + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 995, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":998 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":996 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 998, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 996, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 998, __pyx_L5_except_error) + __PYX_ERR(1, 996, __pyx_L5_except_error) } goto __pyx_L5_except_error; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":995 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":993 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -3857,7 +4023,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_L8_try_end:; } - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":994 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":992 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -3880,7 +4046,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1001 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":999 * * * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< @@ -3890,10 +4056,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) { int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_timedelta64_object", 0); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1013 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1011 * bool * """ * return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) # <<<<<<<<<<<<<< @@ -3903,7 +4067,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_ __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type)); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1001 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":999 * * * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< @@ -3913,11 +4077,10 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_ /* function exit code */ __pyx_L0:; - __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1016 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1014 * * * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< @@ -3927,10 +4090,8 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) { int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_datetime64_object", 0); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1028 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1026 * bool * """ * return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) # <<<<<<<<<<<<<< @@ -3940,7 +4101,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_o __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type)); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1016 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1014 * * * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< @@ -3950,11 +4111,10 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_o /* function exit code */ __pyx_L0:; - __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1031 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1029 * * * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -3965,7 +4125,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_o static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) { npy_datetime __pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1038 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1036 * also needed. That can be found using `get_datetime64_unit`. * """ * return (obj).obval # <<<<<<<<<<<<<< @@ -3975,7 +4135,7 @@ static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject * __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval; goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1031 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1029 * * * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -3988,7 +4148,7 @@ static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject * return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1041 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1039 * * * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -3999,7 +4159,7 @@ static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject * static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) { npy_timedelta __pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1045 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1043 * returns the int64 value underlying scalar numpy timedelta64 object * """ * return (obj).obval # <<<<<<<<<<<<<< @@ -4009,7 +4169,7 @@ static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval; goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1041 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1039 * * * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -4022,7 +4182,7 @@ static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject return __pyx_r; } -/* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1048 +/* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1046 * * * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< @@ -4033,7 +4193,7 @@ static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) { NPY_DATETIMEUNIT __pyx_r; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1052 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1050 * returns the unit part of the dtype for a numpy datetime64 object. * """ * return (obj).obmeta.base # <<<<<<<<<<<<<< @@ -4041,7 +4201,7 @@ static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObjec __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base); goto __pyx_L0; - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":1048 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":1046 * * * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< @@ -4082,18 +4242,26 @@ PyObject *__pyx_args, PyObject *__pyx_kwds PyArrayObject *__pyx_v_idx = 0; PyArrayObject *__pyx_v_toadd = 0; #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_at_64 (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_MACROS + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_idx,&__pyx_n_s_toadd,0}; - PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { @@ -4109,19 +4277,28 @@ PyObject *__pyx_args, PyObject *__pyx_kwds kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: - if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_idx)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_idx)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("add_at_64", 1, 3, 3, 1); __PYX_ERR(0, 9, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: - if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_toadd)) != 0)) kw_args--; + if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_toadd)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("add_at_64", 1, 3, 3, 2); __PYX_ERR(0, 9, __pyx_L3_error) @@ -4142,10 +4319,18 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __pyx_v_idx = ((PyArrayObject *)values[1]); __pyx_v_toadd = ((PyArrayObject *)values[2]); } - goto __pyx_L4_argument_unpacking_done; + goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("add_at_64", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 9, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } __Pyx_AddTraceback("rainforest.common.add_at.add_at_64", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; @@ -4160,6 +4345,12 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -4195,7 +4386,7 @@ static PyObject *__pyx_pf_10rainforest_6common_6add_at_add_at_64(CYTHON_UNUSED P int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("add_at_64", 0); + __Pyx_RefNannySetupContext("add_at_64", 1); __pyx_pybuffer_arr.pybuffer.buf = NULL; __pyx_pybuffer_arr.refcount = 0; __pyx_pybuffernd_arr.data = NULL; @@ -4231,7 +4422,7 @@ static PyObject *__pyx_pf_10rainforest_6common_6add_at_add_at_64(CYTHON_UNUSED P * for k in range(N): * arr[idx[0,k],idx[1,k]] = arr[idx[0,k],idx[1,k]] + toadd[k] */ - __pyx_t_1 = __pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_toadd)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 13, __pyx_L1_error) + __pyx_t_1 = __pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_toadd)); if (unlikely(__pyx_t_1 == ((npy_intp *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 13, __pyx_L1_error) __pyx_v_N = (__pyx_t_1[0]); /* "rainforest/common/add_at.pyx":14 @@ -4340,18 +4531,26 @@ PyObject *__pyx_args, PyObject *__pyx_kwds PyArrayObject *__pyx_v_idx = 0; PyArrayObject *__pyx_v_toadd = 0; #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_at_32 (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_MACROS + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_idx,&__pyx_n_s_toadd,0}; - PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { @@ -4367,19 +4566,28 @@ PyObject *__pyx_args, PyObject *__pyx_kwds kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: - if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_idx)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_idx)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("add_at_32", 1, 3, 3, 1); __PYX_ERR(0, 18, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: - if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_toadd)) != 0)) kw_args--; + if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_toadd)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("add_at_32", 1, 3, 3, 2); __PYX_ERR(0, 18, __pyx_L3_error) @@ -4400,10 +4608,18 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __pyx_v_idx = ((PyArrayObject *)values[1]); __pyx_v_toadd = ((PyArrayObject *)values[2]); } - goto __pyx_L4_argument_unpacking_done; + goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("add_at_32", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 18, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } __Pyx_AddTraceback("rainforest.common.add_at.add_at_32", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; @@ -4418,6 +4634,12 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -4454,7 +4676,7 @@ static PyObject *__pyx_pf_10rainforest_6common_6add_at_2add_at_32(CYTHON_UNUSED int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("add_at_32", 0); + __Pyx_RefNannySetupContext("add_at_32", 1); __pyx_pybuffer_arr.pybuffer.buf = NULL; __pyx_pybuffer_arr.refcount = 0; __pyx_pybuffernd_arr.data = NULL; @@ -4490,7 +4712,7 @@ static PyObject *__pyx_pf_10rainforest_6common_6add_at_2add_at_32(CYTHON_UNUSED * for k in range(N): * arr[idx[0,k],idx[1,k]] = arr[idx[0,k],idx[1,k]] + toadd[k] */ - __pyx_t_1 = __pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_toadd)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 20, __pyx_L1_error) + __pyx_t_1 = __pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_toadd)); if (unlikely(__pyx_t_1 == ((npy_intp *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 20, __pyx_L1_error) __pyx_v_N = (__pyx_t_1[0]); /* "rainforest/common/add_at.pyx":21 @@ -4686,18 +4908,26 @@ PyObject *__pyx_args, PyObject *__pyx_kwds PyArrayObject *__pyx_v_idx = 0; PyArrayObject *__pyx_v_toadd = 0; #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_at_int (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_MACROS + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_idx,&__pyx_n_s_toadd,0}; - PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { @@ -4713,19 +4943,28 @@ PyObject *__pyx_args, PyObject *__pyx_kwds kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: - if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_idx)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_idx)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("add_at_int", 1, 3, 3, 1); __PYX_ERR(0, 25, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: - if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_toadd)) != 0)) kw_args--; + if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_toadd)) != 0)) { + (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); + kw_args--; + } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("add_at_int", 1, 3, 3, 2); __PYX_ERR(0, 25, __pyx_L3_error) @@ -4746,10 +4985,18 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __pyx_v_idx = ((PyArrayObject *)values[1]); __pyx_v_toadd = ((PyArrayObject *)values[2]); } - goto __pyx_L4_argument_unpacking_done; + goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("add_at_int", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 25, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } __Pyx_AddTraceback("rainforest.common.add_at.add_at_int", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; @@ -4764,6 +5011,12 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; + { + Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); + } + } __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -4800,7 +5053,7 @@ static PyObject *__pyx_pf_10rainforest_6common_6add_at_4add_at_int(CYTHON_UNUSED int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("add_at_int", 0); + __Pyx_RefNannySetupContext("add_at_int", 1); __pyx_pybuffer_arr.pybuffer.buf = NULL; __pyx_pybuffer_arr.refcount = 0; __pyx_pybuffernd_arr.data = NULL; @@ -4836,7 +5089,7 @@ static PyObject *__pyx_pf_10rainforest_6common_6add_at_4add_at_int(CYTHON_UNUSED * for k in range(N): * arr[idx[0,k],idx[1,k]] = arr[idx[0,k],idx[1,k]] + toadd[k] */ - __pyx_t_1 = __pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_toadd)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L1_error) + __pyx_t_1 = __pyx_f_5numpy_7ndarray_5shape_shape(((PyArrayObject *)__pyx_v_toadd)); if (unlikely(__pyx_t_1 == ((npy_intp *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L1_error) __pyx_v_N = (__pyx_t_1[0]); /* "rainforest/common/add_at.pyx":28 @@ -5050,7 +5303,7 @@ static int __Pyx_CreateStringTabAndInitStrings(void) { /* #### Code section: cached_builtins ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 14, __pyx_L1_error) - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 986, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 984, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -5061,25 +5314,25 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":986 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":984 * __pyx_import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 986, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "../../../store/msrad/utils/anaconda3-wolfensb/envs/rainforest_tests/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd":992 + /* "../../../tmp/pip-build-env-c4ocyr9s/overlay/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd":990 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 992, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); @@ -5137,7 +5390,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { * numpy._import_array */ #ifdef NPY_FEATURE_VERSION -#if !NO_IMPORT_ARRAY +#ifndef NO_IMPORT_ARRAY if (unlikely(_import_array() == -1)) { PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import " "(auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; " @@ -5204,33 +5457,33 @@ static int __Pyx_modinit_type_import_code(void) { /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_0_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_0_10(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 - sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyTypeObject), + sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyTypeObject), #elif CYTHON_COMPILING_IN_LIMITED_API - sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyTypeObject), + sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyTypeObject), #else - sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyHeapTypeObject), + sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyHeapTypeObject), #endif - __Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) + __Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_5numpy_dtype = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyArray_Descr),__Pyx_ImportType_CheckSize_Ignore_3_0_0); if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 202, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyArrayIterObject),__Pyx_ImportType_CheckSize_Ignore_3_0_0); if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 225, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyArrayMultiIterObject),__Pyx_ImportType_CheckSize_Ignore_3_0_0); if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 229, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyArrayObject),__Pyx_ImportType_CheckSize_Ignore_3_0_0); if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 238, __pyx_L1_error) - __pyx_ptype_5numpy_generic = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_generic) __PYX_ERR(1, 812, __pyx_L1_error) - __pyx_ptype_5numpy_number = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "number", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_number) __PYX_ERR(1, 814, __pyx_L1_error) - __pyx_ptype_5numpy_integer = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_integer) __PYX_ERR(1, 816, __pyx_L1_error) - __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(1, 818, __pyx_L1_error) - __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(1, 820, __pyx_L1_error) - __pyx_ptype_5numpy_inexact = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(1, 822, __pyx_L1_error) - __pyx_ptype_5numpy_floating = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_floating) __PYX_ERR(1, 824, __pyx_L1_error) - __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(1, 826, __pyx_L1_error) - __pyx_ptype_5numpy_flexible = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(1, 828, __pyx_L1_error) - __pyx_ptype_5numpy_character = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "character", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_0); if (!__pyx_ptype_5numpy_character) __PYX_ERR(1, 830, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType_3_0_0(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_0(PyUFuncObject),__Pyx_ImportType_CheckSize_Ignore_3_0_0); if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 868, __pyx_L1_error) + __pyx_ptype_5numpy_dtype = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyArray_Descr),__Pyx_ImportType_CheckSize_Ignore_3_0_10); if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 202, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyArrayIterObject),__Pyx_ImportType_CheckSize_Ignore_3_0_10); if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 225, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyArrayMultiIterObject),__Pyx_ImportType_CheckSize_Ignore_3_0_10); if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 229, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyArrayObject),__Pyx_ImportType_CheckSize_Ignore_3_0_10); if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 238, __pyx_L1_error) + __pyx_ptype_5numpy_generic = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_generic) __PYX_ERR(1, 809, __pyx_L1_error) + __pyx_ptype_5numpy_number = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "number", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_number) __PYX_ERR(1, 811, __pyx_L1_error) + __pyx_ptype_5numpy_integer = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_integer) __PYX_ERR(1, 813, __pyx_L1_error) + __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(1, 815, __pyx_L1_error) + __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(1, 817, __pyx_L1_error) + __pyx_ptype_5numpy_inexact = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(1, 819, __pyx_L1_error) + __pyx_ptype_5numpy_floating = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_floating) __PYX_ERR(1, 821, __pyx_L1_error) + __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(1, 823, __pyx_L1_error) + __pyx_ptype_5numpy_flexible = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(1, 825, __pyx_L1_error) + __pyx_ptype_5numpy_character = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "character", sizeof(PyObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyObject),__Pyx_ImportType_CheckSize_Warn_3_0_10); if (!__pyx_ptype_5numpy_character) __PYX_ERR(1, 827, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType_3_0_10(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_10(PyUFuncObject),__Pyx_ImportType_CheckSize_Ignore_3_0_10); if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 866, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; @@ -5444,7 +5697,7 @@ static CYTHON_SMALL_CODE int __pyx_pymod_exec_add_at(PyObject *__pyx_pyinit_modu __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) { int add_module_result = PyState_AddModule(__pyx_t_1, &__pyx_moduledef); - __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to add_at pseudovariable */ + __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "add_at" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } @@ -5456,10 +5709,8 @@ static CYTHON_SMALL_CODE int __pyx_pymod_exec_add_at(PyObject *__pyx_pyinit_modu CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_b); - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_cython_runtime); + __pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_cython_runtime = __Pyx_PyImport_AddModuleRef((const char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); @@ -5471,7 +5722,7 @@ if (!__Pyx_RefNanny) { } #endif __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_add_at(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); #endif @@ -5718,6 +5969,8 @@ static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObjec tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); + Py_XDECREF(type); + Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; @@ -5775,14 +6028,20 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject #endif /* PyObjectGetAttrStrNoError */ +#if __PYX_LIMITED_VERSION_HEX < 0x030d00A1 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } +#endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; +#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 + (void) PyObject_GetOptionalAttr(obj, attr_name, &result); + return result; +#else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { @@ -5794,6 +6053,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, P __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; +#endif } /* GetBuiltinName */ @@ -5994,8 +6254,13 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg ternaryfunc call = Py_TYPE(func)->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); + #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; + #else + if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) + return NULL; + #endif result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { @@ -6367,12 +6632,30 @@ static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyO { int eq = __Pyx_PyUnicode_Equals(s, PyTuple_GET_ITEM(kwnames, i), Py_EQ); if (unlikely(eq != 0)) { - if (unlikely(eq < 0)) return NULL; // error + if (unlikely(eq < 0)) return NULL; return kwvalues[i]; } } - return NULL; // not found (no exception set) + return NULL; } +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 +CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { + Py_ssize_t i, nkwargs = PyTuple_GET_SIZE(kwnames); + PyObject *dict; + dict = PyDict_New(); + if (unlikely(!dict)) + return NULL; + for (i=0; i= PyTuple_GET_SIZE(kwds)) break; + Py_ssize_t size; +#if CYTHON_ASSUME_SAFE_MACROS + size = PyTuple_GET_SIZE(kwds); +#else + size = PyTuple_Size(kwds); + if (size < 0) goto bad; +#endif + if (pos >= size) break; +#if CYTHON_AVOID_BORROWED_REFS + key = __Pyx_PySequence_ITEM(kwds, pos); + if (!key) goto bad; +#elif CYTHON_ASSUME_SAFE_MACROS key = PyTuple_GET_ITEM(kwds, pos); +#else + key = PyTuple_GetItem(kwds, pos); + if (!key) goto bad; +#endif value = kwvalues[pos]; pos++; } else { if (!PyDict_Next(kwds, &pos, &key, &value)) break; +#if CYTHON_AVOID_BORROWED_REFS + Py_INCREF(key); +#endif } name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; +#if CYTHON_AVOID_BORROWED_REFS + Py_INCREF(value); + Py_DECREF(key); +#endif + key = NULL; + value = NULL; continue; } +#if !CYTHON_AVOID_BORROWED_REFS + Py_INCREF(key); +#endif + Py_INCREF(value); name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_Check(key))) { @@ -6454,6 +6767,9 @@ static int __Pyx_ParseOptionalKeywords( if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; +#if CYTHON_AVOID_BORROWED_REFS + value = NULL; +#endif break; } name++; @@ -6483,6 +6799,9 @@ static int __Pyx_ParseOptionalKeywords( if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; +#if CYTHON_AVOID_BORROWED_REFS + value = NULL; +#endif break; } name++; @@ -6509,6 +6828,8 @@ static int __Pyx_ParseOptionalKeywords( goto invalid_keyword; } } + Py_XDECREF(key); + Py_XDECREF(value); return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); @@ -6528,6 +6849,8 @@ static int __Pyx_ParseOptionalKeywords( function_name, key); #endif bad: + Py_XDECREF(key); + Py_XDECREF(value); return -1; } @@ -6894,7 +7217,7 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { ctx->is_complex = 0; return 0; } -static PyObject * +static int __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) { const char *ts = *tsp; @@ -6903,9 +7226,9 @@ __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) if (ctx->new_count != 1) { PyErr_SetString(PyExc_ValueError, "Cannot handle repeated arrays in format string"); - return NULL; + return -1; } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return -1; ndim = ctx->head->field->type->ndim; while (*ts && *ts != ')') { switch (*ts) { @@ -6913,29 +7236,35 @@ __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) default: break; } number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, + if (number == -1) return -1; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) { + PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %d", ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, + return -1; + } + if (*ts != ',' && *ts != ')') { + PyErr_Format(PyExc_ValueError, "Expected a comma in format string, got '%c'", *ts); + return -1; + } if (*ts == ',') ts++; i++; } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + if (i != ndim) { + PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", ctx->head->field->type->ndim, i); + return -1; + } if (!*ts) { PyErr_SetString(PyExc_ValueError, "Unexpected end of format string, expected ')'"); - return NULL; + return -1; } ctx->is_valid_array = 1; ctx->new_count = 1; *tsp = ++ts; - return Py_None; + return 0; } static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { int got_Z = 0; @@ -7061,7 +7390,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha ++ts; break; case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + if (__pyx_buffmt_parse_array(ctx, &ts) < 0) return NULL; break; default: { @@ -7127,10 +7456,10 @@ fail:; } /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType_3_0_0 -#define __PYX_HAVE_RT_ImportType_3_0_0 -static PyTypeObject *__Pyx_ImportType_3_0_0(PyObject *module, const char *module_name, const char *class_name, - size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_0 check_size) + #ifndef __PYX_HAVE_RT_ImportType_3_0_10 +#define __PYX_HAVE_RT_ImportType_3_0_10 +static PyTypeObject *__Pyx_ImportType_3_0_10(PyObject *module, const char *module_name, const char *class_name, + size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_10 check_size) { PyObject *result = 0; char warning[200]; @@ -7184,7 +7513,7 @@ static PyTypeObject *__Pyx_ImportType_3_0_0(PyObject *module, const char *module module_name, class_name, size, basicsize+itemsize); goto bad; } - if (check_size == __Pyx_ImportType_CheckSize_Error_3_0_0 && + if (check_size == __Pyx_ImportType_CheckSize_Error_3_0_10 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " @@ -7192,7 +7521,7 @@ static PyTypeObject *__Pyx_ImportType_3_0_0(PyObject *module, const char *module module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } - else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_0_0 && (size_t)basicsize > size) { + else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_0_10 && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", @@ -7229,14 +7558,9 @@ static PyTypeObject *__Pyx_ImportType_3_0_0(PyObject *module, const char *module { #if PY_MAJOR_VERSION >= 3 if (level == -1) { - if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { - #if CYTHON_COMPILING_IN_LIMITED_API - module = PyImport_ImportModuleLevelObject( - name, empty_dict, empty_dict, from_list, 1); - #else + if (strchr(__Pyx_MODULE_NAME, '.') != NULL) { module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, 1); - #endif if (unlikely(!module)) { if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) goto bad; @@ -7255,14 +7579,9 @@ static PyTypeObject *__Pyx_ImportType_3_0_0(PyObject *module, const char *module name, __pyx_d, empty_dict, from_list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else - #if CYTHON_COMPILING_IN_LIMITED_API - module = PyImport_ImportModuleLevelObject( - name, empty_dict, empty_dict, from_list, level); - #else module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, level); #endif - #endif } } bad: @@ -7477,10 +7796,7 @@ static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject /* FetchSharedCythonModule */ static PyObject *__Pyx_FetchSharedCythonABIModule(void) { - PyObject *abi_module = PyImport_AddModule((char*) __PYX_ABI_MODULE_NAME); - if (unlikely(!abi_module)) return NULL; - Py_INCREF(abi_module); - return abi_module; + return __Pyx_PyImport_AddModuleRef((char*) __PYX_ABI_MODULE_NAME); } /* FetchCommonType */ @@ -7641,8 +7957,22 @@ static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, _ #endif /* CythonFunctionShared */ - static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { -#if PY_VERSION_HEX < 0x030900B1 + #if CYTHON_COMPILING_IN_LIMITED_API +static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { + if (__Pyx_CyFunction_Check(func)) { + return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; + } else if (PyCFunction_Check(func)) { + return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; + } + return 0; +} +#else +static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { + return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; +} +#endif +static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API __Pyx_Py_XDECREF_SET( __Pyx_CyFunction_GetClassObj(f), ((classobj) ? __Pyx_NewRef(classobj) : NULL)); @@ -7657,6 +7987,10 @@ __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) { CYTHON_UNUSED_VAR(closure); if (unlikely(op->func_doc == NULL)) { +#if CYTHON_COMPILING_IN_LIMITED_API + op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); + if (unlikely(!op->func_doc)) return NULL; +#else if (((PyCFunctionObject*)op)->m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); @@ -7669,6 +8003,7 @@ __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) Py_INCREF(Py_None); return Py_None; } +#endif } Py_INCREF(op->func_doc); return op->func_doc; @@ -7689,7 +8024,9 @@ __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_name == NULL)) { -#if PY_MAJOR_VERSION >= 3 +#if CYTHON_COMPILING_IN_LIMITED_API + op->func_name = PyObject_GetAttrString(op->func, "__name__"); +#elif PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #else op->func_name = PyString_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); @@ -7808,10 +8145,10 @@ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else - op->defaults_tuple = PySequence_ITEM(res, 0); + op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { - op->defaults_kwdict = PySequence_ITEM(res, 1); + op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif @@ -7920,7 +8257,15 @@ __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { fromlist = PyList_New(1); if (unlikely(!fromlist)) return NULL; Py_INCREF(marker); +#if CYTHON_ASSUME_SAFE_MACROS PyList_SET_ITEM(fromlist, 0, marker); +#else + if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { + Py_DECREF(marker); + Py_DECREF(fromlist); + return NULL; + } +#endif module = PyImport_ImportModuleLevelObject(__pyx_n_s_asyncio_coroutines, NULL, NULL, fromlist, 0); Py_DECREF(fromlist); if (unlikely(!module)) goto ignore; @@ -7936,6 +8281,18 @@ __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { op->func_is_coroutine = __Pyx_PyBool_FromLong(is_coroutine); return __Pyx_NewRef(op->func_is_coroutine); } +#if CYTHON_COMPILING_IN_LIMITED_API +static PyObject * +__Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { + CYTHON_UNUSED_VAR(context); + return PyObject_GetAttrString(op->func, "__module__"); +} +static int +__Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { + CYTHON_UNUSED_VAR(context); + return PyObject_SetAttrString(op->func, "__module__", value); +} +#endif static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, @@ -7955,20 +8312,27 @@ static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {(char *) "_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, +#if CYTHON_COMPILING_IN_LIMITED_API + {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, +#endif {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { +#if !CYTHON_COMPILING_IN_LIMITED_API {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, +#endif #if CYTHON_USE_TYPE_SPECS {(char *) "__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, #if CYTHON_METH_FASTCALL #if CYTHON_BACKPORT_VECTORCALL {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, #else +#if !CYTHON_COMPILING_IN_LIMITED_API {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, #endif #endif -#if PY_VERSION_HEX < 0x030500A0 +#endif +#if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, #else {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, @@ -7991,30 +8355,40 @@ static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; -#if PY_VERSION_HEX < 0x030500A0 +#if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { +#if !CYTHON_COMPILING_IN_LIMITED_API PyCFunctionObject *cf = (PyCFunctionObject*) op; +#endif if (unlikely(op == NULL)) return NULL; +#if CYTHON_COMPILING_IN_LIMITED_API + op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); + if (unlikely(!op->func)) return NULL; +#endif op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; +#if !CYTHON_COMPILING_IN_LIMITED_API cf->m_ml = ml; cf->m_self = (PyObject *) op; +#endif Py_XINCREF(closure); op->func_closure = closure; +#if !CYTHON_COMPILING_IN_LIMITED_API Py_XINCREF(module); cf->m_module = module; +#endif op->func_dict = NULL; op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; -#if PY_VERSION_HEX < 0x030900B1 +#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API op->func_classobj = NULL; #else ((PyCMethodObject*)op)->mm_class = NULL; @@ -8060,13 +8434,18 @@ static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); +#if CYTHON_COMPILING_IN_LIMITED_API + Py_CLEAR(m->func); +#else Py_CLEAR(((PyCFunctionObject*)m)->m_module); +#endif Py_CLEAR(m->func_dict); Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); +#if !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x030900B1 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); #else @@ -8075,6 +8454,7 @@ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) ((PyCMethodObject *) (m))->mm_class = NULL; Py_XDECREF(cls); } +#endif #endif Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); @@ -8105,14 +8485,20 @@ static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); +#if CYTHON_COMPILING_IN_LIMITED_API + Py_VISIT(m->func); +#else Py_VISIT(((PyCFunctionObject*)m)->m_module); +#endif Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); Py_VISIT(m->func_code); +#if !CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); +#endif Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); Py_VISIT(m->func_is_coroutine); @@ -8136,10 +8522,22 @@ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) #endif } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { +#if CYTHON_COMPILING_IN_LIMITED_API + PyObject *f = ((__pyx_CyFunctionObject*)func)->func; + PyObject *py_name = NULL; + PyCFunction meth; + int flags; + meth = PyCFunction_GetFunction(f); + if (unlikely(!meth)) return NULL; + flags = PyCFunction_GetFlags(f); + if (unlikely(flags < 0)) return NULL; +#else PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; + int flags = f->m_ml->ml_flags; +#endif Py_ssize_t size; - switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { + switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); @@ -8148,24 +8546,43 @@ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, Py return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { +#if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(arg); +#else + size = PyTuple_Size(arg); + if (unlikely(size < 0)) return NULL; +#endif if (likely(size == 0)) return (*meth)(self, NULL); +#if CYTHON_COMPILING_IN_LIMITED_API + py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); + if (!py_name) return NULL; + PyErr_Format(PyExc_TypeError, + "%.200S() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + py_name, size); + Py_DECREF(py_name); +#else PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); +#endif return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { +#if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(arg); +#else + size = PyTuple_Size(arg); + if (unlikely(size < 0)) return NULL; +#endif if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else - arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; + arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) @@ -8173,9 +8590,18 @@ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, Py #endif return result; } +#if CYTHON_COMPILING_IN_LIMITED_API + py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); + if (!py_name) return NULL; + PyErr_Format(PyExc_TypeError, + "%.200S() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + py_name, size); + Py_DECREF(py_name); +#else PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); +#endif return NULL; } break; @@ -8183,12 +8609,28 @@ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, Py PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); return NULL; } +#if CYTHON_COMPILING_IN_LIMITED_API + py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); + if (!py_name) return NULL; + PyErr_Format(PyExc_TypeError, "%.200S() takes no keyword arguments", + py_name); + Py_DECREF(py_name); +#else PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); +#endif return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { - return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); + PyObject *self, *result; +#if CYTHON_COMPILING_IN_LIMITED_API + self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); + if (unlikely(!self) && PyErr_Occurred()) return NULL; +#else + self = ((PyCFunctionObject*)func)->m_self; +#endif + result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); + return result; } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; @@ -8208,7 +8650,12 @@ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, P Py_ssize_t argc; PyObject *new_args; PyObject *self; +#if CYTHON_ASSUME_SAFE_MACROS argc = PyTuple_GET_SIZE(args); +#else + argc = PyTuple_Size(args); + if (unlikely(!argc) < 0) return NULL; +#endif new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; @@ -8333,7 +8780,7 @@ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, default: return NULL; } - return ((_PyCFunctionFastWithKeywords)(void(*)(void))def->ml_meth)(self, args, nargs, kwnames); + return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))def->ml_meth)(self, args, nargs, kwnames); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { @@ -8421,7 +8868,7 @@ static PyTypeObject __pyx_CyFunctionType_type = { #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif -#ifdef _Py_TPFLAGS_HAVE_VECTORCALL +#if defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL _Py_TPFLAGS_HAVE_VECTORCALL | #endif Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, @@ -8679,20 +9126,93 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { #include "compile.h" #include "frameobject.h" #include "traceback.h" -#if PY_VERSION_HEX >= 0x030b00a6 +#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API +static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, + PyObject *firstlineno, PyObject *name) { + PyObject *replace = NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; + replace = PyObject_GetAttrString(code, "replace"); + if (likely(replace)) { + PyObject *result; + result = PyObject_Call(replace, __pyx_empty_tuple, scratch_dict); + Py_DECREF(replace); + return result; + } + PyErr_Clear(); + #if __PYX_LIMITED_VERSION_HEX < 0x030780000 + { + PyObject *compiled = NULL, *result = NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "code", code))) return NULL; + if (unlikely(PyDict_SetItemString(scratch_dict, "type", (PyObject*)(&PyType_Type)))) return NULL; + compiled = Py_CompileString( + "out = type(code)(\n" + " code.co_argcount, code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize,\n" + " code.co_flags, code.co_code, code.co_consts, code.co_names,\n" + " code.co_varnames, code.co_filename, co_name, co_firstlineno,\n" + " code.co_lnotab)\n", "", Py_file_input); + if (!compiled) return NULL; + result = PyEval_EvalCode(compiled, scratch_dict, scratch_dict); + Py_DECREF(compiled); + if (!result) PyErr_Print(); + Py_DECREF(result); + result = PyDict_GetItemString(scratch_dict, "out"); + if (result) Py_INCREF(result); + return result; + } + #else + return NULL; + #endif +} static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { + PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; + PyObject *replace = NULL, *getframe = NULL, *frame = NULL; + PyObject *exc_type, *exc_value, *exc_traceback; + int success = 0; if (c_line) { (void) __pyx_cfilenm; (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } - _PyTraceback_Add(funcname, filename, py_line); + PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); + code_object = Py_CompileString("_getframe()", filename, Py_eval_input); + if (unlikely(!code_object)) goto bad; + py_py_line = PyLong_FromLong(py_line); + if (unlikely(!py_py_line)) goto bad; + py_funcname = PyUnicode_FromString(funcname); + if (unlikely(!py_funcname)) goto bad; + dict = PyDict_New(); + if (unlikely(!dict)) goto bad; + { + PyObject *old_code_object = code_object; + code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); + Py_DECREF(old_code_object); + } + if (unlikely(!code_object)) goto bad; + getframe = PySys_GetObject("_getframe"); + if (unlikely(!getframe)) goto bad; + if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; + frame = PyEval_EvalCode(code_object, dict, dict); + if (unlikely(!frame) || frame == Py_None) goto bad; + success = 1; + bad: + PyErr_Restore(exc_type, exc_value, exc_traceback); + Py_XDECREF(code_object); + Py_XDECREF(py_py_line); + Py_XDECREF(py_funcname); + Py_XDECREF(dict); + Py_XDECREF(replace); + if (success) { + PyTraceBack_Here( + (struct _frame*)frame); + } + Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -8745,7 +9265,7 @@ static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( #else py_code = PyCode_NewEmpty(filename, funcname, py_line); #endif - Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline + Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); @@ -9182,8 +9702,34 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; +#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); +#else + PyObject *from_bytes, *result = NULL; + PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; + from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); + if (!from_bytes) return NULL; + py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int)); + if (!py_bytes) goto limited_bad; + order_str = PyUnicode_FromString(little ? "little" : "big"); + if (!order_str) goto limited_bad; + arg_tuple = PyTuple_Pack(2, py_bytes, order_str); + if (!arg_tuple) goto limited_bad; + if (!is_unsigned) { + kwds = PyDict_New(); + if (!kwds) goto limited_bad; + if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; + } + result = PyObject_Call(from_bytes, arg_tuple, kwds); + limited_bad: + Py_XDECREF(kwds); + Py_XDECREF(arg_tuple); + Py_XDECREF(order_str); + Py_XDECREF(py_bytes); + Py_XDECREF(from_bytes); + return result; +#endif } } @@ -9357,7 +9903,7 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { #endif if (likely(v)) { int ret = -1; -#if !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) +#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, @@ -9469,7 +10015,8 @@ __Pyx_PyType_GetName(PyTypeObject* tp) __pyx_n_s_name); if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) { PyErr_Clear(); - Py_XSETREF(name, __Pyx_NewRef(__pyx_n_s__8)); + Py_XDECREF(name); + name = __Pyx_NewRef(__pyx_n_s__8); } return name; } @@ -9508,8 +10055,34 @@ __Pyx_PyType_GetName(PyTypeObject* tp) { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; +#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); +#else + PyObject *from_bytes, *result = NULL; + PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; + from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); + if (!from_bytes) return NULL; + py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); + if (!py_bytes) goto limited_bad; + order_str = PyUnicode_FromString(little ? "little" : "big"); + if (!order_str) goto limited_bad; + arg_tuple = PyTuple_Pack(2, py_bytes, order_str); + if (!arg_tuple) goto limited_bad; + if (!is_unsigned) { + kwds = PyDict_New(); + if (!kwds) goto limited_bad; + if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; + } + result = PyObject_Call(from_bytes, arg_tuple, kwds); + limited_bad: + Py_XDECREF(kwds); + Py_XDECREF(arg_tuple); + Py_XDECREF(order_str); + Py_XDECREF(py_bytes); + Py_XDECREF(from_bytes); + return result; +#endif } } @@ -9683,7 +10256,7 @@ __Pyx_PyType_GetName(PyTypeObject* tp) #endif if (likely(v)) { int ret = -1; -#if !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) +#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, @@ -9903,41 +10476,50 @@ static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObj #endif /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { - char ctversion[5]; - int same=1, i, found_dot; - const char* rt_from_call = Py_GetVersion(); - PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - found_dot = 0; - for (i = 0; i < 4; i++) { - if (!ctversion[i]) { - same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); - break; + static unsigned long __Pyx_get_runtime_version(void) { +#if __PYX_LIMITED_VERSION_HEX >= 0x030B00A4 + return Py_Version & ~0xFFUL; +#else + const char* rt_version = Py_GetVersion(); + unsigned long version = 0; + unsigned long factor = 0x01000000UL; + unsigned int digit = 0; + int i = 0; + while (factor) { + while ('0' <= rt_version[i] && rt_version[i] <= '9') { + digit = digit * 10 + (unsigned int) (rt_version[i] - '0'); + ++i; } - if (rt_from_call[i] != ctversion[i]) { - same = 0; + version += factor * digit; + if (rt_version[i] != '.') break; - } + digit = 0; + factor >>= 8; + ++i; } - if (!same) { - char rtversion[5] = {'\0'}; + return version; +#endif +} +static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { + const unsigned long MAJOR_MINOR = 0xFFFF0000UL; + if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) + return 0; + if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) + return 1; + { char message[200]; - for (i=0; i<4; ++i) { - if (rt_from_call[i] == '.') { - if (found_dot) break; - found_dot = 1; - } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { - break; - } - rtversion[i] = rt_from_call[i]; - } PyOS_snprintf(message, sizeof(message), - "compile time version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); + "compile time Python version %d.%d " + "of module '%.100s' " + "%s " + "runtime version %d.%d", + (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), + __Pyx_MODULE_NAME, + (allow_newer) ? "was newer than" : "does not match", + (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) + ); return PyErr_WarnEx(NULL, message, 1); } - return 0; } /* InitStrings */ @@ -9983,8 +10565,24 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { return 0; } +#include +static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { + size_t len = strlen(s); + if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { + PyErr_SetString(PyExc_OverflowError, "byte string is too long"); + return -1; + } + return (Py_ssize_t) len; +} static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); + Py_ssize_t len = __Pyx_ssize_strlen(c_str); + if (unlikely(len < 0)) return NULL; + return __Pyx_PyUnicode_FromStringAndSize(c_str, len); +} +static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { + Py_ssize_t len = __Pyx_ssize_strlen(c_str); + if (unlikely(len < 0)) return NULL; + return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; diff --git a/rainforest/common/graphics.py b/rainforest/common/graphics.py index e3c6de2..bedc0fa 100644 --- a/rainforest/common/graphics.py +++ b/rainforest/common/graphics.py @@ -169,7 +169,7 @@ def qpe_plot(data, subplots = None, figsize = None, np.min(x),np.max(x)] for i,dd in enumerate(data): - m = ax[i].imshow(dd,vmin = vmin, vmax = vmax, extent = extent, + m = ax[i].imshow(dd, extent = extent, cmap = cmap_qpe, norm = norm, **kwargs) if ch_border: diff --git a/rainforest/common/radarprocessing.py b/rainforest/common/radarprocessing.py index 18f32c0..7391b4b 100644 --- a/rainforest/common/radarprocessing.py +++ b/rainforest/common/radarprocessing.py @@ -36,7 +36,7 @@ class Radar(object): single pyart radar instance as this was found to be faster in practice ''' def __init__(self, radname, polfiles, statusfile=None, vprfile=None, - temp_ref='TAIR', metranet_reader = 'python'): + temp_ref='TAIR', metranet_reader = 'C'): """ Creates an Radar class instance diff --git a/rainforest/common/retrieve_data.py b/rainforest/common/retrieve_data.py index d4b9632..6b6121a 100644 --- a/rainforest/common/retrieve_data.py +++ b/rainforest/common/retrieve_data.py @@ -124,7 +124,9 @@ def retrieve_hzt_RT(tstep): # Sort filelist to most recent prediction content_filt = np.array([c for c in content_zip if c.endswith('800')]) times_filt = np.array([datetime.datetime.strptime(c[3:12], - '%y%j%H%M')+datetime.timedelta(hours=int(c[-2::])) for c in content_filt]) + '%y%j%H%M').replace(tzinfo=datetime.timezone.utc)+\ + datetime.timedelta(hours=int(c[-2::])) \ + for c in content_filt]) conditions = np.array([np.logical_and((t >= start_time), (t <= end_time)) for t in times_filt]) content_filt = content_filt[conditions] @@ -139,7 +141,8 @@ def retrieve_hzt_RT(tstep): if len(all_hours) != len(times_filt): content_times = np.array([datetime.datetime.strptime(c[3:12], - '%y%j%H%M')+datetime.timedelta(hours=int(c[-2::])) for c in content_zip]) + '%y%j%H%M').replace(tzinfo=datetime.timezone.utc)+\ + datetime.timedelta(hours=int(c[-2::])) for c in content_zip]) # Find time that is missing: for hh in all_hours: if not hh in times_filt: @@ -571,7 +574,8 @@ def retrieve_prod_RT(time, product_name, # Derive datetime of each file times_zip = np.array([datetime.datetime.strptime(c[3:12], - '%y%j%H%M') for c in content_zip]) + '%y%j%H%M').replace(tzinfo=datetime.timezone.utc) + for c in content_zip]) # Get a list of all files to retrieve conditions = (times_zip == time) diff --git a/rainforest/common/utils.py b/rainforest/common/utils.py index 0f14cf5..6004266 100644 --- a/rainforest/common/utils.py +++ b/rainforest/common/utils.py @@ -12,6 +12,7 @@ # Global imports import datetime import io +import importlib.metadata as _importlib_metadata import os from collections import OrderedDict import numpy as np @@ -19,14 +20,27 @@ from dateutil import parser import glob import yaml +import dask +dask.config.set({'dataframe.query-planning': False}) import dask.dataframe as dd import re import numbers + # Local imports from .logger import logger from .wgs84_ch1903 import GPSConverter from . import constants +def get_version(): + # Get the version + try: + version = _importlib_metadata.version("rainforest_mch") + except _importlib_metadata.PackageNotFoundError: + # package is not installed + version = "0.0.0" + return version + + def hex_to_rgb(value): value = value.lstrip('#') lv = len(value) diff --git a/rainforest/database/retrieve_radar_data.py b/rainforest/database/retrieve_radar_data.py index 0334307..fdc443e 100644 --- a/rainforest/database/retrieve_radar_data.py +++ b/rainforest/database/retrieve_radar_data.py @@ -14,6 +14,8 @@ import numpy as np import pandas as pd +import dask +dask.config.set({'dataframe.query-planning': False}) import dask.dataframe as dd import datetime import logging diff --git a/rainforest/database/retrieve_reference_data.py b/rainforest/database/retrieve_reference_data.py index 988ba5b..7f5ac80 100644 --- a/rainforest/database/retrieve_reference_data.py +++ b/rainforest/database/retrieve_reference_data.py @@ -18,6 +18,8 @@ import pandas as pd import datetime import logging +import pyart +dask.config.set({'dataframe.query-planning': False}) import dask.dataframe as dd logging.basicConfig(level=logging.INFO) diff --git a/rainforest/ml/rf.py b/rainforest/ml/rf.py index 2f07f66..2047e66 100755 --- a/rainforest/ml/rf.py +++ b/rainforest/ml/rf.py @@ -5,6 +5,9 @@ """ # Global imports +from audioop import cross +import logging +logging.getLogger().setLevel(logging.INFO) import os import pickle import glob @@ -17,168 +20,14 @@ # Local imports from ..common import constants -from ..ml.utils import vert_aggregation, split_event, split_years -from ..ml.rfdefinitions import RandomForestRegressorBC, QuantileRandomForestRegressorBC, read_rf +from .utils import vert_aggregation, split_event, split_years +from .rfdefinitions import RandomForestRegressorBC from ..common.utils import perfscores, envyaml from ..common.graphics import plot_crossval_stats -from ..common.logger import logger - dir_path = os.path.dirname(os.path.realpath(__file__)) FOLDER_MODELS = Path(os.environ['RAINFOREST_DATAPATH'], 'rf_models') -def readInputData(input_location, tstart, tend, datalist=['gauge', 'radar', 'refer']): - - if 'gauge' in datalist: - gaugetab = pd.read_parquet(str(Path(input_location, 'gauge.parquet'))) - if 'radar' in datalist: - radartab = pd.read_parquet(str(Path(input_location, 'radar_x0y0.parquet'))) - if 'refer' in datalist: - refertab = pd.read_parquet(str(Path(input_location, 'reference_x0y0.parquet'))) - - grp = pickle.load(open(str(Path(input_location, 'grouping_idx_x0y0.p')),'rb')) - grp_hourly = grp['grp_hourly']; grp_vertical = grp['grp_vertical'] - - if tstart != None: - try: - tstart = datetime.datetime.strptime(tstart, - '%Y%m%d%H%M').replace(tzinfo=datetime.timezone.utc).timestamp() - except: - tstart = gaugetab['TIMESTAMP'].min() - logger.info('The format of tstart was wrong, taking the earliest date') - if tend != None: - try: - tend = datetime.datetime.strptime(tend, - '%Y%m%d%H%M').replace(tzinfo=datetime.timezone.utc).timestamp() - except: - tend = gaugetab['TIMESTAMP'].max() - logger.info('The format of tend was wrong, taking the earliest date') - - timevalid = gaugetab['TIMESTAMP'].copy().astype(bool) - vertvalid = radartab['TIMESTAMP'].copy().astype(bool) - - if (tstart != None): - timevalid[(gaugetab['TIMESTAMP'] < tstart)] = False - vertvalid[(radartab['TIMESTAMP'] < tstart)] = False - if (tend != None): - timevalid[(gaugetab['TIMESTAMP'] > tend)] = False - vertvalid[(radartab['TIMESTAMP'] > tend)] = False - - gaugetab = gaugetab[timevalid] - grp_hourly = grp_hourly[timevalid] - radartab = radartab[vertvalid] - grp_vertical = grp_vertical[vertvalid] - - if 'refer' in datalist: - refertab = refertab[timevalid] - return gaugetab, radartab, refertab, grp_hourly, grp_vertical - else: - return gaugetab, radartab, grp_hourly, grp_vertical - -def processFeatures(features_dic, radartab): - # currently the only supported additional features is zh (refl in linear units) - # and DIST_TO_RAD{A-D-L-W-P} (dist to individual radars) - # Get list of unique features names - if type(features_dic) == dict : - features = np.unique([item for sub in list(features_dic.values()) - for item in sub]) - else: - features = features_dic - - for f in features: - if 'zh' in f: - logger.info('Converting reflectivity {:s} from log [dBZ] to linear [mm^6 m^-3]'.format(f)) - try: - radartab[str(f)] = 10**(0.1 * radartab[f.replace('zh','ZH')+'_mean'].copy()) - except: - radartab[str(f)] = 10**(0.1 * radartab[f.replace('zh','ZH')].copy()) - elif 'zv' in f: - logger.info('Computing derived variable {:s}'.format(f)) - try: - radartab[str(f)] = 10**(0.1 * radartab[f.replace('zv','ZV')+'_mean'].copy()) - except: - radartab[str(f)] = 10**(0.1 * radartab[f.replace('zv','ZV')].copy()) - if 'DIST_TO_RAD' in f: - info_radar = constants.RADARS - vals = np.unique(radartab['RADAR']) - for val in vals: - dist = np.sqrt((radartab['X'] - info_radar['X'][val])**2+ - (radartab['Y'] - info_radar['Y'][val])**2) / 1000. - radartab['DIST_TO_RAD' + str(val)] = dist - - features = [str(f) for f in features] - - return radartab, features - -def getTempIDX(TempOBS, grp_hourly, test, train) : - - # Get reference values - T_test_60 = np.squeeze(np.array(pd.DataFrame(TempOBS[test]) - .groupby(grp_hourly[test]).mean())) - - T_train_60 = np.squeeze(np.array(pd.DataFrame(TempOBS[train]) - .groupby(grp_hourly[train]).mean())) - - # Dictionnary with all indices: - IDX = {} - - for tagg in ['10min', '60min']: - IDX[tagg] = {} - for data_type in ['test', 'train']: - IDX[tagg][data_type] = {} - for precip_type in ['all', 'liquid', 'solid']: - IDX[tagg][data_type][precip_type] = {} - - IDX['10min']['train']['liquid'] = TempOBS[train] >= constants.THRESHOLD_SOLID - IDX['10min']['train']['solid'] = TempOBS[train] < constants.THRESHOLD_SOLID - - IDX['60min']['train']['liquid'] = T_train_60 >= constants.THRESHOLD_SOLID - IDX['60min']['train']['solid'] = T_train_60 < constants.THRESHOLD_SOLID - - IDX['10min']['test']['liquid'] = TempOBS[test] >= constants.THRESHOLD_SOLID - IDX['10min']['test']['solid'] = TempOBS[test] < constants.THRESHOLD_SOLID - - IDX['60min']['test']['liquid'] = T_test_60 >= constants.THRESHOLD_SOLID - IDX['60min']['test']['solid'] = T_test_60 < constants.THRESHOLD_SOLID - - return IDX - - -def prepareScoreDic(modelnames, station_scores=True): - - all_scores = {'10min':{},'60min':{}} - all_stats = {'10min':{},'60min':{}} - - if station_scores == True: - all_station_scores = {'10min': {}, '60min': {}} - all_station_stats = {'10min': {}, '60min': {}} - - for tagg in ['10min', '60min']: - for model in modelnames: - all_scores[tagg][model] = {'train': {'solid':[],'liquid':[],'all':[]}, - 'test': {'solid':[],'liquid':[],'all':[]}} - all_stats[tagg][model] = {'train': {'solid':{},'liquid':{},'all':{}}, - 'test': {'solid':{},'liquid':{},'all':{}}} - if station_scores == True: - all_station_scores[tagg][model] = {'solid':{},'liquid':{},'all':{}} - all_station_stats[tagg][model] = {'solid':{},'liquid':{},'all':{}} - - if station_scores == False: - return all_scores, all_stats - else: - return all_scores, all_stats, all_station_scores, all_station_stats - -def calcScore(all_scores, obs, pred, idxTemp, bounds, - tagg = '10min', model='RFO', data_type='test'): - - for pp_type in all_scores[tagg][model][data_type].keys(): - idx = idxTemp[tagg][data_type][pp_type] - scores = perfscores(pred[idx], obs[idx], bounds=bounds) - all_scores[tagg][model][data_type][pp_type].append(scores) - - return all_scores - - class RFTraining(object): ''' This is the main class that allows to preparate data for random forest @@ -227,9 +76,9 @@ def __init__(self, db_location, input_location=None, self.db_location = db_location if not valid : - logger.info('Could not find valid input data from the folder {:s}'.format(input_location)) + logging.info('Could not find valid input data from the folder {:s}'.format(input_location)) # if force_regenerate_input or not valid: - # logger.info('The program will now compute this input data from the database, this takes quite some time') + # logging.info('The program will now compute this input data from the database, this takes quite some time') # self.prepare_input() def prepare_input(self, only_center=True, foldername_radar='radar'): @@ -265,7 +114,7 @@ def prepare_input(self, only_center=True, foldername_radar='radar'): """ if not os.path.exists(Path(self.db_location, foldername_radar)): - logger.error('Invalid foldername for radar data, please check') + logging.error('Invalid foldername for radar data, please check') if only_center: nx = [0] @@ -282,7 +131,7 @@ def prepare_input(self, only_center=True, foldername_radar='radar'): gauge = gauge.replace(-9999,np.nan) for x in nx: for y in ny: - logger.info('Processing neighbour {:d}{:d}'.format(x, y)) + logging.info('Processing neighbour {:d}{:d}'.format(x, y)) radar = dd.read_parquet(str(Path(self.db_location, foldername_radar, '*.parquet'))) refer = dd.read_parquet(str(Path(self.db_location, 'reference', @@ -389,7 +238,7 @@ def prepare_input(self, only_center=True, foldername_radar='radar'): # Save all to file # Save all to file - logger.info('Saving files to {}'.format(self.input_location)) + logging.info('Saving files to {}'.format(self.input_location)) refer.to_parquet(str(Path(self.input_location, 'reference_x{:d}y{:d}.parquet'.format(x,y))), compression = 'gzip', index = False) @@ -412,102 +261,7 @@ def prepare_input(self, only_center=True, foldername_radar='radar'): gauge.to_parquet(str(Path(self.input_location, 'gauge.parquet')), compression = 'gzip', index = False) - def prepare_input_vert_agg(self, aggregation_params, features=None, - tstart = None, tend = None, - output_folder = None): - """ - Calculates the vertical aggregation of the input features dic and saves - it to a file to run tests faster - - Parameters - ---------- - aggregation_params : dict - Dict with two keywords: beta and visib_weighting - If not given, the default is used: {'beta' : -0.5 , 'visib_weighting: True} - features : list - A list with features that will be aggregated to the ground, - e.g., ['RADAR', 'zh_VISIB_mean', - 'zv_VISIB_mean','KDP_mean','RHOHV_mean','T', 'HEIGHT','VISIB_mean']} - tstart : str - the starting time of the training time interval, default is to start - at the beginning of the time interval covered by the database - tend : str - the end time of the training time interval, default is to end - at the end of the time interval covered by the database - output_folder : str - Location where to store the trained models in pickle format, - if not provided it will store them in the standard location - str(Path(db_location, 'rf_input_data')) - """ - - if output_folder == None: - output_folder = self.input_location - if aggregation_params == None: - vert_agg_params = {'beta' : -0.5, 'visib_weighting' : 1} - else: - vert_agg_params = aggregation_params - - ############################################################################### - # Read and filter data - ############################################################################### - _, radartab, _, grp_vertical = \ - readInputData(self.input_location, tstart, tend, - datalist=['gauge', 'radar']) - - if features == None: - features = radartab.columns - - ############################################################################### - # Compute vertical aggregation and initialize model - ############################################################################### - radartab, features = processFeatures(features, radartab) - - ############################################################################### - # Compute data filter for each model - ############################################################################### - beta = vert_agg_params['beta'] - visib_weigh = vert_agg_params['visib_weighting'] - - vweights = 10**(beta * (radartab['HEIGHT']/1000.)) # vert. weights - - ############################################################################### - # Prepare training dataset - ############################################################################### - logger.info('Performing vertical aggregation of input features') - features_VERT_AGG = vert_aggregation(radartab[features], - vweights, grp_vertical,visib_weigh, - radartab['VISIB_mean']) - - ############################################################################### - # Fit - ############################################################################### - # create name of variables used in the model - features = [] - for f in features_VERT_AGG.columns: - if '_max' in f: - f = f.replace('_max','') - elif '_min' in f: - f = f.replace('_min','') - elif '_mean' in f: - f = f.replace('_mean','') - features.append(f) - - features_VERT_AGG['TIMESTAMP'] = radartab['TIMESTAMP'].groupby(grp_vertical).first() - features_VERT_AGG['STATION'] = radartab['STATION'].groupby(grp_vertical).first() - - features_VERT_AGG.to_parquet(str(Path(self.input_location, - 'feat_vert_agg_BETA_{:1.1f}_VisibWeigh_{:d}.parquet'.format(beta,visib_weigh))), - compression = 'gzip', index = False) - - filename = str(Path(self.input_location, \ - 'feat_vert_agg_BETA_{:1.1f}_VisibWeigh_{:d}_README.txt'.\ - format(beta,visib_weigh))) - with open(filename, 'w') as f: - f.write('Colnames\n'+ (';').join(list(features_VERT_AGG.columns)) + '\n') - f.write('Names in model\n' + (';').join(features) + '\n') - - def fit_models(self, config_file, features_dic, tstart = None, tend = None, output_folder = None): """ @@ -526,10 +280,10 @@ def fit_models(self, config_file, features_dic, tstart = None, tend = None, 'zv_VISIB_mean','KDP_mean','RHOHV_mean','T', 'HEIGHT','VISIB_mean']} will train a model with all these features that will then be stored under the name RF_dualpol_BC_.p in the ml/rf_models dir - tstart : str + tstart : datetime the starting time of the training time interval, default is to start at the beginning of the time interval covered by the database - tend : str + tend : datetime the end time of the training time interval, default is to end at the end of the time interval covered by the database output_folder : str @@ -544,40 +298,62 @@ def fit_models(self, config_file, features_dic, tstart = None, tend = None, try: config = envyaml(config_file) except: - logger.warning('Using default config as no valid config file was provided') + logging.warning('Using default config as no valid config file was provided') config_file = dir_path + '/default_config.yml' config = envyaml(config_file) + ####################################################################### + # Read data + ####################################################################### + + logging.info('Loading input data') + radartab = pd.read_parquet(str(Path(self.input_location, 'radar_x0y0.parquet'))) + gaugetab = pd.read_parquet(str(Path(self.input_location, 'gauge.parquet'))) + grp = pickle.load(open(str(Path(self.input_location, 'grouping_idx_x0y0.p')),'rb')) + grp_vertical = grp['grp_vertical'] + ############################################################################### - # Read and filter data + # Compute additional data if needed ############################################################################### - gaugetab, radartab, _, grp_vertical = \ - readInputData(self.input_location, tstart, tend, - datalist=['gauge', 'radar']) + + # currently the only supported additional features is zh (refl in linear units) + # and DIST_TO_RAD{A-D-L-W-P} (dist to individual radars) + # Get list of unique features names + features = np.unique([item for sub in list(features_dic.values()) + for item in sub]) - ############################################################################### - # Compute vertical aggregation and initialize model - ############################################################################### - radartab, features = processFeatures(features_dic, radartab) + for f in features: + if 'zh' in f: + logging.info('Computing derived variable {:s}'.format(f)) + radartab[f] = 10**(0.1 * radartab[f.replace('zh','ZH')]) + elif 'zv' in f: + logging.info('Computing derived variable {:s}'.format(f)) + radartab[f] = 10**(0.1 * radartab[f.replace('zv','ZV')]) + if 'DIST_TO_RAD' in f: + info_radar = constants.RADARS + vals = np.unique(radartab['RADAR']) + for val in vals: + dist = np.sqrt((radartab['X'] - info_radar['X'][val])**2+ + (radartab['Y'] - info_radar['Y'][val])**2) / 1000. + radartab['DIST_TO_RAD' + str(val)] = dist ############################################################################### # Compute data filter for each model ############################################################################### for model in features_dic.keys(): - logtime0 = datetime.datetime.now() vweights = 10**(config[model]['VERT_AGG']['BETA'] * (radartab['HEIGHT']/1000.)) # vert. weights filterconf = config[model]['FILTERING'].copy() - logger.info('Computing data filter') - logger.info('List of stations to ignore {:s}'.format(','.join(filterconf['STA_TO_REMOVE']))) - logger.info('Start time {:s}'.format(str(tstart))) - logger.info('End time {:s}'.format(str(tend))) - logger.info('ZH must be > {:f} if R <= {:f}'.format(filterconf['CONSTRAINT_MIN_ZH'][1], + logging.info('Computing data filter') + logging.info('List of stations to ignore {:s}'.format(','.join(filterconf['STA_TO_REMOVE']))) + logging.info('Start time {:s}'.format(str(tstart))) + logging.info('End time {:s}'.format(str(tend))) + logging.info('ZH must be > {:f} if R <= {:f}'.format(filterconf['CONSTRAINT_MIN_ZH'][1], filterconf['CONSTRAINT_MIN_ZH'][0])) - logger.info('ZH must be < {:f} if R <= {:f}'.format(filterconf['CONSTRAINT_MAX_ZH'][1], + logging.info('ZH must be < {:f} if R <= {:f}'.format(filterconf['CONSTRAINT_MAX_ZH'][1], filterconf['CONSTRAINT_MAX_ZH'][0])) ZH_agg = vert_aggregation(pd.DataFrame(radartab['ZH_mean']), @@ -595,6 +371,12 @@ def fit_models(self, config_file, features_dic, tstart = None, tend = None, invalid = np.logical_or(invalid,cond3) invalid = np.array(invalid) + if tend != None: + tend_unix = (tend - datetime.datetime(1970,1,1) ).total_seconds() + invalid[gaugetab['TIMESTAMP'] > tend_unix] = 1 + if tstart != None: + tstart_unix = (tstart - datetime.datetime(1970,1,1) ).total_seconds() + invalid[gaugetab['TIMESTAMP'] < tstart_unix] = 1 invalid[np.isnan(gaugetab['RRE150Z0'])] = 1 ############################################################################### @@ -603,7 +385,7 @@ def fit_models(self, config_file, features_dic, tstart = None, tend = None, gaugetab_train = gaugetab[~invalid].copy() - logger.info('Performing vertical aggregation of input features for model {:s}'.format(model)) + logging.info('Performing vertical aggregation of input features for model {:s}'.format(model)) features_VERT_AGG = vert_aggregation(radartab[features_dic[model]], vweights, grp_vertical, config[model]['VERT_AGG']['VISIB_WEIGHTING'], @@ -639,287 +421,26 @@ def fit_models(self, config_file, features_dic, tstart = None, tend = None, config[model]['FILTERING']['STA_INCLUDED'] = gaugetab['STATION'][~invalid].unique() config[model]['FILTERING']['CREATED'] = datetime.datetime.utcnow().strftime('%d %b %Y %H:%M UTC') - logger.info('') - logger.info('Training model on gauge data') + logging.info('') + logging.info('Training model on gauge data') - logger.info('Initializing random forest model {:s}'.format(model)) - if len(config[model]['QUANTILES']) == 0: - reg = RandomForestRegressorBC(degree = 1, + reg = RandomForestRegressorBC(degree = 1, bctype = config[model]['BIAS_CORR'], + visib_weighting = config[model]['VERT_AGG']['VISIB_WEIGHTING'], variables = features, beta = config[model]['VERT_AGG']['BETA'], - visib_weighting=config[model]['VERT_AGG']['VISIB_WEIGHTING'], + metadata = config[model]['FILTERING'], **config[model]['RANDOMFOREST_REGRESSOR']) - else: - reg = QuantileRandomForestRegressorBC(degree = 1, - bctype = config[model]['BIAS_CORR'], - variables = features, - beta = config[model]['VERT_AGG']['BETA'], - visib_weighting=config[model]['VERT_AGG']['VISIB_WEIGHTING'], - **config[model]['RANDOMFOREST_REGRESSOR']) - # reg = QuantileRegressionForest(**config[model]['RANDOMFOREST_REGRESSOR']) - # reg.bctype = config[model]['BIAS_CORR'] - # reg.variables = features - # reg.beta = config[model]['VERT_AGG']['BETA'] - # reg.visib_weighting=config[model]['VERT_AGG']['VISIB_WEIGHTING'] - - logger.info('Fitting random forest model {:s}'.format(model)) - - reg.fit(features_VERT_AGG[valid].to_numpy(), Y[valid]) - - logger.info('Model {} took {} minutes to be trained'.format(model, datetime.datetime.now()-logtime0)) + reg.fit(features_VERT_AGG[valid], Y[valid]) + out_name = str(Path(output_folder, '{:s}_BETA_{:2.1f}_BC_{:s}.p'.format(model, config[model]['VERT_AGG']['BETA'], config[model]['BIAS_CORR']))) - logger.info('Saving model to {:s}'.format(out_name)) + logging.info('Saving model to {:s}'.format(out_name)) pickle.dump(reg, open(out_name, 'wb')) - del reg - - -class RFModelEval(object): - ''' - This is the main class that allows to preparate data for random forest - training, train random forests and perform cross-validation of trained models - ''' - def __init__(self, db_location, input_location=None): - """ - Initializes the class to analyse the model and perform standard ML - evaluation on it - - Note that when calling this constructor the input data is only - generated for the central pixel (NX = NY = 0 = loc of gauge), if you - want to regenerate the inputs for all neighbour pixels, please - call the function self.prepare_input(only_center_pixel = False) - - Parameters - ---------- - db_location : str - Location of the main directory of the database (with subfolders - 'reference', 'gauge' and 'radar' on the filesystem) - input_location : str - Location of the prepared input data, if this data cannot be found - in this folder, it will be computed here, default is a subfolder - called rf_input_data within db_location - force_regenerate_input : bool - if True the input parquet files will always be regenerated from - the database even if already present in the input_location folder - """ - - if input_location == None: - input_location = str(Path(db_location, 'rf_input_data')) - - # Check if at least gauge.parquet, refer_x0y0.parquet and radar_x0y0.parquet - # are present - valid = True - if not os.path.exists(input_location): - valid = False - os.makedirs(input_location) - files = glob.glob(str(Path(input_location, '*'))) - files = [os.path.basename(f) for f in files] - if ('gauge.parquet' not in files or 'reference_x0y0.parquet' not in files - or 'radar_x0y0.parquet' not in files): - valid = False - - self.input_location = input_location - self.db_location = db_location - - if not valid : - logger.info('Could not find valid input data from the folder {:s}'.format(input_location)) - - def calc_model_predictions(self, models_dic, output_folder, model_folder=None, - tstart=None, tend=None, reference=['CPCH', 'RZC'], - station_obs = ['TRE200S0', 'DKL010Z0', 'FKL010Z0'], - ensemble = [] , quantile_dic = {}): - """_summary_ - - Parameters - ----------- - models_dic : dic - dic with modelname, filename of model - e.g.,model_dic = {'RFO': 'RFO_BETA_-0.5_BC_spline.p'} - output_folder : str - Path where the dataframe is stored - model_folder : str, optional - Path where model is stored. Defaults to None. - output_folder : str - Path to where to store the scores - tstart: str (YYYYMMDDHHMM) - A date to define a starting time for the input data - tend: str (YYYYMMDDHHMM) - A date to define the end of the input data - reference : list, optional - _description_. Defaults to ['CPCH', 'RZC']. - station_obs : list, optional - _description_. Defaults to ['TRE200S0', 'DKL1010Z0', 'FKL010Z0']. - ensemble : list - List with all models that a ensemble output is wished for - quantile_dic : dic - Dictionary with modelname and quantiles to extract, - e.g., quantile_dic = {'QuRFO': [0.05,0.10,0.5,0.9,0.95]} - """ - - # Get models and model path - modelnames = list(models_dic.keys()) - if model_folder == None: - MODEL_FOLDER = self.model_paths - else: - MODEL_FOLDER = model_folder - - # Get data from database, and filter it according to the time limitations - if len(reference) == 0 : - gaugetab, radartab, grp_hourly, grp_vertical = \ - readInputData(self.input_location, tstart, tend, datalist=['gauge', 'radar']) - else: - gaugetab, radartab, refertab, grp_hourly, grp_vertical =\ - readInputData(self.input_location, tstart, tend, datalist=['gauge', 'radar', 'refer']) - - ################################################################################# - # Read models and create features dictionary - ################################################################################# - regressors = {} - features_dic = {} - - for model in modelnames: - logger.info('Performing vertical aggregation of input features for model {:s}'.format(model)) - - # regressors[model] = pickle.load(open(Path(MODEL_FOLDER,features_dic[model]),'rb')) - regressors[model] = read_rf(models_dic[model], MODEL_FOLDER) - features = regressors[model].variables.copy() - features_dic[model] = features - - # As RADAR_prop will be calculated below, adding variable here: - # Compute additional data if needed - features_to_be_removed = [] - for f in features: - # Radar_prop is calculated with vert_aggregation - if f.startswith('RADAR_prop'): - features_to_be_removed.append(f) - - if len(features_to_be_removed) > 0: - for ftbr in features_to_be_removed: - features.remove(ftbr) - features.append('RADAR') - - regressors[model].features = features.copy() - - ############################################################################### - # Get linear units of reflectivity - ############################################################################### - radartab, features = processFeatures(features_dic, radartab) - - for colname in radartab.columns: - list_feat = np.unique([item for sub in list(features_dic.values()) - for item in sub]) - if colname.replace('_mean', '') in list_feat: - radartab.rename(columns = {colname:colname.replace('_mean','')}, inplace=True) - - ############################################################################### - # Compute vertical aggregation - ############################################################################### - features_VERT_AGG = {} - for im, model in enumerate(modelnames): - logger.info('Performing vertical aggregation of input features for model {:s}'.format(model)) - - beta = regressors[model].beta - visib_weighting = regressors[model].visib_weighting - - if (im > 0) and (beta == regressors[modelnames[im-1]].beta) \ - and (visib_weighting == regressors[modelnames[im-1]].visib_weighting) : - logger.info('Model {} has same vertical aggregation settings as {}, hence just copy aggregated 2D fields'.format(model, modelnames[im-1])) - features_VERT_AGG[model] = features_VERT_AGG[modelnames[im-1]].copy() - else: - vweights = 10**(beta*(radartab['HEIGHT']/1000.)) # vert. weights - try: - features_VERT_AGG[model] = vert_aggregation(radartab[features_dic[model]], - vweights, grp_vertical, - visib_weighting, - radartab['VISIB_mean']) - except: - features_VERT_AGG[model] = vert_aggregation(radartab[features_dic[model]], - vweights, grp_vertical, - visib_weighting, - radartab['VISIB']) - - ############################################################################### - # Clean and prepare data - ############################################################################### - test_not_ok = False - for iv, val in enumerate(radartab['s-tstamp'].groupby(grp_vertical).first()): - if gaugetab['s-tstamp'].iloc[iv] != val: - test_not_ok = True - print(gaugetab['s-tstamp'][iv]) - if test_not_ok: - logger.error('Time cut went wrong!!') - - valid = np.all(np.isfinite(features_VERT_AGG[modelnames[0]]), - axis = 1) - - for model in modelnames: - features_VERT_AGG[model] = features_VERT_AGG[model][valid] - - gaugetab = gaugetab[valid] - refertab = refertab[valid] - grp_hourly = grp_hourly[valid] - - ############################################################################### - # Assemble dataframe with data from database - ############################################################################### - logger.info('Assembling dataframe') - data_pred = pd.DataFrame({'TIMESTAMP': gaugetab['TIMESTAMP'], - 'STATION': gaugetab['STATION'], - 'RRE150Z0': gaugetab['RRE150Z0']*6, - 'IDX_HOURLY': grp_hourly}) - - for var in station_obs: - try: - data_pred[var] = gaugetab[var] - except: - logger.error('Could not add {}'.format(var)) - - for ref in reference: - try: - data_pred[ref] = refertab[ref] - except: - logger.error('Could not add {}'.format(ref)) - - ############################################################################### - # Calculate model values - ############################################################################### - for model in modelnames: - logger.info('Calculate estimates of {}'.format(model)) - - if model in quantile_dic.keys(): - R_pred_10 = regressors[model].predict(features_VERT_AGG[model][regressors[model].variables], - quantiles=quantile_dic[model]) - data_pred[model] = R_pred_10[0] - data_quant = pd.DataFrame(R_pred_10[1], - columns = [model+'_Q'+str(qu) for qu in quantile_dic[model]], - index = data_pred.index) - data_pred = pd.concat([data_pred, data_quant], axis=1) - else: - data_pred[model] = regressors[model].predict(\ - features_VERT_AGG[model][regressors[model].variables]) - - if (model in ensemble) & ('Qu' not in model) : - pred_ens = regressors[model].predict_ens(\ - features_VERT_AGG[model][regressors[model].variables]) - for tree in range(regressors[model].n_estimators): - data_pred['{}_E{}'.format(model, tree)] = pred_ens[:,tree] - # data_pred['{}_E{}'.format(model, tree)] = \ - # regressors[model].estimators_[tree].predict(\ - # features_VERT_AGG[model][regressors[model].variables]) - - ############################################################################### - # Save output - ############################################################################### - name_file = str(Path(output_folder, 'rfmodels_x0_y0.parquet')) - data_pred.to_parquet(name_file, compression='gzip', index=False) - logger.info('Saved file: {}'.format(name_file)) - - def feature_selection(self, features_dic, featuresel_configfile, output_folder, K=5, tstart=None, tend=None): """ @@ -947,14 +468,71 @@ def feature_selection(self, features_dic, featuresel_configfile, config = envyaml(featuresel_configfile) modelnames = list(features_dic.keys()) + ####################################################################### + # Read data + ####################################################################### + logging.info('Reading input data from {}'.format(self.input_location)) + radartab = pd.read_parquet(str(Path(self.input_location, 'radar_x0y0.parquet'))) + gaugetab = pd.read_parquet(str(Path(self.input_location, 'gauge.parquet'))) + grp = pickle.load(open(str(Path(self.input_location, 'grouping_idx_x0y0.p')),'rb')) + grp_vertical = grp['grp_vertical'] + grp_hourly = grp['grp_hourly'] + + ####################################################################### + # Filter time + ####################################################################### + if tstart != None: + try: + tstart = datetime.datetime.strptime(tstart, + '%Y%m%d%H%M').replace(tzinfo=datetime.timezone.utc).timestamp() + except: + tstart = gaugetab['TIMESTAMP'].min() + logging.info('The format of tstart was wrong, taking the earliest date') + if tend != None: + try: + tend = datetime.datetime.strptime(tend, + '%Y%m%d%H%M').replace(tzinfo=datetime.timezone.utc).timestamp() + except: + tend = gaugetab['TIMESTAMP'].max() + logging.info('The format of tend was wrong, taking the earliest date') + + timevalid = gaugetab['TIMESTAMP'].copy().astype(bool) + vertvalid = radartab['TIMESTAMP'].copy().astype(bool) + + if (tstart != None): + timevalid[(gaugetab['TIMESTAMP'] < tstart)] = False + vertvalid[(radartab['TIMESTAMP'] < tstart)] = False + if (tend != None): + timevalid[(gaugetab['TIMESTAMP'] > tend)] = False + vertvalid[(radartab['TIMESTAMP'] > tend)] = False + + gaugetab = gaugetab[timevalid] + grp_hourly = grp_hourly[timevalid] + radartab = radartab[vertvalid] + grp_vertical = grp_vertical[vertvalid] ############################################################################### - # Read data, filter time and get linear reflectivity units + # Compute additional data if needed ############################################################################### - gaugetab, radartab, _, grp_hourly, grp_vertical = \ - readInputData(self.input_location, tstart, tend) - - radartab, features = processFeatures(features_dic, radartab) + # currently the only supported additional features is zh (refl in linear units) + # and DIST_TO_RAD{A-D-L-W-P} (dist to individual radars) + # Get list of unique features names + features = np.unique([item for sub in list(features_dic.values()) + for item in sub]) + for f in features: + if 'zh' in f: + logging.info('Computing derived variable {:s}'.format(f)) + radartab[f] = 10**(0.1 * radartab[f.replace('zh','ZH')]) + elif 'zv' in f: + logging.info('Computing derived variable {:s}'.format(f)) + radartab[f] = 10**(0.1 * radartab[f.replace('zv','ZV')]) + if 'DIST_TO_RAD' in f: + info_radar = constants.RADARS + vals = np.unique(radartab['RADAR']) + for val in vals: + dist = np.sqrt((radartab['X'] - info_radar['X'][val])**2+ + (radartab['Y'] - info_radar['Y'][val])**2) / 1000. + radartab['DIST_TO_RAD' + str(val)] = dist ############################################################################### # Compute vertical aggregation @@ -962,11 +540,11 @@ def feature_selection(self, features_dic, featuresel_configfile, features_VERT_AGG = {} regressors = {} for im, model in enumerate(modelnames): - logger.info('Performing vertical aggregation of input features for model {:s}'.format(model)) + logging.info('Performing vertical aggregation of input features for model {:s}'.format(model)) if (im > 0) and (config[model]['VERT_AGG']['BETA'] == config[modelnames[im-1]]['VERT_AGG']['BETA']) \ and (config[model]['VERT_AGG']['VISIB_WEIGHTING'] == config[modelnames[im-1]]['VERT_AGG']['VISIB_WEIGHTING']): - logger.info('Model {} has same vertical aggregation settings as {}, hence just copy aggregated 2D fields'.format(model, modelnames[im-1])) + logging.info('Model {} has same vertical aggregation settings as {}, hence just copy aggregated 2D fields'.format(model, modelnames[im-1])) features_VERT_AGG[model] = features_VERT_AGG[modelnames[im-1]].copy() else: vweights = 10**(config[model]['VERT_AGG']['BETA'] * @@ -987,13 +565,18 @@ def feature_selection(self, features_dic, featuresel_configfile, valid = np.all(np.isfinite(features_VERT_AGG[modelnames[0]]), axis = 1) + # if (tstart != None): + # valid[(gaugetab['TIMESTAMP'] < tstart)] = False + # if (tend != None): + # valid[(gaugetab['TIMESTAMP'] > tend)] = False + test_not_ok = False for iv, val in enumerate(radartab['s-tstamp'].groupby(grp_vertical).first()): if gaugetab['s-tstamp'][iv] != val: test_not_ok = True print(gaugetab['s-tstamp'][iv]) if test_not_ok: - logger.error('Time cut went wrong!!') + logging.error('Time cut went wrong!!') for model in modelnames: features_VERT_AGG[model] = features_VERT_AGG[model][valid] @@ -1011,7 +594,7 @@ def feature_selection(self, features_dic, featuresel_configfile, if (K != None): K = list(range(K)) elif (K == None): - logger.info('Cross validation with random events defined but not specified, applying 5-fold CV') + logging.info('Cross validation with random events defined but not specified, applying 5-fold CV') K = list(range(5)) idx_testtrain = split_event(gaugetab['TIMESTAMP'].values, len(K)) @@ -1028,7 +611,7 @@ def feature_selection(self, features_dic, featuresel_configfile, scores[tagg][model][feat] = [] for k in K: - logger.info('Run {:d}/{:d}-{:d} of cross-validation'.format(k,np.nanmin(K),np.nanmax(K))) + logging.info('Run {:d}/{:d}-{:d} of cross-validation'.format(k,np.nanmin(K),np.nanmax(K))) test = idx_testtrain == k train = idx_testtrain != k @@ -1049,7 +632,7 @@ def feature_selection(self, features_dic, featuresel_configfile, rmse_ref_60 = perfscores(R_pred_60, R_test_60, bounds=None)['all']['RMSE'] for feat in features_VERT_AGG[model].keys(): - logger.info('Shuffling feature: {}'.format(feat)) + logging.info('Shuffling feature: {}'.format(feat)) # Shuffle input feature on test fraction, keep others untouched x_test = features_VERT_AGG[model][test].copy() x_test[feat] = np.random.permutation(x_test[feat].values) @@ -1076,7 +659,7 @@ def model_intercomparison(self, features_dic, intercomparison_configfile, bounds10 = [0,2,10,100], bounds60 = [0,2,10,100], cross_val_type='years', K=5, years=None, tstart=None, tend=None, station_scores=False, - save_model=False, save_output=False): + save_model=False): """ Does an intercomparison (cross-validation) of different RF models and reference products (RZC, CPC, ...) and plots the performance plots @@ -1110,7 +693,7 @@ def model_intercomparison(self, features_dic, intercomparison_configfile, at hourly time resolution [0,1,10,100] will give scores in range [0-1], [1-10] and [10-100] cross_val_type: str - Define how the split of events is done. Options are "random", + Define how the split of events is done. Options are "random events", "years" and "seasons" (TODO) K : int or None Number of splits in iterations do perform in the K fold cross-val @@ -1141,194 +724,267 @@ def model_intercomparison(self, features_dic, intercomparison_configfile, raise ValueError('Keys in features_dic are not all present in intercomparison config file!') if (cross_val_type == 'years') and (years == None): - logger.info('Cross validation years defined, but not specified, years from 2016-2021 used') - K = list(range(2016,2023,1)) + logging.info('Cross validation years defined, but not specified, years from 2016-2021 used') + K = list(range(2016,2022,1)) elif (cross_val_type == 'years') and (years != None): K = years - if (cross_val_type == 'random') and (K != None): + if (cross_val_type == 'random events') and (K != None): K = list(range(K)) - elif (cross_val_type == 'random') and (K == None): - logger.info('Cross validation with random events defined but not specified, applying 5-fold CV') + elif (cross_val_type == 'random events') and (K == None): + logging.info('Cross validation with random events defined but not specified, applying 5-fold CV') K = list(range(5)) + ####################################################################### + # Read data + ####################################################################### + logging.info('Reading input data from {}'.format(self.input_location)) + radartab = pd.read_parquet(str(Path(self.input_location, 'radar_x0y0.parquet'))) + refertab = pd.read_parquet(str(Path(self.input_location, 'reference_x0y0.parquet'))) + gaugetab = pd.read_parquet(str(Path(self.input_location, 'gauge.parquet'))) + grp = pickle.load(open(str(Path(self.input_location, 'grouping_idx_x0y0.p')),'rb')) + grp_vertical = grp['grp_vertical'] + grp_hourly = grp['grp_hourly'] + + ####################################################################### + # Filter time + ####################################################################### + if tstart != None: + try: + tstart = datetime.datetime.strptime(tstart, + '%Y%m%d%H%M').replace(tzinfo=datetime.timezone.utc).timestamp() + except: + tstart = gaugetab['TIMESTAMP'].min() + logging.info('The format of tstart was wrong, taking the earliest date') + if tend != None: + try: + tend = datetime.datetime.strptime(tend, + '%Y%m%d%H%M').replace(tzinfo=datetime.timezone.utc).timestamp() + except: + tend = gaugetab['TIMESTAMP'].max() + logging.info('The format of tend was wrong, taking the earliest date') ############################################################################### - # Read and filter data with time constraints + # Compute additional data if needed ############################################################################### - gaugetab, radartab, refertab, grp_hourly, grp_vertical = \ - readInputData(self.input_location, tstart, tend, - datalist=['gauge', 'radar', 'refer']) - - radartab, _ = processFeatures(features_dic, radartab) + # currently the only supported additional features is zh (refl in linear units) + # and DIST_TO_RAD{A-D-L-W-P} (dist to individual radars) + # Get list of unique features names + features = np.unique([item for sub in list(features_dic.values()) + for item in sub]) + for f in features: + if 'zh' in f: + logging.info('Computing derived variable {:s}'.format(f)) + radartab[f] = 10**(0.1 * radartab[f.replace('zh','ZH')]) + elif 'zv' in f: + logging.info('Computing derived variable {:s}'.format(f)) + radartab[f] = 10**(0.1 * radartab[f.replace('zv','ZV')]) + if 'DIST_TO_RAD' in f: + info_radar = constants.RADARS + vals = np.unique(radartab['RADAR']) + for val in vals: + dist = np.sqrt((radartab['X'] - info_radar['X'][val])**2+ + (radartab['Y'] - info_radar['Y'][val])**2) / 1000. + radartab['DIST_TO_RAD' + str(val)] = dist + ############################################################################### - # Compute vertical aggregation and initialize model + # Compute vertical aggregation ############################################################################### - features_VERT_AGG = {} regressors = {} - for im, model in enumerate(modelnames): - logger.info('Performing vertical aggregation of input features for model {:s}'.format(model)) + for model in modelnames: + logging.info('Performing vertical aggregation of input features for model {:s}'.format(model)) - # Save computational time if the input data is the same within the model - if (im > 0) and (config[model]['VERT_AGG']['BETA'] == config[modelnames[im-1]]['VERT_AGG']['BETA']) \ - and (config[model]['VERT_AGG']['VISIB_WEIGHTING'] == config[modelnames[im-1]]['VERT_AGG']['VISIB_WEIGHTING']): - logger.info('Model {} has same vertical aggregation settings as {}, hence just copy aggregated 2D fields'.format(model, modelnames[im-1])) - features_VERT_AGG[model] = features_VERT_AGG[modelnames[im-1]].copy() - else: - vweights = 10**(config[model]['VERT_AGG']['BETA'] * - (radartab['HEIGHT']/1000.)) # vert. weights - features_VERT_AGG[model] = vert_aggregation(radartab[features_dic[model]], - vweights, grp_vertical, - config[model]['VERT_AGG']['VISIB_WEIGHTING'], - radartab['VISIB_mean']) - - # Use either the classical RainForest model or the new one - if len(config[model]['QUANTILES']) == 0: - regressors[model] = RandomForestRegressorBC(degree = 1, + vweights = 10**(config[model]['VERT_AGG']['BETA'] * + (radartab['HEIGHT']/1000.)) # vert. weights + features_VERT_AGG[model] = vert_aggregation(radartab[features_dic[model]], + vweights, grp_vertical, + config[model]['VERT_AGG']['VISIB_WEIGHTING'], + radartab['VISIB_mean']) + + regressors[model] = RandomForestRegressorBC(degree = 1, bctype = config[model]['BIAS_CORR'], variables = features_dic[model], beta = config[model]['VERT_AGG']['BETA'], visib_weighting=config[model]['VERT_AGG']['VISIB_WEIGHTING'], **config[model]['RANDOMFOREST_REGRESSOR']) - else: - regressors[model] = QuantileRegressionForest(**config[model]['RANDOMFOREST_REGRESSOR']) - - ############################################################################### - # Remove nans within dataset - ############################################################################### + + # remove nans valid = np.all(np.isfinite(features_VERT_AGG[modelnames[0]]), axis = 1) + # if (tstart != None) and (tend == None): + # (gaugetab['TIMESTAMP'] >= tstart) + # elif (tstart == None) and (tend != None): + # timeperiod = (gaugetab['TIMESTAMP'] <= tend) + # elif (tstart != None) and (tend != None): + # timeperiod = (gaugetab['TIMESTAMP'] >= tstart) & (gaugetab['TIMESTAMP'] <= tend) + # else: + # timeperiod = valid + if (tstart != None): + valid[(gaugetab['TIMESTAMP'] < tstart)] = False + if (tend != None): + valid[(gaugetab['TIMESTAMP'] > tend)] = False + for model in modelnames: features_VERT_AGG[model] = features_VERT_AGG[model][valid] - + gaugetab = gaugetab[valid] refertab = refertab[valid] grp_hourly = grp_hourly[valid] - ############################################################################### # Get R, T and idx test/train - ############################################################################### R = np.array(gaugetab['RRE150Z0'] * 6) # Reference precip in mm/h R[np.isnan(R)] = 0 + T = np.array(gaugetab['TRE200S0']) # Reference temp in degrees + # features must have the same size as gauge - if cross_val_type == 'random': + if cross_val_type == 'random_events': idx_testtrain = split_event(gaugetab['TIMESTAMP'].values, len(K)) elif cross_val_type == 'years': idx_testtrain = split_years(gaugetab['TIMESTAMP'].values, years=K) else: - logger.error('Please define your cross validation separation') + logging.error('Please define your cross validation separation') + - ############################################################################### - # Initialize outputs - ############################################################################### modelnames.extend(reference_products) - if station_scores == False: - all_scores, all_stats = prepareScoreDic(modelnames, station_scores) - else: - all_scores, all_stats, all_station_scores, all_station_stats = \ - prepareScoreDic(modelnames, station_scores) - + all_scores = {'10min':{},'60min':{}} + all_stats = {'10min':{},'60min':{}} + + if station_scores == True: + all_station_scores = {'10min': {}, '60min': {}} + all_station_stats = {'10min': {}, '60min': {}} + ############################################################################### - # MAIN LOOP: CROSS VALIDATION + # Initialize outputs ############################################################################### - for ik, k in enumerate(K): - logger.info('Run {:d}/{:d}-{:d} of cross-validation'.format(k,np.nanmin(K),np.nanmax(K))) + for model in modelnames: + all_scores['10min'][model] = {'train': {'solid':[],'liquid':[],'all':[]}, + 'test': {'solid':[],'liquid':[],'all':[]}} + all_scores['60min'][model] = {'train': {'solid':[],'liquid':[],'all':[]}, + 'test': {'solid':[],'liquid':[],'all':[]}} + + all_stats['10min'][model] = {'train': {'solid':{},'liquid':{},'all':{}}, + 'test': {'solid':{},'liquid':{},'all':{}}} + + all_stats['60min'][model] = {'train': {'solid':{},'liquid':{},'all':{}}, + 'test': {'solid':{},'liquid':{},'all':{}}} + + if station_scores == True: + # for station scores we will limit the output to test data only + for timeagg in all_station_scores.keys(): + all_station_scores[timeagg][model] = {'solid':{},'liquid':{},'all':{}} + all_station_stats[timeagg][model] = {'solid':{},'liquid':{},'all':{}} + + + for k in K: + logging.info('Run {:d}/{:d}-{:d} of cross-validation'.format(k,np.nanmin(K),np.nanmax(K))) test = idx_testtrain == k train = idx_testtrain != k if cross_val_type == 'years': - logger.info('Time range for testing set: {} - {} with {:3.2f}% of datapoints'.format( + logging.info('Time range for testing set: {} - {} with {:3.2f}% of datapoints'.format( datetime.datetime.utcfromtimestamp(gaugetab['TIMESTAMP'][test].min()), datetime.datetime.utcfromtimestamp(gaugetab['TIMESTAMP'][test].max()), gaugetab['TIMESTAMP'][test].count()/ gaugetab['TIMESTAMP'].count()*100)) - - idxTemp = getTempIDX(T, grp_hourly, test, train) - R_obs_test_60 = np.squeeze(np.array(pd.DataFrame(R[test]) + # Get reference values + R_test_60 = np.squeeze(np.array(pd.DataFrame(R[test]) .groupby(grp_hourly[test]).mean())) - R_obs_train_60 = np.squeeze(np.array(pd.DataFrame(R[train]) + R_train_60 = np.squeeze(np.array(pd.DataFrame(R[train]) .groupby(grp_hourly[train]).mean())) - - idxTemp['10min']['test']['all'] = R[test].astype(bool) - idxTemp['10min']['train']['all'] = R[train].astype(bool) - idxTemp['60min']['train']['all'] = R_obs_train_60.astype(bool) - idxTemp['60min']['test']['all'] = R_obs_test_60.astype(bool) - + + T_test_60 = np.squeeze(np.array(pd.DataFrame(T[test]) + .groupby(grp_hourly[test]).mean())) + + T_train_60 = np.squeeze(np.array(pd.DataFrame(T[train]) + .groupby(grp_hourly[train]).mean())) + + + liq_10_train = T[train] >= constants.THRESHOLD_SOLID + sol_10_train = T[train] < constants.THRESHOLD_SOLID + liq_60_train = T_train_60 >= constants.THRESHOLD_SOLID + sol_60_train = T_train_60 < constants.THRESHOLD_SOLID + + liq_10_test = T[test] >= constants.THRESHOLD_SOLID + sol_10_test = T[test] < constants.THRESHOLD_SOLID + liq_60_test = T_test_60 >= constants.THRESHOLD_SOLID + sol_60_test = T_test_60 < constants.THRESHOLD_SOLID + # Fit every regression model for model in modelnames: - logger.info('Checking model {:s}'.format(model)) + logging.info('Checking model {:s}'.format(model)) + logging.info('Evaluating test error') + # 10 min + logging.info('at 10 min') # Performing fit if model not in reference_products: - logger.info('Training model on gauge data') - - regressors[model].fit(features_VERT_AGG[model][train].to_numpy(),R[train]) - - if len(config[model]['QUANTILES']) == 0 : - R_pred_10 = regressors[model].predict(features_VERT_AGG[model][test]) - else: - # In this case, R_pred_10 becomes a tuple - R_pred_10_all = regressors[model].predict(features_VERT_AGG[model][test].to_numpy(), - quantiles=config[model]['QUANTILES']) - - # Save output for analysis - R_pred_10 = R_pred_10_all[0] - - RFquantiles = np.column_stack([R_pred_10_all[0], R_pred_10_all[1]]) - header = ['mean'] + [str(qe) for qe in config[model]['QUANTILES']] - RFQ = pd.DataFrame(RFquantiles, columns=header) - RFQ['gauge'] = R[test] - filename = str(Path(output_folder, 'RFQuantiles_{}_K_fold_{}.parquet'.format(model, k))) - logger.info('Saving data to {:s}'.format(filename)) - RFQ.to_parquet(filename) + logging.info('Training model on gauge data') + regressors[model].fit(features_VERT_AGG[model][train],R[train]) + R_pred_10 = regressors[model].predict(features_VERT_AGG[model][test]) + if (save_model == True): regressors[model].variables = features_VERT_AGG[model].columns out_name = str(Path(output_folder, '{:s}_BETA_{:2.1f}_BC_{:s}_excl_{}.p'.format(model, config[model]['VERT_AGG']['BETA'], config[model]['BIAS_CORR'],k))) - logger.info('Saving model to {:s}'.format(out_name)) + logging.info('Saving model to {:s}'.format(out_name)) pickle.dump(regressors[model], open(out_name, 'wb')) else: R_pred_10 = refertab[model].values[test] - logger.info('Evaluating test error') - logger.info('at 10 min') - all_scores = calcScore(all_scores, obs=R[test], pred=R_pred_10, - idxTemp = idxTemp, bounds= bounds10, - tagg = '10min', model=model, data_type='test') + scores_solid = perfscores(R_pred_10[sol_10_test], + R[test][sol_10_test], + bounds = bounds10) + + all_scores['10min'][model]['test']['solid'].append(scores_solid) + + scores_liquid = perfscores(R_pred_10[liq_10_test], + R[test][liq_10_test], + bounds = bounds10) + all_scores['10min'][model]['test']['liquid'].append(scores_liquid) + + scores_all = perfscores(R_pred_10, + R[test], + bounds = bounds10) + all_scores['10min'][model]['test']['all'].append(scores_all) # 60 min - logger.info('at 60 min') + logging.info('at 60 min') R_pred_60 = np.squeeze(np.array(pd.DataFrame(R_pred_10) .groupby(grp_hourly[test]).mean())) - - all_scores = calcScore(all_scores, obs=R_obs_test_60, pred=R_pred_60, - idxTemp = idxTemp, bounds= bounds60, - tagg = '60min', model=model, data_type='test') + + scores_solid = perfscores(R_pred_60[sol_60_test], + R_test_60[sol_60_test], + bounds = bounds60) + all_scores['60min'][model]['test']['solid'].append(scores_solid) + + + scores_liquid = perfscores(R_pred_60[liq_60_test], + R_test_60[liq_60_test], + bounds = bounds60) + all_scores['60min'][model]['test']['liquid'].append(scores_liquid) + + scores_all = perfscores(R_pred_60, + R_test_60, + bounds = bounds60) + all_scores['60min'][model]['test']['all'].append(scores_all) if station_scores == True: - logger.info('Calculating station performances for model {}'.format(model)) + logging.info('Calculating station performances for model {}'.format(model)) stations_60 = np.array(gaugetab['STATION'][test] .groupby(grp_hourly[test]).first()) df = pd.DataFrame(columns=gaugetab['STATION'].unique(), - index = all_scores['60min'][model]['test']['all'][ik]['all'].keys()) - - # Fast fix - liq_10_test = idxTemp['10min']['test']['liquid'] - sol_10_test = idxTemp['10min']['test']['solid'] - liq_60_test = idxTemp['60min']['test']['liquid'] - sol_60_test = idxTemp['60min']['test']['solid'] - + index = scores_all['all'].keys()) for timeagg in all_station_scores.keys(): all_station_scores[timeagg][model]['all'][k] = df.copy() @@ -1344,83 +1000,80 @@ def model_intercomparison(self, features_dic, intercomparison_configfile, R[test][sta_idx])['all'] all_station_scores['10min'][model]['all'][k][sta] = scores_all_10 - scores_all_60 = perfscores(R_pred_60[sta_idx_60],R_obs_test_60[sta_idx_60])['all'] + scores_all_60 = perfscores(R_pred_60[sta_idx_60],R_test_60[sta_idx_60])['all'] all_station_scores['60min'][model]['all'][k][sta] = scores_all_60 del scores_all_10, scores_all_60 except: - logger.info('No performance score for {}'.format(sta)) + logging.info('No performance score for {}'.format(sta)) try: scores_liquid_10 = perfscores(R_pred_10[liq_10_test & sta_idx], R[test][liq_10_test & sta_idx])['all'] all_station_scores['10min'][model]['liquid'][k][sta] = scores_liquid_10 scores_liquid_60 = perfscores(R_pred_60[liq_60_test & sta_idx_60], - R_obs_test_60[liq_60_test & sta_idx_60])['all'] + R_test_60[liq_60_test & sta_idx_60])['all'] all_station_scores['60min'][model]['liquid'][k][sta] = scores_liquid_60 except: - logger.info('No performance score for liquid precip for {}'.format(sta)) + logging.info('No performance score for liquid precip for {}'.format(sta)) try: scores_solid_10 = perfscores(R_pred_10[sol_10_test & sta_idx], R[test][sol_10_test & sta_idx])['all'] all_station_scores['10min'][model]['solid'][k][sta] = scores_solid_10 scores_solid_60 = perfscores(R_pred_60[sol_60_test & sta_idx_60], - R_obs_test_60[sol_60_test & sta_idx_60])['all'] + R_test_60[sol_60_test & sta_idx_60])['all'] all_station_scores['60min'][model]['solid'][k][sta] = scores_solid_60 except: - logger.info('No performance score for solid precip for {}'.format(sta)) - - # Save output of training and testing data - if save_output: - if model not in reference_products: - data = features_VERT_AGG[model][test].copy() - data[model] = R_pred_10.copy() - else: - data = pd.DataFrame(pd.Series(R_pred_10, name=model)) - - data['gauge'] = R[test].copy() - data['TIMESTAMP'] = gaugetab['TIMESTAMP'][test] - data['STATION'] = gaugetab['STATION'][test] - - out_name = str(Path(output_folder, 'data_{}_test_10min_CVfold_{}.csv'.format(model,k))) - data.to_csv(out_name, index=False) - logger.info('Saving data to {:s}'.format(out_name)) - - data_60 = pd.DataFrame({'gauge': R_obs_test_60, model: R_pred_60}) - data_60['STATION'] = np.array(gaugetab['STATION'][test] - .groupby(grp_hourly[test]).first()) - data_60['TIMESTAMP'] = np.array(gaugetab['TIMESTAMP'][test] - .groupby(grp_hourly[test]).max()) - data_60['n_counts'] = np.squeeze(np.array(pd.DataFrame(R[test]) - .groupby(grp_hourly[test]).count())) - out_name = str(Path(output_folder, 'data_{}_test_60min_CVfold_{}.csv'.format(model,k))) - data_60.to_csv(out_name, index=False) - logger.info('Saving data to {:s}'.format(out_name)) + logging.info('No performance score for solid precip for {}'.format(sta)) # train - logger.info('Evaluating train error') + logging.info('Evaluating train error') # 10 min - logger.info('at 10 min') + logging.info('at 10 min') if model not in reference_products: R_pred_10 = regressors[model].predict(features_VERT_AGG[model][train]) else: R_pred_10 = refertab[model].values[train] - - all_scores = calcScore(all_scores, obs=R[train], pred=R_pred_10, - idxTemp = idxTemp, bounds= bounds60, - tagg = '10min', model=model, data_type='train') - - # 60 min - logger.info('at 60 min') + scores_solid = perfscores(R_pred_10[sol_10_train], + R[train][sol_10_train], + bounds = bounds10) + all_scores['10min'][model]['train']['solid'].append(scores_solid) + + scores_liquid = perfscores(R_pred_10[liq_10_train], + R[train][liq_10_train], + bounds = bounds10) + + all_scores['10min'][model]['train']['liquid'].append(scores_liquid) + + scores_all = perfscores(R_pred_10, + R[train], + bounds = bounds10) + all_scores['10min'][model]['train']['all'].append(scores_all) + + R_pred_60 = np.squeeze(np.array(pd.DataFrame(R_pred_10) .groupby(grp_hourly[train]).mean())) - - all_scores = calcScore(all_scores, obs=R_obs_train_60, pred=R_pred_60, - idxTemp = idxTemp, bounds= bounds60, - tagg = '60min', model=model, data_type='train') + + # 60 min + logging.info('at 60 min') + # Evaluate model 10 min + + scores_solid = perfscores(R_pred_60[sol_60_train], + R_train_60[sol_60_train], + bounds = bounds60) + all_scores['60min'][model]['train']['solid'].append(scores_solid) + + scores_liquid = perfscores(R_pred_60[liq_60_train], + R_train_60[liq_60_train], + bounds = bounds60) + all_scores['60min'][model]['train']['liquid'].append(scores_liquid) + + scores_all = perfscores(R_pred_60,R_train_60, + bounds = bounds60) + all_scores['60min'][model]['train']['all'].append(scores_all) # Compute statistics after the 5-fold cross validation @@ -1468,9 +1121,11 @@ def model_intercomparison(self, features_dic, intercomparison_configfile, perfs[score].std().rename('std')], axis=1) + if not os.path.exists(output_folder): os.makedirs(output_folder) + plot_crossval_stats(all_stats, output_folder) name_file = str(Path(output_folder, 'all_scores.p')) pickle.dump(all_scores, open(name_file, 'wb')) name_file = str(Path(output_folder, 'all_scores_stats.p')) @@ -1481,9 +1136,8 @@ def model_intercomparison(self, features_dic, intercomparison_configfile, pickle.dump(all_station_scores, open(name_file, 'wb')) name_file = str(Path(output_folder, 'all_station_stats.p')) pickle.dump(all_station_stats, open(name_file, 'wb')) - - plot_crossval_stats(all_stats, output_folder) - logger.info('Finished script and saved all scores to {}'.format(output_folder)) + + logging.info('Finished script and saved all scores to {}'.format(output_folder)) return all_scores, all_stats diff --git a/rainforest/ml/rfdefinitions.py b/rainforest/ml/rfdefinitions.py index 9856b12..ae52f88 100644 --- a/rainforest/ml/rfdefinitions.py +++ b/rainforest/ml/rfdefinitions.py @@ -14,7 +14,6 @@ import pickle import numpy as np from sklearn.ensemble import RandomForestRegressor -from doubt import QuantileRegressionForest import os from scipy.interpolate import UnivariateSpline from pathlib import Path @@ -84,8 +83,7 @@ def __init__(self, n_jobs=None, random_state=None, verbose=0, - warm_start=False, - max_samples=None): + warm_start=False): super().__init__(n_estimators = n_estimators, criterion = criterion, max_depth = max_depth, @@ -100,8 +98,7 @@ def __init__(self, n_jobs = n_jobs, random_state = random_state, verbose = verbose, - warm_start = warm_start, - max_samples=None) + warm_start = warm_start) self.degree = degree self.bctype = bctype @@ -187,198 +184,9 @@ def predict(self, X, round_func = None, bc = True): out = func(pred) out[out < 0] = 0 return round_func(out) - - def predict_ens(self, X, round_func = None, bc = True): - """ - Predict regression target for X. - The predicted regression target of an input sample is computed as the - mean predicted regression targets of the trees in the forest. - Parameters - ---------- - X : array-like or sparse matrix of shape (n_samples, n_features) - The input samples. Internally, its dtype will be converted to - ``dtype=np.float32``. If a sparse matrix is provided, it will be - converted into a sparse ``csr_matrix``. - round_func : lambda function - Optional function to apply to outputs (for example to discretize them - using MCH lookup tables). If not provided f(x) = x will be applied - (i.e. no function) - bc : bool - if True the bias correction function will be applied - - Returns - ------- - pred : array (n_samples,n_trees) - The predicted values. - """ - - if round_func == None: - round_func = lambda x: x - - func = lambda x: x - if bc: - if self.bctype in ['cdf','raw']: - func = lambda x : np.polyval(self.p,x) - elif self.bctype == 'spline': - func = lambda x : self.p(x) - - pred = np.empty(shape=[X.shape[0], self.n_estimators]) * np.nan - - for tree in range(self.n_estimators): - pred_tree = self.estimators_[tree].predict(X) - - out = func(pred_tree) - out[out < 0] = 0 - - pred[:,tree] = round_func(out) - - return pred - - -################## - -class QuantileRandomForestRegressorBC(QuantileRegressionForest): - ''' - This is an extension of the RandomForestRegressor regressor class of - sklearn that does additional bias correction, is able - to apply a rounding function to the outputs on the fly and adds a - bit of metadata: - - *bctype* : type of bias correction method - *variables* : name of input features - *beta* : weighting factor in vertical aggregation - *degree* : order of the polyfit used in some bias-correction methods - *metadata* : configuration setup used to train this model - - For *bc_type* tHe available methods are currently "raw": - simple linear fit between prediction and observation, "cdf": linear fit - between sorted predictions and sorted observations and "spline" : - spline fit between sorted predictions and sorted observations. Any - new method should be added in this class in order to be used. - - For any information regarding the parent class from the package doubt see - https://github.com/saattrupdan/doubt (used version: 4.3.1) - - ''' - def __init__(self, - variables, - beta, - visib_weighting, - degree = 1, - bctype = 'cdf', - metadata = {}, - n_estimators=100, - criterion="mse", - max_depth=None, - min_samples_split=2, - min_samples_leaf=1, - min_weight_fraction_leaf=0., - max_features="auto", - max_leaf_nodes=None, - min_impurity_decrease=0., - bootstrap=True, - oob_score=False, - n_jobs=None, - random_state=None, - verbose=0, - warm_start=False): - super().__init__(n_estimators = n_estimators, - criterion = criterion, - max_depth = max_depth, - min_samples_split = min_samples_split, - min_samples_leaf = min_samples_leaf, - min_weight_fraction_leaf = min_weight_fraction_leaf, - max_features = max_features, - max_leaf_nodes = max_leaf_nodes, - n_jobs = n_jobs, - random_state = random_state, - verbose = verbose) - - self.degree = degree - self.bctype = bctype - self.variables = variables - self.beta = beta - self.visib_weighting = visib_weighting - self.metadata = metadata - - def fit(self, X, y): - """ - Fit both estimator and a-posteriori bias correction - Parameters - ---------- - X (array-like or sparse matrix): - The input samples, of shape [n_samples, n_features]. Internally, it - will be converted to `dtype=np.float32` and if a sparse matrix is - provided to a sparse `csr_matrix`. - y (array-like): - The target values (class labels) as integers or strings, of shape - [n_samples] or [n_samples, n_outputs]. - - Returns - ------- - self : object - """ - - super().fit(X,y) - y_pred = super().predict(X) - if self.bctype in ['cdf','raw']: - if self.bctype == 'cdf': - x_ = np.sort(y_pred) - y_ = np.sort(y) - elif self.bctype == 'raw': - x_ = y_pred - y_ = y - self.p = _polyfit_no_inter(x_,y_,self.degree) - elif self.bctype == 'spline': - x_ = np.sort(y_pred) - y_ = np.sort(y) - _,idx = np.unique(x_, return_index = True) - self.p = UnivariateSpline(x_[idx], y_[idx]) - else: - self.p = 1 - - return - - def predict(self, X, round_func = None, bc = True): - """ - Predict regression target for X. - The predicted regression target of an input sample is computed as the - mean predicted regression targets of the trees in the forest. - Parameters - ---------- - X : array-like or sparse matrix of shape (n_samples, n_features) - The input samples. Internally, its dtype will be converted to - ``dtype=np.float32``. If a sparse matrix is provided, it will be - converted into a sparse ``csr_matrix``. - round_func : lambda function - Optional function to apply to outputs (for example to discretize them - using MCH lookup tables). If not provided f(x) = x will be applied - (i.e. no function) - bc : bool - if True the bias correction function will be applied - - Returns - ------- - y : array-like of shape (n_samples,) or (n_samples, n_outputs) - The predicted values. - """ - pred = super().predict(X) - - if round_func == None: - round_func = lambda x: x - - func = lambda x: x - if bc: - if self.bctype in ['cdf','raw']: - func = lambda x : np.polyval(self.p,x) - elif self.bctype == 'spline': - func = lambda x : self.p(x) - out = func(pred) - out[out < 0] = 0 - return round_func(out) ################## - + class MyCustomUnpickler(pickle.Unpickler): """ This is an extension of the pickle Unpickler that handles the diff --git a/rainforest/performance/eval_get_estimates.py b/rainforest/performance/eval_get_estimates.py index 5376dba..6c5c0ec 100644 --- a/rainforest/performance/eval_get_estimates.py +++ b/rainforest/performance/eval_get_estimates.py @@ -10,6 +10,8 @@ import numpy as np import pandas as pd from pathlib import Path +import dask +dask.config.set({'dataframe.query-planning': False}) import dask.dataframe as dd import copy import pickle @@ -435,4 +437,4 @@ def extractEstimatesFromMaps(self, slf_stations=False, tagg_hourly=True, save_ou with open(self.configfile,'a') as yamlfile: yaml.safe_dump({'FILE_60MIN' : save_file_60}, yamlfile) - return \ No newline at end of file + return diff --git a/rainforest/qpe/qpe.py b/rainforest/qpe/qpe.py index 8dcdca2..f4026b2 100644 --- a/rainforest/qpe/qpe.py +++ b/rainforest/qpe/qpe.py @@ -3,10 +3,13 @@ """ Main function to compute the QPE estimations on the Swiss grid -Daniel Wolfensberger, MeteoSwiss/EPFL, daniel.wolfensberger@meteoswiss.ch -Rebecca Gugerli, EPFL/ MeteoSwiss -March 2023 +Daniel Wolfensberger +MeteoSwiss/EPFL +daniel.wolfensberger@epfl.ch +December 2019 +Modified by D. Wolfensberger and R. Gugerli +December 2022 """ @@ -20,8 +23,6 @@ from pathlib import Path import os -import h5py - from pathlib import Path from scipy.ndimage import gaussian_filter from scipy.signal import convolve2d @@ -31,7 +32,7 @@ from pyart.aux_io.odim_h5_writer import write_odim_grid_h5 from pyart.aux_io.odim_h5 import proj4_to_dict - +from ..common.utils import get_version from ..common.logger import logger from ..common import constants from ..common.retrieve_data import retrieve_prod, get_COSMO_T, retrieve_hzt_prod, retrieve_prod_RT, retrieve_hzt_RT @@ -135,7 +136,7 @@ def _features_to_chgrid(features, features_labels, time, missing_files): grid.time['units'] = 'seconds since {:s}'.format( datetime.datetime.strftime(time_start, '%Y-%m-%dT%H:%M:%SZ')) - grid.time['data'] = np.arange(0, 5 *60) + grid.time['data'] = np.arange(0, 5 *60 + 1) grid.origin_latitude['data'] = 46.9524 grid.origin_longitude['data'] = 7.43958333 grid.projection = proj4_to_dict("+proj=somerc +lat_0=46.95240555555556 "+\ @@ -158,6 +159,7 @@ def _features_to_chgrid(features, features_labels, time, missing_files): grid.metadata['source'] = b'ORG:215, CTY:644, CMT:MeteoSwiss (Switzerland)' grid.metadata['version'] = b'H5rad 2.3' + grid.metadata['sw_version'] = get_version() # Add missing radar information quality = 'ADLPW' if len(missing_files) != 0: @@ -205,7 +207,7 @@ def _qpe_to_chgrid(qpe, time, missing_files, precision=2): grid.time['units'] = 'seconds since {:s}'.format( datetime.datetime.strftime(time_start, '%Y-%m-%dT%H:%M:%SZ')) - grid.time['data'] = np.arange(0, 5 *60) + grid.time['data'] = np.arange(0, 5 *60 + 1) grid.origin_latitude['data'] = 46.9524 grid.origin_longitude['data'] = 7.43958333 grid.projection = proj4_to_dict("+proj=somerc +lat_0=46.95240555555556 "+\ @@ -224,6 +226,7 @@ def _qpe_to_chgrid(qpe, time, missing_files, precision=2): grid.fields['radar_estimated_rain_rate']['prodname'] = 'CHRFO' grid.metadata['source'] = b'ORG:215, CTY:644, CMT:MeteoSwiss (Switzerland)' grid.metadata['version'] = b'H5rad 2.3' + grid.metadata['sw_version'] = get_version() # Add missing radar information quality = 'ADLPW' if len(missing_files) != 0: @@ -233,7 +236,17 @@ def _qpe_to_chgrid(qpe, time, missing_files, precision=2): qual_new = qual_new.replace(rad, '-') quality = qual_new grid.metadata['radar'] = quality.encode() - grid.metadata['nodes'] = 'WMO:06661,WMO:06699,WMO:06768,WMO:06726,WMO:06776' + + if '-' not in quality: + grid.metadata['nodes'] = 'WMO:06661,WMO:06699,WMO:06768,WMO:06726,WMO:06776' + else: + # 06661: Albis; 06699: Dôle; 06768: Lema; 06726: Plaine Morte; 06776: Weissfluh + all_wmo = ['WMO:06661','WMO:06699','WMO:06768','WMO:06726','WMO:06776'] + rad_wmo = [] + for ir, rad in enumerate(['A', 'D', 'L', 'P', 'W']): + if rad in quality: + rad_wmo.append(all_wmo[ir]) + grid.metadata['nodes'] = ','.join(rad_wmo) return grid @@ -420,8 +433,9 @@ def fetch_data(self, t0, t1 = None): self.radar_files[rad] = split_by_time(radfiles) self.status_files[rad] = split_by_time(statfiles) - except: - logger.error('Failed to retrieve data for radar {:s}'.format(rad)) + except Exception as error: + error_msg = 'Failed to retrieve data for radar {:s}.\n'.format(rad)+ str(error) + logger.error(error_msg) # Retrieve iso0 height files if 'ISO0_HEIGHT' in self.cosmo_var: @@ -532,7 +546,7 @@ def save_features(self, features, features_labels, t, filepath): def compute(self, output_folder, t0, t1, timestep = 5, - basename = 'RFO%y%j%H%MVH', test_mode = False, ensembles = False): + basename = 'RFO%y%j%H%MVH', test_mode = False): """ Computes QPE values for a given time range and stores them in a folder, in a binary format @@ -646,8 +660,8 @@ def compute(self, output_folder, t0, t1, timestep = 5, logger.info('HZT fields for timestep {} missing, creating empty one'.format(t.strftime('%Y%m%d%H%M'))) """Part one - compute radar variables and mask""" - logger.info('Computing radar variables and masks') # Begin compilation of radarobject + logger.info('Preparing all polar radar data') radobjects = {} for rad in self.config['RADARS']: # if radar does not exist, add to missing file list @@ -662,12 +676,28 @@ def compute(self, output_folder, t0, t1, timestep = 5, # Read raw radar file and create a RADAR object radobjects[rad] = Radar(rad, self.radar_files[rad][t], - self.status_files[rad][t]) + self.status_files[rad][t], + metranet_reader='C') + # try: + # radobjects[rad] = Radar(rad, self.radar_files[rad][t], + # self.status_files[rad][t], + # metranet_reader='C') + # except: + # try: + # wrnmsg = 'Could not read polar radar data for radar {:s}'.format(rad)+\ + # ' with c-reader (default), trying with python-reader' + # logger.warning(wrnmsg) + # radobjects[rad] = Radar(rad, self.radar_files[rad][t], + # self.status_files[rad][t], + # metranet_reader='python') + # except: + # logger.error('Could not read polar radar data of {:s}'.format(rad)) + # if problem with radar file, exclude it and add to missing files list if len(radobjects[rad].radarfields) == 0: self.missing_files[rad] = t - logger.info('Removing timestep {:s} of radar {:s}'.format(str(t), rad)) + logger.warning('Removing timestep {:s} of radar {:s}'.format(str(t), rad)) continue # Process the radar data @@ -678,8 +708,8 @@ def compute(self, output_folder, t0, t1, timestep = 5, radobjects[rad].snr_mask(self.config['SNR_THRESHOLD']) except Exception as e: self.missing_files[rad] = t - logger.info(e) - logger.info('Removing timestep {:s} of radar {:s}'.format(str(t), rad)) + logger.warning(e) + logger.warning('Removing timestep {:s} of radar {:s}'.format(str(t), rad)) continue radobjects[rad].compute_kdp(self.config['KDP_PARAMETERS']) @@ -720,9 +750,11 @@ def compute(self, output_folder, t0, t1, timestep = 5, except: logger.error('No cleanup was defined, unzipped files remain in temp-folder') + logger.info('Processing all sweeps of all radars') for sweep in self.config['SWEEPS']: # Loop on sweeps - logger.info('---') - logger.info('Processing sweep ' + str(sweep)) + if not self.rt: + logger.info('---') + logger.info('Processing sweep ' + str(sweep)) for rad in self.config['RADARS']: # Loop on radars, A,D,L,P,W # If there is no radar file for the specific radar, continue to next radar @@ -733,7 +765,8 @@ def compute(self, output_folder, t0, t1, timestep = 5, logger.info('Processing sweep {} of {} - no data for this timestep!'.format(sweep, rad)) continue else: - logger.info('Processing radar ' + str(rad)) + if not self.rt: + logger.info('Processing radar ' + str(rad) + '; sweep '+str(sweep)) try: """Part two - retrieve radar data at every sweep""" @@ -814,14 +847,16 @@ def compute(self, output_folder, t0, t1, timestep = 5, W * isvalidzh_radsweep)),2) except: - logger.error('Could not compute sweep {:d}'.format(sweep)) raise + logger.error('Could not compute sweep {:d}'.format(sweep)) + pass + """Part four - RF prediction""" + logger.info('Applying RF model to retrieve predictions') # Get QPE estimate # X: current time step; X_prev: previous timestep (t-5min) for k in self.models.keys(): - logger.info('Calculating prediction for model {}'.format(k)) model = self.models[k] X = [] for v in model.variables: @@ -857,64 +892,18 @@ def compute(self, output_folder, t0, t1, timestep = 5, # Convert radar data to precipitation estimates qpe = np.zeros((NBINS_X, NBINS_Y), dtype = np.float32).ravel() - - if len(self.config['QUANTILES'][k]) == 0: - try: - qpe[validrows] = self.models[k].predict(Xcomb[validrows,:]) - ensemble_qpe = np.zeros((NBINS_X, NBINS_Y, self.models[k].n_estimators)) - for tree in range(self.models[k].n_estimators): - qpe_temp = np.zeros((NBINS_X, NBINS_Y), dtype = np.float32).ravel() - qpe_temp[validrows] = self.models[k].estimators_[tree].predict(Xcomb[validrows,:]) - ensemble_qpe[:,:,tree] = np.reshape(qpe_temp, (NBINS_X, NBINS_Y)) - except: - logger.error('Model failed!') - raise - else: - try: - # This will render a tuple with the first element as a traditional - # Random Forest estimation, and second element a 2D array with all - # the quantile estimates - timelog0 = datetime.datetime.now() - qpe_all = self.models[k].predict(Xcomb[validrows,:], - quantiles = self.config['QUANTILES'][k]) - logger.info('Quantile prediction took {} '.format(datetime.datetime.now()-timelog0)) - qpe[validrows] = qpe_all[0] - - quantile_qpe = np.zeros((NBINS_X, NBINS_Y, len(self.config['QUANTILES'][k]))) - for iq, q in enumerate(self.config['QUANTILES'][k]): - qpe_temp = np.zeros((NBINS_X, NBINS_Y), dtype = np.float32).ravel() - qpe_temp[validrows] = qpe_all[1][:,iq] - quantile_qpe[:,:,iq] = np.reshape(qpe_temp, (NBINS_X, NBINS_Y)) - - if ensembles: - ensemble_qpe = np.zeros((NBINS_X, NBINS_Y, self.models[k].n_estimators)) - for tree in range(self.models[k].n_estimators): - qpe_temp = np.zeros((NBINS_X, NBINS_Y), dtype = np.float32).ravel() - qpe_temp[validrows] = self.models[k].estimators_[tree].predict(Xcomb[validrows,:]) - ensemble_qpe[:,:,tree] = np.reshape(qpe_temp, (NBINS_X, NBINS_Y)) - except: - logger.error('Model failed!') - raise + try: + qpe[validrows] = self.models[k].predict(Xcomb[validrows,:]) + except: + raise + logger.error('Model failed!') + pass - if ensembles: - filepath = output_folder + '/' + k+'_ENS' - if not os.path.exists(filepath): - os.mkdir(filepath) - filepath += '/' + tstr - f = h5py.File(filepath, 'w') - f.create_dataset('RFO_ENS', data=ensemble_qpe) - f.close() - logger.info('Continuing with next timestep as we dont apply a temporal integration') - continue - - # Traditional QPE output qpe = np.reshape(qpe, (NBINS_X, NBINS_Y)) - if self.config['SAVE_NON_POSTPROCESSED_DATA']: qpe_no_temp = qpe.copy() """Temporal disaggregation; Rescale qpe through rproxy""" - logger.info('Temporal disaggregation from 10-min to 5min') idx_zh = np.where(np.array(model.variables) == 'zh_VISIB')[0][0] @@ -960,6 +949,7 @@ def compute(self, output_folder, t0, t1, timestep = 5, logger.error("Pysteps is not available, no qpe disaggregation will be performed!") qpe_ac = _disaggregate(comp) + filepath = output_folder + '/' + k +'_AC/' if not os.path.exists(filepath): os.mkdir(filepath) @@ -971,24 +961,7 @@ def compute(self, output_folder, t0, t1, timestep = 5, os.mkdir(filepath) filepath += '/' + tstr self.save_output(qpe, t, filepath) - - if ensembles: - filepath = output_folder + '/' + k+'_ENS' - if not os.path.exists(filepath): - os.mkdir(filepath) - filepath += '/' + tstr - f = h5py.File(filepath, 'w') - f.create_dataset('RFO_ENS', data=ensemble_qpe) - f.close() - - if len(self.config['QUANTILES'][k]) != 0 : - for iq, qu in enumerate(self.config['QUANTILES'][k]): - filepath = output_folder + '/' + k +'_Q{}/'.format(str(qu).replace('.','_')) - if not os.path.exists(filepath): - os.mkdir(filepath) - self.save_output(quantile_qpe[:,:,iq], t, filepath+tstr) - - + if self.config['SAVE_NON_POSTPROCESSED_DATA']: # Coding of folders (0 not applied, 1 applied) # T: temporal disaggregation diff --git a/requirements.txt b/requirements.txt index 123b557..40861fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,3 @@ h5py pysteps xlrd pyproj -doubt \ No newline at end of file diff --git a/setup.py b/setup.py index 8b9d14d..3b176be 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ s = setup(name = "rainforest_mch", description = "RandomForest QPE python library", long_description = "A library to compute a gauge/radar database, train a RF QPE predictor and apply it to generate QPE fields", - version = "1.4.0", + version = "1.4.4", author = 'Rebecca Gugerli, Daniel Wolfensberger', author_email = ' rebecca.gugerli@epfl.ch, daniel.wolfensberger@meteoswiss.ch', license = 'GPL-3.0', diff --git a/tests_ci/qpe/test_qpe.py b/tests_ci/qpe/test_qpe.py index 73a158b..d3442f8 100644 --- a/tests_ci/qpe/test_qpe.py +++ b/tests_ci/qpe/test_qpe.py @@ -4,6 +4,7 @@ import datetime import numpy as np import shutil +import pyart from rainforest.common.object_storage import ObjectStorage from rainforest.qpe import QPEProcessor @@ -32,11 +33,17 @@ def test_qpe(): print(str(Path(cwd, 'test_config.yml'))) qpeproc = QPEProcessor(str(Path(cwd, 'test_config.yml')), models) qpeproc.compute(cwd, t0,t1, basename = '{}{}'.format(names[model], tstr), test_mode = True) - qpe = read_cart(str(Path(cwd, model, datetime.datetime.strftime(t1, '{}{}.h5'.format(names[model], tstr))))) - qpe_field = qpe.data + qpe = pyart.aux_io.read_odim_grid_h5(str(Path(cwd, model, datetime.datetime.strftime(t1, + '{}{}.h5'.format(names[model], tstr))))) # Assertions - assert qpe_field.shape == (640, 710) or qpe_field.shape == (1,640, 710) - assert len(np.unique(qpe_field)) > 2 + # Data + assert 'radar_estimated_rain_rate' in qpe.fields + assert qpe.fields['radar_estimated_rain_rate']['data'].shape == (1,640, 710) + assert len(np.unique(qpe.fields['radar_estimated_rain_rate']['data'])) > 2 + + # Time + assert qpe.time['units'] == 'seconds since 2022-09-28T05:05:00Z' + assert qpe.time['data'] == [0, 300] shutil.rmtree(str(Path(cwd, model))) diff --git a/tests_cscs/summary.txt b/tests_cscs/summary.txt index 8b0e609..b9894c1 100644 --- a/tests_cscs/summary.txt +++ b/tests_cscs/summary.txt @@ -6,3 +6,4 @@ 20191019;1571443200;1571443200;1;304;tests_cscs/test_task_file.txt 20191019;1571443200;1571443200;1;304;tests_cscs/test_task_file.txt 20191019;1571443200;1571443200;1;304;tests_cscs/test_task_file.txt +20191019;1571443200;1571443200;1;304;tests_cscs/test_task_file.txt