Skip to content

Commit d424668

Browse files
committed
Use size() in place of dim(0)
1 parent 37f4dcd commit d424668

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/_backend_agg_wrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,21 +500,21 @@ PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args, PyObje
500500
return NULL;
501501
}
502502

503-
if (points.dim(1) != 3 || points.dim(2) != 2) {
503+
if (points.size() != 0 && (points.dim(1) != 3 || points.dim(2) != 2)) {
504504
PyErr_Format(PyExc_ValueError,
505505
"points must be a Nx3x2 array, got %dx%dx%d",
506506
points.dim(0), points.dim(1), points.dim(2));
507507
return NULL;
508508
}
509509

510-
if (colors.dim(1) != 3 || colors.dim(2) != 4) {
510+
if (colors.size() != 0 && (colors.dim(1) != 3 || colors.dim(2) != 4)) {
511511
PyErr_Format(PyExc_ValueError,
512512
"colors must be a Nx3x4 array, got %dx%dx%d",
513513
colors.dim(0), colors.dim(1), colors.dim(2));
514514
return NULL;
515515
}
516516

517-
if (points.dim(0) != colors.dim(0)) {
517+
if (points.size() != colors.size()) {
518518
PyErr_Format(PyExc_ValueError,
519519
"points and colors arrays must be the same length, got %d and %d",
520520
points.dim(0), colors.dim(0));

src/_path.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void get_path_collection_extents(agg::trans_affine &master_transform,
358358
agg::trans_affine &offset_trans,
359359
extent_limits &extent)
360360
{
361-
if (offsets.dim(0) != 0 && offsets.dim(1) != 2) {
361+
if (offsets.size() != 0 && offsets.dim(1) != 2) {
362362
throw "Offsets array must be Nx2";
363363
}
364364

@@ -416,7 +416,7 @@ void point_in_path_collection(double x,
416416
return;
417417
}
418418

419-
size_t Noffsets = offsets.dim(0);
419+
size_t Noffsets = offsets.size();
420420
size_t N = std::max(Npaths, Noffsets);
421421
size_t Ntransforms = std::min(transforms.size(), N);
422422
size_t i;
@@ -692,11 +692,11 @@ clip_path_to_rect(PathIterator &path, agg::rect_d &rect, bool inside, std::vecto
692692
template <class VerticesArray, class ResultArray>
693693
void affine_transform_2d(VerticesArray &vertices, agg::trans_affine &trans, ResultArray &result)
694694
{
695-
if (vertices.dim(0) != 0 && vertices.dim(1) != 2) {
695+
if (vertices.size() != 0 && vertices.dim(1) != 2) {
696696
throw "Invalid vertices array.";
697697
}
698698

699-
size_t n = vertices.dim(0);
699+
size_t n = vertices.size();
700700
double x;
701701
double y;
702702
double t0;

src/_path_wrapper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static PyObject *Py_points_in_path(PyObject *self, PyObject *args, PyObject *kwd
7979
return NULL;
8080
}
8181

82-
npy_intp dims[] = { points.dim(0) };
82+
npy_intp dims[] = { points.size() };
8383
numpy::array_view<bool, 1> results(dims);
8484

8585
CALL_CPP("points_in_path", (points_in_path(points, r, path, trans, results)));
@@ -138,7 +138,7 @@ static PyObject *Py_points_on_path(PyObject *self, PyObject *args, PyObject *kwd
138138
return NULL;
139139
}
140140

141-
npy_intp dims[] = { points.dim(0) };
141+
npy_intp dims[] = { points.size() };
142142
numpy::array_view<bool, 1> results(dims);
143143

144144
CALL_CPP("points_on_path", (points_on_path(points, r, path, trans, results)));
@@ -437,15 +437,15 @@ static PyObject *Py_affine_transform(PyObject *self, PyObject *args, PyObject *k
437437

438438
try {
439439
numpy::array_view<double, 2> vertices(vertices_obj);
440-
npy_intp dims[] = { vertices.dim(0), 2 };
440+
npy_intp dims[] = { vertices.size(), 2 };
441441
numpy::array_view<double, 2> result(dims);
442442
CALL_CPP("affine_transform", (affine_transform_2d(vertices, trans, result)));
443443
return result.pyobj();
444444
} catch (py::exception) {
445445
PyErr_Clear();
446446
try {
447447
numpy::array_view<double, 1> vertices(vertices_obj);
448-
npy_intp dims[] = { vertices.dim(0) };
448+
npy_intp dims[] = { vertices.size() };
449449
numpy::array_view<double, 1> result(dims);
450450
CALL_CPP("affine_transform", (affine_transform_1d(vertices, trans, result)));
451451
return result.pyobj();

src/py_converters.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ int convert_points(PyObject *obj, void *pointsp)
529529

530530
points->set(obj);
531531

532-
if (points->dim(0) == 0) {
532+
if (points->size() == 0) {
533533
return 1;
534534
}
535535

@@ -553,7 +553,7 @@ int convert_transforms(PyObject *obj, void *transp)
553553

554554
trans->set(obj);
555555

556-
if (trans->dim(0) == 0) {
556+
if (trans->size() == 0) {
557557
return 1;
558558
}
559559

@@ -577,7 +577,7 @@ int convert_bboxes(PyObject *obj, void *bboxp)
577577

578578
bbox->set(obj);
579579

580-
if (bbox->dim(0) == 0) {
580+
if (bbox->size() == 0) {
581581
return 1;
582582
}
583583

@@ -601,7 +601,7 @@ int convert_colors(PyObject *obj, void *colorsp)
601601

602602
colors->set(obj);
603603

604-
if (colors->dim(0) == 0) {
604+
if (colors->size() == 0) {
605605
return 1;
606606
}
607607

0 commit comments

Comments
 (0)