8000 Merge pull request #3675 from mdboom/doc-build-warnings · matplotlib/matplotlib@5305f4a · GitHub
[go: up one dir, main page]

Skip to content

Commit 5305f4a

Browse files
committed
Merge pull request #3675 from mdboom/doc-build-warnings
Additional Warnings in docs build on travis after merge of decxx
2 parents 0a96efb + c0995e5 commit 5305f4a

File tree

4 files changed

+63
-83
lines changed

4 files changed

+63
-83
lines changed

doc/pyplots/annotate_transform.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ax.set_ylim(-1, 1)
1212

1313
xdata, ydata = 5, 0
14-
xdisplay, ydisplay = ax.transData.transform((xdata, ydata))
14+
xdisplay, ydisplay = ax.transData.transform_point((xdata, ydata))
1515

1616
bbox = dict(boxstyle="round", fc="0.8")
1717
arrowprops = dict(

lib/matplotlib/backends/backend_pdf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
18651865
if elt[0] == 'font':
18661866
self.file.output(elt[1], elt[2], Op.selectfont)
18671867
elif elt[0] == 'text':
1868-
curx, cury = mytrans.transform((elt[1], elt[2]))
1868+
curx, cury = mytrans.transform_point((elt[1], elt[2]))
18691869
self._setup_textpos(curx, cury, angle, oldx, oldy)
18701870
oldx, oldy = curx, cury
18711871
if len(elt[3]) == 1:

lib/matplotlib/sankey.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ def _get_angle(a, r):
728728
if prior is None:
729729
if rotation != 0: # By default, none of this is needed.
730730
angles = [_get_angle(angle, rotation) for angle in angles]
731-
rotate = Affine2D().rotate_deg(rotation * 90).transform_point
731+
rotate = Affine2D().rotate_deg(rotation * 90).transform_affine
732732
tips = rotate(tips)
733733
label_locations = rotate(label_locations)
734734
vertices = rotate(vertices)
@@ -737,10 +737,10 @@ def _get_angle(a, r):
737737
rotation = (self.diagrams[prior].angles[connect[0]] -
738738
angles[connect[1]])
739739
angles = [_get_angle(angle, rotation) for angle in angles]
740-
rotate = Affine2D().rotate_deg(rotation * 90).transform_point
740+
rotate = Affine2D().rotate_deg(rotation * 90).transform_affine
741741
tips = rotate(tips)
742742
offset = self.diagrams[prior].tips[connect[0]] - tips[connect[1]]
743-
translate = Affine2D().translate(*offset).transform_point
743+
translate = Affine2D().translate(*offset).transform_affine
744744
tips = translate(tips)
745745
label_locations = translate(rotate(label_locations))
746746
vertices = translate(rotate(vertices))

src/py_converters.cpp

+58-78
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,47 @@
99

1010
extern "C" {
1111

12+
static int convert_string_enum(PyObject *obj, const char *name, const char **names, int *values, int *result)
13+
{
14+
PyObject *bytesobj;
15+
char *str;
16+
17+
if (obj == NULL || obj == Py_None) {
18+
return 1;
19+
}
20+
21+
if (PyUnicode_Check(obj)) {
22+
bytesobj = PyUnicode_AsASCIIString(obj);
23+
if (bytesobj == NULL) {
24+
return 0;
25+
}
26+
} else if (PyBytes_Check(obj)) {
27+
Py_INCREF(obj);
28+
bytesobj = obj;
29+
} else {
30+
PyErr_Format(PyExc_TypeError, "%s must be bytes or unicode", name);
31+
return 0;
32+
}
33+
34+
str = PyBytes_AsString(bytesobj);
35+
if (str == NULL) {
36+
Py_DECREF(bytesobj);
37+
return 0;
38+
}
39+
40+
for ( ; *names != NULL; names++, values++) {
41+
if (strncmp(str, *names, 64) == 0) {
42+
*result = *values;
43+
Py_DECREF(bytesobj);
44+
return 1;
45+
}
46+
}
47+
48+
PyErr_Format(PyExc_ValueError, "invalid %s value", name);
49+
Py_DECREF(bytesobj);
50+
return 0;
51+
}
52+
1253
int convert_from_method(PyObject *obj, const char *name, converter func, void *p)
1354
{
1455
PyObject *value;
@@ -76,76 +117,29 @@ int convert_bool(PyObject *obj, void *p)
76117

77118
int convert_cap(PyObject *capobj, void *capp)
78119
{
79-
PyObject *capstrobj;
80-
char *capstr;
81-
agg::line_cap_e *cap = (agg::line_cap_e *)capp;
82-
83-
if (capobj == NULL || capobj == Py_None) {
84-
return 1;
85-
}
86-
87-
capstrobj = PyUnicode_AsASCIIString(capobj);
88-
if (capstrobj == NULL) {
89-
return 0;
90-
}
120+
const char *names[] = {"butt", "round", "projecting", NULL};
121+
int values[] = {agg::butt_cap, agg::round_cap, agg::square_cap};
122+
int result;
91123

92-
capstr = PyBytes_AsString(capstrobj);
93-
if (capstr == NULL) {
94-
Py_DECREF(capstrobj);
124+
if (!convert_string_enum(capobj, "capstyle", names, values, &result)) {
95125
return 0;
96126
}
97127

98-
if (strncmp(capstr, "butt", 5) == 0) {
99-
*cap = agg::butt_cap;
100-
} else if (strncmp(capstr, "round", 6) == 0) {
101-
*cap = agg::round_cap;
102-
} else if (strncmp(capstr, "projecting", 11) == 0) {
103-
*cap = agg::square_cap;
104-
} else {
105-
PyErr_Format(PyExc_ValueError, "Unknown capstyle '%s'", capstr);
106-
Py_DECREF(capstrobj);
107-
return 0;
108-
}
109-
110-
Py_DECREF(capstrobj);
111-
128+
*(agg::line_cap_e *)capp = (agg::line_cap_e)result;
112129
return 1;
113130
}
114131

115132
int convert_join(PyObject *joinobj, void *joinp)
116133
{
117-
PyObject *joinstrobj;
118-
char *joinstr;
119-
agg::line_join_e *join = (agg::line_join_e *)joinp;
120-
121-
if (joinobj == NULL || joinobj == Py_None) {
122-
return 1;
123-
}
124-
125-
joinstrobj = PyUnicode_AsASCIIString(joinobj);
126-
if (joinstrobj == NULL) {
127-
return 0;
128-
}
134+
const char *names[] = {"miter", "round", "bevel", NULL};
135+
int values[] = {agg::miter_join_revert, agg::round_join, agg::bevel_join};
136+
int result;
129137

130-
joinstr = PyBytes_AsString(joinstrobj);
131-
if (joinstr == NULL) {
132-
Py_DECREF(joinstrobj);
138+
if (!convert_string_enum(joinobj, "joinstyle", names, values, &result)) {
133139
return 0;
134140
}
135141

136-
if (strncmp(joinstr, "miter", 6) == 0) {
137-
*join = agg::miter_join_revert;
138-
} else if (strncmp(joinstr, "round", 6) == 0) {
139-
*join = agg::round_join;
140-
} else if (strncmp(joinstr, "bevel", 6) == 0) {
141-
*join = agg::bevel_join;
142-
} else {
143-
PyErr_Format(PyExc_ValueError, "Unknown joinstyle '%s'", joinstr);
144-
Py_DECREF(joinstrobj);
145-
return 0;
146-
}
147-
148-
Py_DECREF(joinstrobj);
142+
*(agg::line_join_e *)joinp = (agg::line_join_e)result;
149143
return 1;
150144
}
151145

@@ -497,32 +491,18 @@ int convert_gcagg(PyObject *pygc, void *gcp)
497491
int convert_offset_position(PyObject *obj, void *offsetp)
498492
{
499493
e_offset_position *offset = (e_offset_position *)offsetp;
500-
PyObject *offsetstrobj;
501-
char *offsetstr;
494+
const char *names[] = {"data", NULL};
495+
int values[] = {OFFSET_POSITION_DATA};
496+
int result;
502497

503498
*offset = OFFSET_POSITION_FIGURE;
504499

505-
if (obj == NULL || obj == Py_None) {
506-
return 1;
507-
}
508-
509-
offsetstrobj = PyUnicode_AsASCIIString(obj);
510-
if (offsetstrobj == NULL) {
511-
return 0;
512-
}
513-
514-
offsetstr = PyBytes_AsString(offsetstrobj);
515-
if (offsetstr == NULL) {
516-
Py_DECREF(offsetstrobj);
517-
return 0;
518-
}
519-
520-
if (strncmp(offsetstr, "data", 5) == 0) {
521-
*offset = OFFSET_POSITION_DATA;
500+
if (convert_string_enum(obj, "offset_position", names, values, &result)) {
501+
*offset = (e_offset_position)result;
502+
} else {
503+
PyErr_Clear();
522504
}
523505

524-
Py_DECREF(offsetstrobj);
525-
526506
return 1;
527507
}
528508

0 commit comments

Comments
 (0)
0