Skip to content

Commit 1b7047d

Browse files
committed
Original author is Peter Heesterman - Fixed problem with NPY_CARRAY and NPY_CARRAY_RO being unavailable in newer versions of numpy.
1 parent f2d5c8d commit 1b7047d

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

devsupApp/src/dbfield.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ static PyArray_Descr* dbf2np[DBF_MENU+1];
4444
#define PyDataType_ELSIZE(descr) ((descr)->elsize)
4545
#define PyDataType_SET_ELSIZE(descr, size) (descr)->elsize = size
4646
#endif
47-
#ifndef NPY_CARRAY_RO
48-
#define NPY_CARRAY_RO NPY_ARRAY_CARRAY_RO
49-
#endif
50-
#ifndef NPY_CARRAY
51-
#define NPY_CARRAY NPY_ARRAY_CARRAY
52-
#endif
5347
#endif
5448

5549
typedef struct {
@@ -164,7 +158,7 @@ static int assign_array(DBADDR *paddr, PyObject *arr)
164158
}
165159

166160
Py_XINCREF(desc);
167-
if(!(aval = PyArray_FromAny(arr, desc, 1, 2, NPY_CARRAY, arr)))
161+
if(!(aval = PyArray_FromAny(arr, desc, 1, 2, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE, arr)))
168162
return 1;
169163

170164
if(elemsize!=PyArray_ITEMSIZE((PyArrayObject *)aval)) {
@@ -219,7 +213,7 @@ static PyObject* pyField_getval(pyField *self)
219213

220214
if(self->addr.no_elements>1) {
221215
return build_array((PyObject*)self, rawfield, self->addr.field_type,
222-
noe, NPY_CARRAY_RO);
216+
noe, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED);
223217
}
224218
}
225219

@@ -374,7 +368,7 @@ static PyObject *pyField_getarray(pyField *self)
374368
} else
375369
data = self->addr.pfield;
376370

377-
return build_array((PyObject*)self, data, self->addr.field_type, self->addr.no_elements, NPY_CARRAY);
371+
return build_array((PyObject*)self, data, self->addr.field_type, self->addr.no_elements, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE);
378372
}
379373

380374
static PyObject *pyField_getlen(pyField *self)

0 commit comments

Comments
 (0)