Skip to content

Commit 545c2a0

Browse files
committed
Merge pull request matplotlib#4603 from jkseppan/pdf-cleanup
MNT: Minor cleanups in the pdf backend and related files
2 parents 8b5e226 + 99c54f5 commit 545c2a0

File tree

3 files changed

+7
-27
lines changed

3 files changed

+7
-27
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# -*- coding: iso-8859-1 -*-
1+
# -*- coding: utf-8 -*-
22

33
"""
44
A PDF matplotlib backend
5-
Author: Jouni K Sepp�nen <[email protected]>
5+
Author: Jouni K Seppänen <[email protected]>
66
"""
77
from __future__ import (absolute_import, division, print_function,
88
unicode_literals)
99

1010
import six
11-
from six.moves import map
1211

1312
import codecs
1413
import os
@@ -20,14 +19,10 @@
2019

2120
import numpy as np
2221
from six import unichr
23-
from six import BytesIO
22+
from io import BytesIO
2423

2524
from datetime import datetime
2625
from math import ceil, cos, floor, pi, sin
27-
try:
28-
set
29-
except NameError:
30-
from sets import Set as set
3126

3227
import matplotlib
3328
from matplotlib import __version__, rcParams
@@ -592,7 +587,7 @@ def write(self, data):
592587
self.currentstream.write(data)
593588

594589
def output(self, *data):
595-
self.write(fill(list(map(pdfRepr, data))))
590+
self.write(fill([pdfRepr(x) for x in data]))
596591
self.write(b'\n')
597592

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

lib/matplotlib/dviread.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ def _read(self):
148148
while True:
149149
byte = ord(self.file.read(1)[0])
150150
self._dispatch(byte)
151-
# if self.state == _dvistate.inpage:
152-
# matplotlib.verbose.report(
153-
# 'Dvi._read: after %d at %f,%f' %
154-
# (byte, self.h, self.v),
155-
# 'debug-annoying')
156151
if byte == 140: # end of page
157152
return True
158153
if self.state == _dvistate.post_post: # end of file
@@ -282,9 +277,6 @@ def _put_char(self, char):
282277
if font._vf is None:
283278
self.text.append((self.h, self.v, font, char,
284279
font._width_of(char)))
285-
# matplotlib.verbose.report(
286-
# 'Dvi._put_char: %d,%d %d' %(self.h, self.v, char),
287-
# 'debug-annoying')
288280
else:
289281
scale = font._scale
290282
for x, y, f, g, w in font._vf[char].text:
@@ -303,9 +295,6 @@ def _put_rule(self, a, b):
303295
raise ValueError("misplaced put_rule in dvi file")
304296
if a > 0 and b > 0:
305297
self.boxes.append((self.h, self.v, a, b))
306-
# matplotlib.verbose.report(
307-
# 'Dvi._put_rule: %d,%d %d,%d' % (self.h, self.v, a, b),
308-
# 'debug-annoying')
309298

310299
def _nop(self):
311300
pass
@@ -401,10 +390,6 @@ def _fnt_def(self, k, c, s, d, a, l, n):
401390
raise FileNotFoundError("missing font metrics file: %s" % fontname)
402391
if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
403392
raise ValueError('tfm checksum mismatch: %s'%n)
404-
# It seems that the assumption behind the following check is incorrect:
405-
#if d != tfm.design_size:
406-
# raise ValueError, 'tfm design size mismatch: %d in dvi, %d in %s'%\
407-
# (d, tfm.design_size, n)
408393

409394
vf = _vffile(fontname)
410395

lib/matplotlib/type1font.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
unicode_literals)
2727

2828
import six
29-
from six.moves import filter
3029
from six import unichr
3130

3231
import binascii
@@ -209,8 +208,9 @@ def _parse(self):
209208
# Start with reasonable defaults
210209
prop = {'weight': 'Regular', 'ItalicAngle': 0.0, 'isFixedPitch': False,
211210
'UnderlinePosition': -100, 'UnderlineThickness': 50}
212-
tokenizer = self._tokens(self.parts[0])
213-
filtered = filter(lambda x: x[0] != self._whitespace, tokenizer)
211+
filtered = ((token, value)
212+
for token, value in self._tokens(self.parts[0])
213+
if token is not self._whitespace)
214214
# The spec calls this an ASCII format; in Python 2.x we could
215215
# just treat the strings and names as opaque bytes but let's
216216
# turn them into proper Unicode, and be lenient in case of high bytes.

0 commit comments

Comments
 (0)