Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4683de5

Browse files
committed
Fix deprecated api usage in cntr.c
1 parent 9df9d31 commit 4683de5

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/cntr.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,8 @@ build_cntr_list_v2(long *np, double *xp, double *yp, short *kp,
15151515
if (kv == NULL) goto error;
15161516

15171517
n = reorder(xpp, ypp, kpp,
1518-
(double *) xyv->data,
1519-
(unsigned char *) kv->data,
1518+
(double *) PyArray_DATA(xyv),
1519+
(unsigned char *) PyArray_DATA(kv),
15201520
np[i]);
15211521
if (n == -1) goto error;
15221522
newshape.len = 2;
@@ -1827,22 +1827,22 @@ Cntr_init(Cntr *self, PyObject *args, PyObject *kwds)
18271827
"x, y, z must be castable to double.");
18281828
goto error;
18291829
}
1830-
iMax = zpa->dimensions[1];
1831-
jMax = zpa->dimensions[0];
1832-
if (xpa->dimensions[0] != jMax || xpa->dimensions[1] != iMax ||
1833-
ypa->dimensions[0] != jMax || ypa->dimensions[1] != iMax ||
1834-
(mpa && (mpa->dimensions[0] != jMax || mpa->dimensions[1] != iMax)))
1830+
iMax = PyArray_DIM(zpa, 1);
1831+
jMax = PyArray_DIM(zpa, 0);
1832+
if (PyArray_DIM(xpa, 0) != jMax || PyArray_DIM(xpa, 1) != iMax ||
1833+
PyArray_DIM(ypa, 0) != jMax || PyArray_DIM(ypa, 1) != iMax ||
1834+
(mpa && (PyArray_DIM(mpa, 0) != jMax || PyArray_DIM(mpa, 1) != iMax)))
18351835
{
18361836
PyErr_SetString(PyExc_ValueError,
18371837
"Arguments x, y, z, mask (if present)"
18381838
" must have the same dimensions.");
18391839
goto error;
18401840
}
1841-
if (mpa) mask = mpa->data;
1841+
if (mpa) mask = PyArray_DATA(mpa);
18421842
else mask = NULL;
1843-
if ( cntr_init(self->site, iMax, jMax, (double *)xpa->data,
1844-
(double *)ypa->data,
1845-
(double *)zpa->data, mask))
1843+
if ( cntr_init(self->site, iMax, jMax, (double *)PyArray_DATA(xpa),
1844+
(double *)PyArray_DATA(ypa),
1845+
(double *)PyArray_DATA(zpa), mask))
18461846
{
18471847
PyErr_SetString(PyExc_MemoryError,
18481848
"Memory allocation failure in cntr_init");
@@ -1895,9 +1895,10 @@ Cntr_get_cdata(Cntr *self)
18951895
dims[1] = nj = self->site->jmax;
18961896

18971897
Cdata = (PyArrayObject *) PyArray_SimpleNew(2, dims, NPY_SHORT);
1898+
char* const data = PyArray_DATA(Cdata);
18981899
for (j=0; j<nj; j++)
18991900
for (i=0; i<ni; i++)
1900-
Cdata->data[j + i*nj] = self->site->data[i + j*ni];
1901+
data[j + i*nj] = self->site->data[i + j*ni];
19011902
/* output is C-order, input is F-order */
19021903
/* for now we are ignoring the last ni+1 values */
19031904
return (PyObject *)Cdata;

0 commit comments

Comments
 (0)