From 732632a82ab68c86317d0634b729232c9eb8d724 Mon Sep 17 00:00:00 2001 From: Raffaele Gaetano <raffaele@teledetection.fr> Date: Thu, 29 Jul 2021 14:09:36 +0200 Subject: [PATCH] Changed parsing of optional arrays --- src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e1208cb..de448d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -63,11 +63,11 @@ obiatools_zonalstats(PyObject *self, PyObject *args) { if (!w || w == Py_None) { wg = 0; } else { - PyArray_Descr* dtype; - int _ndims; - npy_intp _dims; - PyArrayObject* _w; - PyArray_GetArrayParamsFromObject(w,NULL,1,&dtype,&_ndims,&_dims,&_w,NULL); + PyArray_Descr* dtype = PyArray_DescrFromType(NPY_FLOAT32); + //int _ndims; + //npy_intp _dims; + PyArrayObject* _w = (PyArrayObject*)PyArray_FromAny(w, dtype, 1, 1, NPY_ARRAY_CARRAY, NULL); + //PyArray_GetArrayParamsFromObject(w,NULL,1,&dtype,&_ndims,&_dims,&_w,NULL); wg = (float*)PyArray_DATA(_w); } @@ -76,11 +76,11 @@ obiatools_zonalstats(PyObject *self, PyObject *args) { nvg = new Data[B]; for (k=0; k<B; k++) nvg[k] = -9999.0; } else { - PyArray_Descr* dtype; - int _ndims; - npy_intp _dims; - PyArrayObject* _nv; - PyArray_GetArrayParamsFromObject(nv,NULL,1,&dtype,&_ndims,&_dims,&_nv,NULL); + PyArray_Descr* dtype = PyArray_DescrFromType(NPY_FLOAT32); + //int _ndims; + //npy_intp _dims; + PyArrayObject* _nv = (PyArrayObject*)PyArray_FromAny(nv, dtype, 1, 1, NPY_ARRAY_CARRAY, NULL); + //PyArray_GetArrayParamsFromObject(nv,NULL,1,&dtype,&_ndims,&_dims,&_nv,NULL); nvg = (Data*)PyArray_DATA(_nv); } -- GitLab