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 7eebf2a

Browse filesBrowse files
authored
Merge pull request #27086 from QuLogic/mpl-namespace
Rename py namespace to mpl in extension code
2 parents aa9353c + 9fa1186 commit 7eebf2a
Copy full SHA for 7eebf2a
Expand file treeCollapse file tree

16 files changed

+108
-102
lines changed

‎src/_backend_agg.cpp

Copy file name to clipboardExpand all lines: src/_backend_agg.cpp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ RendererAgg::restore_region(BufferRegion &region, int xx1, int yy1, int xx2, int
128128
rendererBase.copy_from(rbuf, &rect, x, y);
129129
}
130130

131-
bool RendererAgg::render_clippath(py::PathIterator &clippath,
131+
bool RendererAgg::render_clippath(mpl::PathIterator &clippath,
132132
const agg::trans_affine &clippath_trans,
133133
e_snap_mode snap_mode)
134134
{
135-
typedef agg::conv_transform<py::PathIterator> transformed_path_t;
135+
typedef agg::conv_transform<mpl::PathIterator> transformed_path_t;
136136
typedef PathNanRemover<transformed_path_t> nan_removed_t;
137137
/* Unlike normal Paths, the clip path cannot be clipped to the Figure bbox,
138138
* because it needs to remain a complete closed path, so there is no

‎src/_backend_agg.h

Copy file name to clipboardExpand all lines: src/_backend_agg.h
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class RendererAgg
244244
template <class R>
245245
void set_clipbox(const agg::rect_d &cliprect, R &rasterizer);
246246

247-
bool render_clippath(py::PathIterator &clippath, const agg::trans_affine &clippath_trans, e_snap_mode snap_mode);
247+
bool render_clippath(mpl::PathIterator &clippath, const agg::trans_affine &clippath_trans, e_snap_mode snap_mode);
248248

249249
template <class PathIteratorType>
250250
void _draw_path(PathIteratorType &path, bool has_clippath, const facepair_t &face, GCAgg &gc);
@@ -340,11 +340,11 @@ RendererAgg::_draw_path(path_t &path, bool has_clippath, const facepair_t &face,
340340
rendererBase.reset_clipping(true);
341341

342342
// Create and transform the path
343-
typedef agg::conv_transform<py::PathIterator> hatch_path_trans_t;
343+
typedef agg::conv_transform<mpl::PathIterator> hatch_path_trans_t;
344344
typedef agg::conv_curve<hatch_path_trans_t> hatch_path_curve_t;
345345
typedef agg::conv_stroke<hatch_path_curve_t> hatch_path_stroke_t;
346346

347-
py::PathIterator hatch_path(gc.hatchpath);
347+
mpl::PathIterator hatch_path(gc.hatchpath);
348348
agg::trans_affine hatch_trans;
349349
hatch_trans *= agg::trans_affine_scaling(1.0, -1.0);
350350
hatch_trans *= agg::trans_affine_translation(0.0, 1.0);
@@ -447,7 +447,7 @@ template <class PathIterator>
447447
inline void
448448
RendererAgg::draw_path(GCAgg &gc, PathIterator &path, agg::trans_affine &trans, agg::rgba &color)
449449
{
450-
typedef agg::conv_transform<py::PathIterator> transformed_path_t;
450+
typedef agg::conv_transform<mpl::PathIterator> transformed_path_t;
451451
typedef PathNanRemover<transformed_path_t> nan_removed_t;
452452
typedef PathClipper<nan_removed_t> clipped_t;
453453
typedef PathSnapper<clipped_t> snapped_t;
@@ -490,7 +490,7 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
490490
agg::trans_affine &trans,
491491
agg::rgba color)
492492
{
493-
typedef agg::conv_transform<py::PathIterator> transformed_path_t;
493+
typedef agg::conv_transform<mpl::PathIterator> transformed_path_t;
494494
typedef PathNanRemover<transformed_path_t> nan_removed_t;
495495
typedef PathSnapper<nan_removed_t> snap_t;
496496
typedef agg::conv_curve<snap_t> curve_t;

‎src/_backend_agg_basic_types.h

Copy file name to clipboardExpand all lines: src/_backend_agg_basic_types.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
struct ClipPath
1616
{
17-
py::PathIterator path;
17+
mpl::PathIterator path;
1818
agg::trans_affine trans;
1919
};
2020

@@ -103,7 +103,7 @@ class GCAgg
103103

104104
e_snap_mode snap_mode;
105105

106-
py::PathIterator hatchpath;
106+
mpl::PathIterator hatchpath;
107107
agg::rgba hatch_color;
108108
double hatch_linewidth;
109109

‎src/_backend_agg_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_backend_agg_wrapper.cpp
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static void PyRendererAgg_dealloc(PyRendererAgg *self)
209209
static PyObject *PyRendererAgg_draw_path(PyRendererAgg *self, PyObject *args)
210210
{
211211
GCAgg gc;
212-
py::PathIterator path;
212+
mpl::PathIterator path;
213213
agg::trans_affine trans;
214214
PyObject *faceobj = NULL;
215215
agg::rgba face;
@@ -263,9 +263,9 @@ static PyObject *PyRendererAgg_draw_text_image(PyRendererAgg *self, PyObject *ar
263263
PyObject *PyRendererAgg_draw_markers(PyRendererAgg *self, PyObject *args)
264264
{
265265
GCAgg gc;
266-
py::PathIterator marker_path;
266+
mpl::PathIterator marker_path;
267267
agg::trans_affine marker_path_trans;
268-
py::PathIterator path;
268+
mpl::PathIterator path;
269269
agg::trans_affine trans;
270270
PyObject *faceobj = NULL;
271271
agg::rgba face;
@@ -328,7 +328,7 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args)
328328
{
329329
GCAgg gc;
330330
agg::trans_affine master_transform;
331-
py::PathGenerator paths;
331+
mpl::PathGenerator paths;
332332
numpy::array_view<const double, 3> transforms;
333333
numpy::array_view<const double, 2> offsets;
334334
agg::trans_affine offset_trans;

‎src/_image_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_image_wrapper.cpp
+37-35Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "_image_resample.h"
55
#include "py_converters_11.h"
66

7+
namespace py = pybind11;
8+
using namespace pybind11::literals;
79

810
/**********************************************************************
911
* Free functions
@@ -46,8 +48,8 @@ radius: float, default: 1
4648
)""";
4749

4850

49-
static pybind11::array_t<double>
50-
_get_transform_mesh(const pybind11::object& transform, const pybind11::ssize_t *dims)
51+
static py::array_t<double>
52+
_get_transform_mesh(const py::object& transform, const py::ssize_t *dims)
5153
{
5254
/* TODO: Could we get away with float, rather than double, arrays here? */
5355

@@ -58,8 +60,8 @@ _get_transform_mesh(const pybind11::object& transform, const pybind11::ssize_t *
5860
// If attribute doesn't exist, raises Python AttributeError
5961
auto inverse = transform.attr("inverted")();
6062

61-
pybind11::ssize_t mesh_dims[2] = {dims[0]*dims[1], 2};
62-
pybind11::array_t<double> input_mesh(mesh_dims);
63+
py::ssize_t mesh_dims[2] = {dims[0]*dims[1], 2};
64+
py::array_t<double> input_mesh(mesh_dims);
6365
auto p = input_mesh.mutable_data();
6466

6567
for (auto y = 0; y < dims[0]; ++y) {
@@ -72,7 +74,7 @@ _get_transform_mesh(const pybind11::object& transform, const pybind11::ssize_t *
7274
auto output_mesh = inverse.attr("transform")(input_mesh);
7375

7476
auto output_mesh_array =
75-
pybind11::array_t<double, pybind11::array::c_style | pybind11::array::forcecast>(output_mesh);
77+
py::array_t<double, py::array::c_style | py::array::forcecast>(output_mesh);
7678

7779
if (output_mesh_array.ndim() != 2) {
7880
throw std::runtime_error(
@@ -84,12 +86,12 @@ _get_transform_mesh(const pybind11::object& transform, const pybind11::ssize_t *
8486
}
8587

8688

87-
// Using generic pybind::array for input and output arrays rather than the more usual
88-
// pybind::array_t<type> as function supports multiple array dtypes.
89+
// Using generic py::array for input and output arrays rather than the more usual
90+
// py::array_t<type> as this function supports multiple array dtypes.
8991
static void
90-
image_resample(pybind11::array input_array,
91-
pybind11::array& output_array,
92-
const pybind11::object& transform,
92+
image_resample(py::array input_array,
93+
py::array& output_array,
94+
const py::object& transform,
9395
interpolation_e interpolation,
9496
bool resample_, // Avoid name clash with resample() function
9597
float alpha,
@@ -111,7 +113,7 @@ image_resample(pybind11::array input_array,
111113
}
112114

113115
// Ensure input array is contiguous, regardless of dtype
114-
input_array = pybind11::array::ensure(input_array, pybind11::array::c_style);
116+
input_array = py::array::ensure(input_array, py::array::c_style);
115117

116118
// Validate output array
117119
auto out_ndim = output_array.ndim();
@@ -132,7 +134,7 @@ image_resample(pybind11::array input_array,
132134
throw std::invalid_argument("Input and output arrays have mismatched types");
133135
}
134136

135-
if ((output_array.flags() & pybind11::array::c_style) == 0) {
137+
if ((output_array.flags() & py::array::c_style) == 0) {
136138
throw std::invalid_argument("Output array must be C-contiguous");
137139
}
138140

@@ -150,14 +152,14 @@ image_resample(pybind11::array input_array,
150152

151153
// Only used if transform is not affine.
152154
// Need to keep it in scope for the duration of this function.
153-
pybind11::array_t<double> transform_mesh;
155+
py::array_t<double> transform_mesh;
154156

155157
// Validate transform
156158
if (transform.is_none()) {
157159
params.is_affine = true;
158160
} else {
159161
// Raises Python AttributeError if no such attribute or TypeError if cast fails
160-
bool is_affine = pybind11::cast<bool>(transform.attr("is_affine"));
162+
bool is_affine = py::cast<bool>(transform.attr("is_affine"));
161163

162164
if (is_affine) {
163165
convert_trans_affine(transform, params.affine);
@@ -171,20 +173,20 @@ image_resample(pybind11::array input_array,
171173

172174
if (auto resampler =
173175
(ndim == 2) ? (
174-
(dtype.is(pybind11::dtype::of<std::uint8_t>())) ? resample<agg::gray8> :
175-
(dtype.is(pybind11::dtype::of<std::int8_t>())) ? resample<agg::gray8> :
176-
(dtype.is(pybind11::dtype::of<std::uint16_t>())) ? resample<agg::gray16> :
177-
(dtype.is(pybind11::dtype::of<std::int16_t>())) ? resample<agg::gray16> :
178-
(dtype.is(pybind11::dtype::of<float>())) ? resample<agg::gray32> :
179-
(dtype.is(pybind11::dtype::of<double>())) ? resample<agg::gray64> :
176+
(dtype.is(py::dtype::of<std::uint8_t>())) ? resample<agg::gray8> :
177+
(dtype.is(py::dtype::of<std::int8_t>())) ? resample<agg::gray8> :
178+
(dtype.is(py::dtype::of<std::uint16_t>())) ? resample<agg::gray16> :
179+
(dtype.is(py::dtype::of<std::int16_t>())) ? resample<agg::gray16> :
180+
(dtype.is(py::dtype::of<float>())) ? resample<agg::gray32> :
181+
(dtype.is(py::dtype::of<double>())) ? resample<agg::gray64> :
180182
nullptr) : (
181183
// ndim == 3
182-
(dtype.is(pybind11::dtype::of<std::uint8_t>())) ? resample<agg::rgba8> :
183-
(dtype.is(pybind11::dtype::of<std::int8_t>())) ? resample<agg::rgba8> :
184-
(dtype.is(pybind11::dtype::of<std::uint16_t>())) ? resample<agg::rgba16> :
185-
(dtype.is(pybind11::dtype::of<std::int16_t>())) ? resample<agg::rgba16> :
186-
(dtype.is(pybind11::dtype::of<float>())) ? resample<agg::rgba32> :
187-
(dtype.is(pybind11::dtype::of<double>())) ? resample<agg::rgba64> :
184+
(dtype.is(py::dtype::of<std::uint8_t>())) ? resample<agg::rgba8> :
185+
(dtype.is(py::dtype::of<std::int8_t>())) ? resample<agg::rgba8> :
186+
(dtype.is(py::dtype::of<std::uint16_t>())) ? resample<agg::rgba16> :
187+
(dtype.is(py::dtype::of<std::int16_t>())) ? resample<agg::rgba16> :
188+
(dtype.is(py::dtype::of<float>())) ? resample<agg::rgba32> :
189+
(dtype.is(py::dtype::of<double>())) ? resample<agg::rgba64> :
188190
nullptr)) {
189191
Py_BEGIN_ALLOW_THREADS
190192
resampler(
@@ -199,7 +201,7 @@ image_resample(pybind11::array input_array,
199201

200202

201203
PYBIND11_MODULE(_image, m) {
202-
pybind11::enum_<interpolation_e>(m, "_InterpolationType")
204+
py::enum_<interpolation_e>(m, "_InterpolationType")
203205
.value("NEAREST", NEAREST)
204206
.value("BILINEAR", BILINEAR)
205207
.value("BICUBIC", BICUBIC)
@@ -220,13 +222,13 @@ PYBIND11_MODULE(_image, m) {
220222
.export_values();
221223

222224
m.def("resample", &image_resample,
223-
pybind11::arg("input_array"),
224-
pybind11::arg("output_array"),
225-
pybind11::arg("transform"),
226-
pybind11::arg("interpolation") = interpolation_e::NEAREST,
227-
pybind11::arg("resample") = false,
228-
pybind11::arg("alpha") = 1,
229-
pybind11::arg("norm") = false,
230-
pybind11::arg("radius") = 1,
225+
"input_array"_a,
226+
"output_array"_a,
227+
"transform"_a,
228+
"interpolation"_a = interpolation_e::NEAREST,
229+
"resample"_a = false,
230+
"alpha"_a = 1,
231+
"norm"_a = false,
232+
"radius"_a = 1,
231233
image_resample__doc__);
232234
}

‎src/_path.h

Copy file name to clipboardExpand all lines: src/_path.h
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ inline bool segments_intersect(const double &x1,
856856
template <class PathIterator1, class PathIterator2>
857857
bool path_intersects_path(PathIterator1 &p1, PathIterator2 &p2)
858858
{
859-
typedef PathNanRemover<py::PathIterator> no_nans_t;
859+
typedef PathNanRemover<mpl::PathIterator> no_nans_t;
860860
typedef agg::conv_curve<no_nans_t> curve_t;
861861

862862
if (p1.total_vertices() < 2 || p2.total_vertices() < 2) {
@@ -920,7 +920,7 @@ bool path_intersects_rectangle(PathIterator &path,
920920
double rect_x2, double rect_y2,
921921
bool filled)
922922
{
923-
typedef PathNanRemover<py::PathIterator> no_nans_t;
923+
typedef PathNanRemover<mpl::PathIterator> no_nans_t;
924924
typedef agg::conv_curve<no_nans_t> curve_t;
925925

926926
if (path.total_vertices() == 0) {
@@ -966,7 +966,7 @@ void convert_path_to_polygons(PathIterator &path,
966966
int closed_only,
967967
std::vector<Polygon> &result)
968968
{
969-
typedef agg::conv_transform<py::PathIterator> transformed_path_t;
969+
typedef agg::conv_transform<mpl::PathIterator> transformed_path_t;
970970
typedef PathNanRemover<transformed_path_t> nan_removal_t;
971971
typedef PathClipper<nan_removal_t> clipped_t;
972972
typedef PathSimplifier<clipped_t> simplify_t;
@@ -1032,7 +1032,7 @@ void cleanup_path(PathIterator &path,
10321032
std::vector<double> &vertices,
10331033
std::vector<unsigned char> &codes)
10341034
{
1035-
typedef agg::conv_transform<py::PathIterator> transformed_path_t;
1035+
typedef agg::conv_transform<mpl::PathIterator> transformed_path_t;
10361036
typedef PathNanRemover<transformed_path_t> nan_removal_t;
10371037
typedef PathClipper<nan_removal_t> clipped_t;
10381038
typedef PathSnapper<clipped_t> snapped_t;
@@ -1189,7 +1189,7 @@ bool convert_to_string(PathIterator &path,
11891189
std::string& buffer)
11901190
{
11911191
size_t buffersize;
1192-
typedef agg::conv_transform<py::PathIterator> transformed_path_t;
1192+
typedef agg::conv_transform<mpl::PathIterator> transformed_path_t;
11931193
typedef PathNanRemover<transformed_path_t> nan_removal_t;
11941194
typedef PathClipper<nan_removal_t> clipped_t;
11951195
typedef PathSimplifier<clipped_t> simplify_t;

0 commit comments

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