@@ -245,8 +245,7 @@ inline void points_in_path(PointArray &points,
245245 typedef agg::conv_curve<no_nans_t > curve_t ;
246246 typedef agg::conv_contour<curve_t > contour_t ;
247247
248- size_t i;
249- for (i = 0 ; i < safe_first_shape (points); ++i) {
248+ for (auto i = 0 ; i < safe_first_shape (points); ++i) {
250249 result[i] = false ;
251250 }
252251
@@ -270,10 +269,11 @@ template <class PathIterator>
270269inline bool point_in_path (
271270 double x, double y, const double r, PathIterator &path, agg::trans_affine &trans)
272271{
273- npy_intp shape[] = {1 , 2 };
274- numpy::array_view<double , 2 > points (shape);
275- points (0 , 0 ) = x;
276- points (0 , 1 ) = y;
272+ py::ssize_t shape[] = {1 , 2 };
273+ py::array_t <double > points_arr (shape);
274+ *points_arr.mutable_data (0 , 0 ) = x;
275+ *points_arr.mutable_data (0 , 1 ) = y;
276+ auto points = points_arr.mutable_unchecked <2 >();
277277
278278 int result[1 ];
279279 result[0 ] = 0 ;
@@ -292,10 +292,11 @@ inline bool point_on_path(
292292 typedef agg::conv_curve<no_nans_t > curve_t ;
293293 typedef agg::conv_stroke<curve_t > stroke_t ;
294294
295- npy_intp shape[] = {1 , 2 };
296- numpy::array_view<double , 2 > points (shape);
297- points (0 , 0 ) = x;
298- points (0 , 1 ) = y;
295+ py::ssize_t shape[] = {1 , 2 };
296+ py::array_t <double > points_arr (shape);
297+ *points_arr.mutable_data (0 , 0 ) = x;
298+ *points_arr.mutable_data (0 , 1 ) = y;
299+ auto points = points_arr.mutable_unchecked <2 >();
299300
300301 int result[1 ];
301302 result[0 ] = 0 ;
@@ -382,20 +383,19 @@ void get_path_collection_extents(agg::trans_affine &master_transform,
382383 throw std::runtime_error (" Offsets array must have shape (N, 2)" );
383384 }
384385
385- size_t Npaths = paths.size ();
386- size_t Noffsets = safe_first_shape (offsets);
387- size_t N = std::max (Npaths, Noffsets);
388- size_t Ntransforms = std::min (safe_first_shape (transforms), N);
389- size_t i;
386+ auto Npaths = paths.size ();
387+ auto Noffsets = safe_first_shape (offsets);
388+ auto N = std::max (Npaths, Noffsets);
389+ auto Ntransforms = std::min (safe_first_shape (transforms), N);
390390
391391 agg::trans_affine trans;
392392
393393 reset_limits (extent);
394394
395- for (i = 0 ; i < N; ++i) {
395+ for (auto i = 0 ; i < N; ++i) {
396396 typename PathGenerator::path_iterator path (paths (i % Npaths));
397397 if (Ntransforms) {
398- size_t ti = i % Ntransforms;
398+ py:: ssize_t ti = i % Ntransforms;
399399 trans = agg::trans_affine (transforms (ti, 0 , 0 ),
400400 transforms (ti, 1 , 0 ),
401401 transforms (ti, 0 , 1 ),
@@ -429,24 +429,23 @@ void point_in_path_collection(double x,
429429 bool filled,
430430 std::vector<int > &result)
431431{
432- size_t Npaths = paths.size ();
432+ auto Npaths = paths.size ();
433433
434434 if (Npaths == 0 ) {
435435 return ;
436436 }
437437
438- size_t Noffsets = safe_first_shape (offsets);
439- size_t N = std::max (Npaths, Noffsets);
440- size_t Ntransforms = std::min (safe_first_shape (transforms), N);
441- size_t i;
438+ auto Noffsets = safe_first_shape (offsets);
439+ auto N = std::max (Npaths, Noffsets);
440+ auto Ntransforms = std::min (safe_first_shape (transforms), N);
442441
443442 agg::trans_affine trans;
444443
445- for (i = 0 ; i < N; ++i) {
444+ for (auto i = 0 ; i < N; ++i) {
446445 typename PathGenerator::path_iterator path = paths (i % Npaths);
447446
448447 if (Ntransforms) {
449- size_t ti = i % Ntransforms;
448+ auto ti = i % Ntransforms;
450449 trans = agg::trans_affine (transforms (ti, 0 , 0 ),
451450 transforms (ti, 1 , 0 ),
452451 transforms (ti, 0 , 1 ),
@@ -1224,17 +1223,15 @@ bool convert_to_string(PathIterator &path,
12241223}
12251224
12261225template <class T >
1227- bool is_sorted_and_has_non_nan (PyArrayObject * array)
1226+ bool is_sorted_and_has_non_nan (py:: array_t <T> array)
12281227{
1229- char * ptr = PyArray_BYTES (array);
1230- npy_intp size = PyArray_DIM (array, 0 ),
1231- stride = PyArray_STRIDE (array, 0 );
1228+ auto size = array.shape (0 );
12321229 using limits = std::numeric_limits<T>;
12331230 T last = limits::has_infinity ? -limits::infinity () : limits::min ();
12341231 bool found_non_nan = false ;
12351232
1236- for (npy_intp i = 0 ; i < size; ++i, ptr += stride ) {
1237- T current = *(T*)ptr ;
1233+ for (auto i = 0 ; i < size; ++i) {
1234+ T current = *array. data (i) ;
12381235 // The following tests !isnan(current), but also works for integral
12391236 // types. (The isnan(IntegralType) overload is absent on MSVC.)
12401237 if (current == current) {
0 commit comments