Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02b5e12

Browse files
committed
Small unrelated cleanups.
- In missing_references.py, splitting on ":" will work even if ":" is not in the string. - Just a linewrap in backend_pdf. - In backend_ps, we can just printout the whole psDefs in a single shot. (the few extra spaces not stripped out don't affect the validity of the PS file and if we *really* worry about the tiny impact on the file size we should just pre-strip the contents of psDefs). - rcsetup.validate_sketch is really just validating that its input is None or three floats.
1 parent 9a24fb7 commit 02b5e12

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

doc/sphinxext/missing_references.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ def _truncate_location(location):
139139
This allows for easy comparison even when line numbers chagne
140140
(as they do regularily).
141141
"""
142-
if ":" in location:
143-
return location.split(":", 1)[0]
144-
return location
142+
return location.split(":", 1)[0]
145143

146144

147145
def _warn_unused_missing_references(app):

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,7 @@ def __init__(self, filename, metadata=None):
538538
self.pageAnnotations = [] # A list of annotations for the current page
539539

540540
# The PDF spec recommends to include every procset
541-
procsets = [Name(x)
542-
for x in "PDF Text ImageB ImageC ImageI".split()]
541+
procsets = [Name(x) for x in "PDF Text ImageB ImageC ImageI".split()]
543542

544543
# Write resource dictionary.
545544
# Possibly TODO: more general ExtGState (graphics state dictionaries)

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,7 @@ def print_figure_impl(fh):
916916
Ndict += len(ps_renderer._character_tracker.used)
917917
print("/mpldict %d dict def" % Ndict, file=fh)
918918
print("mpldict begin", file=fh)
919-
for d in psDefs:
920-
d = d.strip()
921-
for l in d.split('\n'):
922-
print(l.strip(), file=fh)
919+
print("\n".join(psDefs), file=fh)
923920
if not mpl.rcParams['ps.useafm']:
924921
for font_path, chars \
925922
in ps_renderer._character_tracker.used.items():

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,10 @@ def validate_sketch(s):
701701
s = s.lower()
702702
if s == 'none' or s is None:
703703
return None
704-
if isinstance(s, str):
705-
result = tuple([float(v.strip()) for v in s.split(',')])
706-
elif isinstance(s, (list, tuple)):
707-
result = tuple([float(v) for v in s])
708-
if len(result) != 3:
709-
raise ValueError("path.sketch must be a tuple (scale, length, randomness)")
710-
return result
704+
try:
705+
return validate_nseq_float(3)(s)
706+
except ValueError:
707+
raise ValueError("Expected a (scale, length, randomness) triplet")
711708

712709

713710
def _validate_greaterequal0_lessthan1(s):

0 commit comments

Comments
 (0)