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 ec410ab

Browse filesBrowse files
committed
Deprecate functions in backends
1 parent 9caa261 commit ec410ab
Copy full SHA for ec410ab

File tree

Expand file treeCollapse file tree

4 files changed

+98
-56
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+98
-56
lines changed
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Deprecation of helper functions in backends
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The following functions are considered private and deprecated. Vendor the code
5+
of the similarly named private functions if you rely on these functions.
6+
7+
* ``backend_pdf.fill``
8+
* ``backend_ps.quote_ps_string``
9+
* ``backend_svg.escape_attrib``
10+
* ``backend_svg.escape_cdata``
11+
* ``backend_svg.escape_comment``
12+
* ``backend_svg.short_float_fmt``

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@
9393
# * draw_quad_mesh
9494

9595

96+
@_api.deprecated("3.6", alternative="Vendor the code")
9697
def fill(strings, linelen=75):
98+
return _fill(strings, linelen=linelen)
99+
100+
101+
def _fill(strings, linelen=75):
97102
"""
98103
Make one string from sequence of strings, with whitespace in between.
99104
@@ -292,15 +297,15 @@ def pdfRepr(obj):
292297
# anything, so the caller must ensure that PDF names are
293298
# represented as Name objects.
294299
elif isinstance(obj, dict):
295-
return fill([
300+
return _fill([
296301
b"<<",
297302
*[Name(k).pdfRepr() + b" " + pdfRepr(v) for k, v in obj.items()],
298303
b">>",
299304
])
300305

301306
# Lists.
302307
elif isinstance(obj, (list, tuple)):
303-
return fill([b"[", *[pdfRepr(val) for val in obj], b"]"])
308+
return _fill([b"[", *[pdfRepr(val) for val in obj], b"]"])
304309

305310
# The null keyword.
306311
elif obj is None:
@@ -312,7 +317,7 @@ def pdfRepr(obj):
312317

313318
# A bounding box
314319
elif isinstance(obj, BboxBase):
315-
return fill([pdfRepr(val) for val in obj.bounds])
320+
return _fill([pdfRepr(val) for val in obj.bounds])
316321

317322
else:
318323
raise TypeError("Don't know a PDF representation for {} objects"
@@ -833,7 +838,7 @@ def write(self, data):
833838
self.currentstream.write(data)
834839

835840
def output(self, *data):
836-
self.write(fill([pdfRepr(x) for x in data]))
841+
self.write(_fill([pdfRepr(x) for x in data]))
837842
self.write(b'\n')
838843

839844
def beginStream(self, id, len, extra=None, png=None):

‎lib/matplotlib/backends/backend_ps.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_ps.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ def _nums_to_str(*args):
8989
return " ".join(f"{arg:1.3f}".rstrip("0").rstrip(".") for arg in args)
9090

9191

92+
@_api.deprecated("3.6", alternative="Vendor the code")
9293
def quote_ps_string(s):
94+
return _quote_ps_string(s)
95+
96+
97+
def _quote_ps_string(s):
9398
"""
9499
Quote dangerous characters of S for use in a PostScript string constant.
95100
"""
@@ -738,7 +743,7 @@ def draw_gouraud_triangles(self, gc, points, colors, trans):
738743
streamarr['flags'] = 0
739744
streamarr['points'] = (flat_points - points_min) * factor
740745
streamarr['colors'] = flat_colors[:, :3] * 255.0
741-
stream = quote_ps_string(streamarr.tobytes())
746+
stream = _quote_ps_string(streamarr.tobytes())
742747

743748
self._pswriter.write(f"""\
744749
gsave

0 commit comments

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