Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02fa8fc

Browse filesBrowse files
committed
Replace some calls to array_view.size with .shape(0)
The other dimensions have already been confirmed to be non-zero, so size() == shape(0) in these cases.
1 parent c1e6873 commit 02fa8fc
Copy full SHA for 02fa8fc

File tree

Expand file treeCollapse file tree

4 files changed

+17
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+17
-9
lines changed
Open diff view settings
Collapse file

‎lib/matplotlib/tests/test_transforms.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_transforms.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,9 @@ def test_invalid_arguments():
627627
t.transform([])
628628
with pytest.raises(RuntimeError):
629629
t.transform([1])
630-
with pytest.raises(RuntimeError):
630+
with pytest.raises(ValueError):
631631
t.transform([[1]])
632-
with pytest.raises(RuntimeError):
632+
with pytest.raises(ValueError):
633633
t.transform([[1, 2, 3]])
634634

635635

Collapse file

‎src/_backend_agg_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_backend_agg_wrapper.cpp
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,13 @@ PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args)
456456
&trans)) {
457457
return NULL;
458458
}
459-
if (points.size() && !check_trailing_shape(points, "points", 3, 2)) {
459+
if (points.shape(0) && !check_trailing_shape(points, "points", 3, 2)) {
460460
return NULL;
461461
}
462-
if (colors.size() && !check_trailing_shape(colors, "colors", 3, 4)) {
462+
if (colors.shape(0) && !check_trailing_shape(colors, "colors", 3, 4)) {
463463
return NULL;
464464
}
465-
if (points.size() != colors.size()) {
465+
if (points.shape(0) != colors.shape(0)) {
466466
PyErr_Format(PyExc_ValueError,
467467
"points and colors arrays must be the same length, got "
468468
"%" NPY_INTP_FMT " points and %" NPY_INTP_FMT "colors",
Collapse file

‎src/_path.h‎

Copy file name to clipboardExpand all lines: src/_path.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ void affine_transform_2d(VerticesArray &vertices, agg::trans_affine &trans, Resu
713713
throw std::runtime_error("Invalid vertices array.");
714714
}
715715

716-
size_t n = vertices.size();
716+
size_t n = vertices.shape(0);
717717
double x;
718718
double y;
719719
double t0;
Collapse file

‎src/_path_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_path_wrapper.cpp
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ static PyObject *Py_points_in_path(PyObject *self, PyObject *args)
8383
return NULL;
8484
}
8585

86-
npy_intp dims[] = { (npy_intp)points.size() };
86+
if (!check_trailing_shape(points, "points", 2)) {
87+
return NULL;
88+
}
89+
90+
npy_intp dims[] = { (npy_intp)points.shape(0) };
8791
numpy::array_view<uint8_t, 1> results(dims);
8892

8993
CALL_CPP("points_in_path", (points_in_path(points, r, path, trans, results)));
@@ -361,15 +365,19 @@ static PyObject *Py_affine_transform(PyObject *self, PyObject *args)
361365
numpy::array_view<double, 2> vertices(vertices_arr);
362366
Py_DECREF(vertices_arr);
363367

364-
npy_intp dims[] = { (npy_intp)vertices.size(), 2 };
368+
if(!check_trailing_shape(vertices, "vertices", 2)) {
369+
return NULL;
370+
}
371+
372+
npy_intp dims[] = { (npy_intp)vertices.shape(0), 2 };
365373
numpy::array_view<double, 2> result(dims);
366374
CALL_CPP("affine_transform", (affine_transform_2d(vertices, trans, result)));
367375
return result.pyobj();
368376
} else { // PyArray_NDIM(vertices_arr) == 1
369377
numpy::array_view<double, 1> vertices(vertices_arr);
370378
Py_DECREF(vertices_arr);
371379

372-
npy_intp dims[] = { (npy_intp)vertices.size() };
380+
npy_intp dims[] = { (npy_intp)vertices.shape(0) };
373381
numpy::array_view<double, 1> result(dims);
374382
CALL_CPP("affine_transform", (affine_transform_1d(vertices, trans, result)));
375383
return result.pyobj();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.