Skip to content

Commit 1446d1c

Browse files
committed
Rename py namespace to mpl in extension code
This will allow using the standard namespace alias for pybind11.
1 parent aa9353c commit 1446d1c

11 files changed

+49
-50
lines changed

src/_backend_agg.cpp

Lines 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

Lines 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

Lines 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

Lines 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/_path.h

Lines 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;

src/_path_wrapper.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const char *Py_point_in_path__doc__ =
3535
static PyObject *Py_point_in_path(PyObject *self, PyObject *args)
3636
{
3737
double x, y, r;
38-
py::PathIterator path;
38+
mpl::PathIterator path;
3939
agg::trans_affine trans;
4040
bool result;
4141

@@ -68,7 +68,7 @@ static PyObject *Py_points_in_path(PyObject *self, PyObject *args)
6868
{
6969
numpy::array_view<const double, 2> points;
7070
double r;
71-
py::PathIterator path;
71+
mpl::PathIterator path;
7272
agg::trans_affine trans;
7373

7474
if (!PyArg_ParseTuple(args,
@@ -97,7 +97,7 @@ const char *Py_update_path_extents__doc__ =
9797

9898
static PyObject *Py_update_path_extents(PyObject *self, PyObject *args)
9999
{
100-
py::PathIterator path;
100+
mpl::PathIterator path;
101101
agg::trans_affine trans;
102102
agg::rect_d rect;
103103
numpy::array_view<double, 1> minpos;
@@ -177,7 +177,7 @@ const char *Py_get_path_collection_extents__doc__ =
177177
static PyObject *Py_get_path_collection_extents(PyObject *self, PyObject *args)
178178
{
179179
agg::trans_affine master_transform;
180-
py::PathGenerator paths;
180+
mpl::PathGenerator paths;
181181
numpy::array_view<const double, 3> transforms;
182182
numpy::array_view<const double, 2> offsets;
183183
agg::trans_affine offset_trans;
@@ -227,7 +227,7 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args)
227227
{
228228
double x, y, radius;
229229
agg::trans_affine master_transform;
230-
py::PathGenerator paths;
230+
mpl::PathGenerator paths;
231231
numpy::array_view<const double, 3> transforms;
232232
numpy::array_view<const double, 2> offsets;
233233
agg::trans_affine offset_trans;
@@ -280,9 +280,9 @@ const char *Py_path_in_path__doc__ =
280280

281281
static PyObject *Py_path_in_path(PyObject *self, PyObject *args)
282282
{
283-
py::PathIterator a;
283+
mpl::PathIterator a;
284284
agg::trans_affine atrans;
285-
py::PathIterator b;
285+
mpl::PathIterator b;
286286
agg::trans_affine btrans;
287287
bool result;
288288

@@ -314,7 +314,7 @@ const char *Py_clip_path_to_rect__doc__ =
314314

315315
static PyObject *Py_clip_path_to_rect(PyObject *self, PyObject *args)
316316
{
317-
py::PathIterator path;
317+
mpl::PathIterator path;
318318
agg::rect_d rect;
319319
bool inside;
320320
std::vector<Polygon> result;
@@ -407,8 +407,8 @@ const char *Py_path_intersects_path__doc__ =
407407

408408
static PyObject *Py_path_intersects_path(PyObject *self, PyObject *args, PyObject *kwds)
409409
{
410-
py::PathIterator p1;
411-
py::PathIterator p2;
410+
mpl::PathIterator p1;
411+
mpl::PathIterator p2;
412412
agg::trans_affine t1;
413413
agg::trans_affine t2;
414414
int filled = 0;
@@ -453,7 +453,7 @@ const char *Py_path_intersects_rectangle__doc__ =
453453

454454
static PyObject *Py_path_intersects_rectangle(PyObject *self, PyObject *args, PyObject *kwds)
455455
{
456-
py::PathIterator path;
456+
mpl::PathIterator path;
457457
double rect_x1, rect_y1, rect_x2, rect_y2;
458458
bool filled = false;
459459
const char *names[] = { "path", "rect_x1", "rect_y1", "rect_x2", "rect_y2", "filled", NULL };
@@ -489,7 +489,7 @@ const char *Py_convert_path_to_polygons__doc__ =
489489

490490
static PyObject *Py_convert_path_to_polygons(PyObject *self, PyObject *args, PyObject *kwds)
491491
{
492-
py::PathIterator path;
492+
mpl::PathIterator path;
493493
agg::trans_affine trans;
494494
double width = 0.0, height = 0.0;
495495
int closed_only = 1;
@@ -524,7 +524,7 @@ const char *Py_cleanup_path__doc__ =
524524

525525
static PyObject *Py_cleanup_path(PyObject *self, PyObject *args)
526526
{
527-
py::PathIterator path;
527+
mpl::PathIterator path;
528528
agg::trans_affine trans;
529529
bool remove_nans;
530530
agg::rect_d clip_rect;
@@ -631,7 +631,7 @@ const char *Py_convert_to_string__doc__ =
631631

632632
static PyObject *Py_convert_to_string(PyObject *self, PyObject *args)
633633
{
634-
py::PathIterator path;
634+
mpl::PathIterator path;
635635
agg::trans_affine trans;
636636
agg::rect_d cliprect;
637637
PyObject *simplifyobj;

src/ft2font.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static void ft_glyph_warn(FT_ULong charcode)
195195
Py_XDECREF(text_helpers);
196196
Py_XDECREF(tmp);
197197
if (PyErr_Occurred()) {
198-
throw py::exception();
198+
throw mpl::exception();
199199
}
200200
}
201201

src/numpy_cpp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
378378
array_view(PyObject *arr, bool contiguous = false) : m_arr(NULL), m_data(NULL)
379379
{
380380
if (!set(arr, contiguous)) {
381-
throw py::exception();
381+
throw mpl::exception();
382382
}
383383
}
384384

@@ -413,11 +413,11 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
413413
{
414414
PyObject *arr = PyArray_SimpleNew(ND, shape, type_num_of<T>::value);
415415
if (arr == NULL) {
416-
throw py::exception();
416+
throw mpl::exception();
417417
}
418418
if (!set(arr, true)) {
419419
Py_DECREF(arr);
420-
throw py::exception();
420+
throw mpl::exception();
421421
}
422422
Py_DECREF(arr);
423423
}

src/py_adaptors.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ extern "C" {
1818
int convert_path(PyObject *obj, void *pathp);
1919
}
2020

21-
namespace py
22-
{
21+
namespace mpl {
2322

2423
/************************************************************
25-
* py::PathIterator acts as a bridge between Numpy and Agg. Given a
26-
* pair of Numpy arrays, vertices and codes, it iterates over
24+
* mpl::PathIterator acts as a bridge between NumPy and Agg. Given a
25+
* pair of NumPy arrays, vertices and codes, it iterates over
2726
* those vertices and codes, using the standard Agg vertex source
2827
* interface:
2928
*
@@ -66,14 +65,14 @@ class PathIterator
6665
: m_vertices(NULL), m_codes(NULL), m_iterator(0)
6766
{
6867
if (!set(vertices, codes, should_simplify, simplify_threshold))
69-
throw py::exception();
68+
throw mpl::exception();
7069
}
7170

7271
inline PathIterator(PyObject *vertices, PyObject *codes)
7372
: m_vertices(NULL), m_codes(NULL), m_iterator(0)
7473
{
7574
if (!set(vertices, codes))
76-
throw py::exception();
75+
throw mpl::exception();
7776
}
7877

7978
inline PathIterator(const PathIterator &other)
@@ -233,11 +232,11 @@ class PathGenerator
233232

234233
item = PySequence_GetItem(m_paths, i % m_npaths);
235234
if (item == NULL) {
236-
throw py::exception();
235+
throw mpl::exception();
237236
}
238237
if (!convert_path(item, &path)) {
239238
Py_DECREF(item);
240-
throw py::exception();
239+
throw mpl::exception();
241240
}
242241
Py_DECREF(item);
243242
return path;

src/py_converters.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ int convert_trans_affine(PyObject *obj, void *transp)
343343

344344
int convert_path(PyObject *obj, void *pathp)
345345
{
346-
py::PathIterator *path = (py::PathIterator *)pathp;
346+
mpl::PathIterator *path = (mpl::PathIterator *)pathp;
347347

348348
PyObject *vertices_obj = NULL;
349349
PyObject *codes_obj = NULL;
@@ -404,7 +404,7 @@ int convert_path(PyObject *obj, void *pathp)
404404

405405
int convert_pathgen(PyObject *obj, void *pathgenp)
406406
{
407-
py::PathGenerator *paths = (py::PathGenerator *)pathgenp;
407+
mpl::PathGenerator *paths = (mpl::PathGenerator *)pathgenp;
408408
if (!paths->set(obj)) {
409409
PyErr_SetString(PyExc_TypeError, "Not an iterable of paths");
410410
return 0;
@@ -415,7 +415,7 @@ int convert_pathgen(PyObject *obj, void *pathgenp)
415415
int convert_clippath(PyObject *clippath_tuple, void *clippathp)
416416
{
417417
ClipPath *clippath = (ClipPath *)clippathp;
418-
py::PathIterator path;
418+
mpl::PathIterator path;
419419
agg::trans_affine trans;
420420

421421
if (clippath_tuple != NULL && clippath_tuple != Py_None) {

0 commit comments

Comments
 (0)