Skip to content

Commit 7b066c6

Browse files
authored
Merge pull request #11401 from anntzer/py3
Some py3fications.
2 parents 40b51d5 + 3fa49bc commit 7b066c6

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from itertools import chain, product
1+
from itertools import product
22
from distutils.version import LooseVersion
33
import io
44

@@ -357,7 +357,7 @@ def test_arrow_simple():
357357
shape = ('full', 'left', 'right')
358358
head_starts_at_zero = (True, False)
359359
# Create outer product of values
360-
kwargs = list(product(length_includes_head, shape, head_starts_at_zero))
360+
kwargs = product(length_includes_head, shape, head_starts_at_zero)
361361

362362
fig, axs = plt.subplots(3, 4)
363363
for i, (ax, kwarg) in enumerate(zip(axs.flatten(), kwargs)):
@@ -5041,9 +5041,7 @@ def generate_errorbar_inputs():
50415041
yerr_only = base_xy * yerr_cy
50425042
both_err = base_xy * yerr_cy * xerr_cy
50435043

5044-
test_cyclers = chain(xerr_only, yerr_only, both_err, empty)
5045-
5046-
return test_cyclers
5044+
return [*xerr_only, *yerr_only, *both_err, *empty]
50475045

50485046

50495047
@pytest.mark.parametrize('kwargs', generate_errorbar_inputs())

lib/matplotlib/type1font.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,13 @@ def _transformer(cls, tokens, slant, extend):
243243
def fontname(name):
244244
result = name
245245
if slant:
246-
result += b'_Slant_' + str(int(1000 * slant)).encode('ascii')
246+
result += b'_Slant_%d' % int(1000 * slant)
247247
if extend != 1.0:
248-
result += b'_Extend_' + str(int(1000 * extend)).encode('ascii')
248+
result += b'_Extend_%d' % int(1000 * extend)
249249
return result
250250

251251
def italicangle(angle):
252-
return (str(float(angle) - np.arctan(slant) / np.pi * 180)
253-
.encode('ascii'))
252+
return b'%a' % (float(angle) - np.arctan(slant) / np.pi * 180)
254253

255254
def fontmatrix(array):
256255
array = array.lstrip(b'[').rstrip(b']').split()
@@ -264,19 +263,21 @@ def fontmatrix(array):
264263
newmatrix = np.dot(modifier, oldmatrix)
265264
array[::2] = newmatrix[0:3, 0]
266265
array[1::2] = newmatrix[0:3, 1]
266+
# Not directly using `b'%a' % x for x in array` for now as that
267+
# produces longer reprs on numpy<1.14, causing test failures.
267268
as_string = '[' + ' '.join(str(x) for x in array) + ']'
268269
return as_string.encode('latin-1')
269270

270271
def replace(fun):
271272
def replacer(tokens):
272273
token, value = next(tokens) # name, e.g., /FontMatrix
273-
yield bytes(value)
274+
yield value
274275
token, value = next(tokens) # possible whitespace
275276
while token is _TokenType.whitespace:
276-
yield bytes(value)
277+
yield value
277278
token, value = next(tokens)
278279
if value != b'[': # name/number/etc.
279-
yield bytes(fun(value))
280+
yield fun(value)
280281
else: # array, e.g., [1 2 3]
281282
result = b''
282283
while value != b']':
@@ -298,9 +299,8 @@ def suppress(tokens):
298299

299300
for token, value in tokens:
300301
if token is _TokenType.name and value in table:
301-
for value in table[value](itertools.chain([(token, value)],
302-
tokens)):
303-
yield value
302+
yield from table[value](
303+
itertools.chain([(token, value)], tokens))
304304
else:
305305
yield value
306306

0 commit comments

Comments
 (0)