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

Skip to content

Commit 9df9d31

Browse files
committed
Fix deprecated api usage in _path.cpp
1 parent 9c4f149 commit 9df9d31

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/_path.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ _path_module::points_in_path(const Py::Tuple& args)
382382
PyArray_STRIDE(points_array, 0),
383383
PyArray_STRIDE(points_array, 1),
384384
n, r, path, trans,
385-
(npy_bool *)PyArray_DATA(result));
385+
(npy_bool *)PyArray_DATA((PyArrayObject*)result));
386386
Py_DECREF(points_array);
387387

388388
return Py::Object(result, true);;
@@ -645,7 +645,7 @@ _path_module::get_path_collection_extents(const Py::Tuple& args)
645645
}
646646

647647
size_t Npaths = paths.length();
648-
size_t Noffsets = offsets->dimensions[0];
648+
size_t Noffsets = PyArray_DIM(offsets, 0);
649649
size_t N = std::max(Npaths, Noffsets);
650650
size_t Ntransforms = std::min(transforms_obj.length(), N);
651651
size_t i;
@@ -771,7 +771,7 @@ _path_module::point_in_path_collection(const Py::Tuple& args)
771771
}
772772

773773
size_t Npaths = paths.length();
774-
size_t Noffsets = offsets->dimensions[0];
774+
size_t Noffsets = PyArray_DIM(offsets, 0);
775775
size_t N = std::max(Npaths, Noffsets);
776776
size_t Ntransforms = std::min(transforms_obj.length(), N);
777777
size_t i;
@@ -1125,13 +1125,14 @@ _path_module::clip_path_to_rect(const Py::Tuple &args)
11251125
{
11261126
throw Py::MemoryError("Could not allocate result array");
11271127
}
1128+
double* const data = (double*)PyArray_DATA(pyarray);
11281129
for (size_t i = 0; i < size; ++i)
11291130
{
1130-
((double *)pyarray->data)[2*i] = (*p)[i].x;
1131-
((double *)pyarray->data)[2*i+1] = (*p)[i].y;
1131+
data[2*i] = (*p)[i].x;
1132+
data[2*i+1] = (*p)[i].y;
11321133
}
1133-
((double *)pyarray->data)[2*size] = (*p)[0].x;
1134-
((double *)pyarray->data)[2*size+1] = (*p)[0].y;
1134+
data[2*size] = (*p)[0].x;
1135+
data[2*size+1] = (*p)[0].y;
11351136

11361137
if (PyList_SetItem(py_results, p - results.begin(), (PyObject *)pyarray) == -1)
11371138
{

0 commit comments

Comments
 (0)