Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gaetano Raffaele
obiatools
Commits
732632a8
Commit
732632a8
authored
Jul 29, 2021
by
Raffaele Gaetano
Browse files
Changed parsing of optional arrays
parent
342bc860
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.cpp
View file @
732632a8
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment