Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: iso-8859-1 -*-
# -*- coding: utf-8 -*-

"""
A PDF matplotlib backend
Author: Jouni K Sepp�nen <jks@iki.fi>
Author: Jouni K Seppänen <jks@iki.fi>
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
from six.moves import map

import codecs
import os
Expand All @@ -20,14 +19,10 @@

import numpy as np
from six import unichr
from six import BytesIO
from io import BytesIO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://pythonhosted.org/six/ six.BytesIO is StringIO.StringIO in Python 2 not io.BytesIO does that make any difference?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the io.BytesIO version is closer to the corresponding code in Python 3, and six uses StringIO probably because BytesIO was only introduced in 2.6. For example, BytesIO has a readinto method that StringIO lacks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some googling I think you are right.

from datetime import datetime
from math import ceil, cos, floor, pi, sin
try:
set
except NameError:
from sets import Set as set

import matplotlib
from matplotlib import __version__, rcParams
Expand Down Expand Up @@ -592,7 +587,7 @@ def write(self, data):
self.currentstream.write(data)

def output(self, *data):
self.write(fill(list(map(pdfRepr, data))))
self.write(fill([pdfRepr(x) for x in data]))
self.write(b'\n')

def beginStream(self, id, len, extra=None):
Expand Down
15 changes: 0 additions & 15 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ def _read(self):
while True:
byte = ord(self.file.read(1)[0])
self._dispatch(byte)
# if self.state == _dvistate.inpage:
# matplotlib.verbose.report(
# 'Dvi._read: after %d at %f,%f' %
# (byte, self.h, self.v),
# 'debug-annoying')
if byte == 140: # end of page
return True
if self.state == _dvistate.post_post: # end of file
Expand Down Expand Up @@ -282,9 +277,6 @@ def _put_char(self, char):
if font._vf is None:
self.text.append((self.h, self.v, font, char,
font._width_of(char)))
# matplotlib.verbose.report(
# 'Dvi._put_char: %d,%d %d' %(self.h, self.v, char),
# 'debug-annoying')
else:
scale = font._scale
for x, y, f, g, w in font._vf[char].text:
Expand All @@ -303,9 +295,6 @@ def _put_rule(self, a, b):
raise ValueError("misplaced put_rule in dvi file")
if a > 0 and b > 0:
self.boxes.append((self.h, self.v, a, b))
# matplotlib.verbose.report(
# 'Dvi._put_rule: %d,%d %d,%d' % (self.h, self.v, a, b),
# 'debug-annoying')

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

vf = _vffile(fontname)

Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/type1font.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
unicode_literals)

import six
from six.moves import filter
from six import unichr

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