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 39fb7b5

Browse filesBrowse files
committed
Py3fication of unicode.
1 parent ef5d01a commit 39fb7b5
Copy full SHA for 39fb7b5

File tree

Expand file treeCollapse file tree

12 files changed

+76
-118
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

12 files changed

+76
-118
lines changed
Open diff view settings
Collapse file

‎examples/misc/multipage_pdf.py‎

Copy file name to clipboardExpand all lines: examples/misc/multipage_pdf.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
# We can also set the file's metadata via the PdfPages object:
4848
d = pdf.infodict()
4949
d['Title'] = 'Multipage PDF Example'
50-
d['Author'] = u'Jouni K. Sepp\xe4nen'
50+
d['Author'] = 'Jouni K. Sepp\xe4nen'
5151
d['Subject'] = 'How to create a multipage pdf file and set its metadata'
5252
d['Keywords'] = 'PdfPages multipage keywords author title subject'
5353
d['CreationDate'] = datetime.datetime(2009, 11, 13)
Collapse file

‎examples/pyplots/text_commands.py‎

Copy file name to clipboardExpand all lines: examples/pyplots/text_commands.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Plotting text of many different kinds.
77
"""
8+
89
import matplotlib.pyplot as plt
910

1011
fig = plt.figure()
@@ -22,7 +23,7 @@
2223

2324
ax.text(2, 6, r'an equation: $E=mc^2$', fontsize=15)
2425

25-
ax.text(3, 2, u'unicode: Institut f\374r Festk\366rperphysik')
26+
ax.text(3, 2, 'unicode: Institut f\374r Festk\366rperphysik')
2627

2728
ax.text(0.95, 0.01, 'colored text in axes coords',
2829
verticalalignment='bottom', horizontalalignment='right',
Collapse file

‎lib/matplotlib/sphinxext/tests/tinypages/conf.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/tests/tinypages/conf.py
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
#
31
# tinypages documentation build configuration file, created by
42
# sphinx-quickstart on Tue Mar 18 11:58:34 2014.
53
#
@@ -46,8 +44,8 @@
4644
master_doc = 'index'
4745

4846
# General information about the project.
49-
project = u'tinypages'
50-
copyright = u'2014, Matplotlib developers'
47+
project = 'tinypages'
48+
copyright = '2014, Matplotlib developers'
5149

5250
# The version info for the project you're documenting, acts as replacement for
5351
# |version| and |release|, also used in various other places throughout the
@@ -202,8 +200,8 @@
202200
# (source start file, target name, title,
203201
# author, documentclass [howto, manual, or own class]).
204202
latex_documents = [
205-
('index', 'tinypages.tex', u'tinypages Documentation',
206-
u'Matplotlib developers', 'manual'),
203+
('index', 'tinypages.tex', 'tinypages Documentation',
204+
'Matplotlib developers', 'manual'),
207205
]
208206

209207
# The name of an image file (relative to this directory) to place at the top of
@@ -232,8 +230,8 @@
232230
# One entry per manual page. List of tuples
233231
# (source start file, name, description, authors, manual section).
234232
man_pages = [
235-
('index', 'tinypages', u'tinypages Documentation',
236-
[u'Matplotlib developers'], 1)
233+
('index', 'tinypages', 'tinypages Documentation',
234+
['Matplotlib developers'], 1)
237235
]
238236

239237
# If true, show URL addresses after external links.
@@ -246,8 +244,8 @@
246244
# (source start file, target name, title, author,
247245
# dir menu entry, description, category)
248246
texinfo_documents = [
249-
('index', 'tinypages', u'tinypages Documentation',
250-
u'Matplotlib developers', 'tinypages', 'One line description of project.',
247+
('index', 'tinypages', 'tinypages Documentation',
248+
'Matplotlib developers', 'tinypages', 'One line description of project.',
251249
'Miscellaneous'),
252250
]
253251

Collapse file

‎lib/matplotlib/testing/determinism.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/determinism.py
+23-33Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
Provides utilities to test output reproducibility.
33
"""
44

5-
from __future__ import (absolute_import, division, print_function,
6-
unicode_literals)
7-
8-
import six
9-
105
import io
116
import os
127
import re
8+
import subprocess
139
import sys
14-
from subprocess import check_output
1510

1611
import pytest
1712

@@ -34,11 +29,11 @@ def _determinism_save(objects='mhi', format="pdf", usetex=False):
3429
# use different markers...
3530
ax1 = fig.add_subplot(1, 6, 1)
3631
x = range(10)
37-
ax1.plot(x, [1] * 10, marker=u'D')
38-
ax1.plot(x, [2] * 10, marker=u'x')
39-
ax1.plot(x, [3] * 10, marker=u'^')
40-
ax1.plot(x, [4] * 10, marker=u'H')
41-
ax1.plot(x, [5] * 10, marker=u'v')
32+
ax1.plot(x, [1] * 10, marker='D')
33+
ax1.plot(x, [2] * 10, marker='x')
34+
ax1.plot(x, [3] * 10, marker='^')
35+
ax1.plot(x, [4] * 10, marker='H')
36+
ax1.plot(x, [5] * 10, marker='v')
4237

4338
if 'h' in objects:
4439
# also use different hatch patterns
@@ -63,13 +58,8 @@ def _determinism_save(objects='mhi', format="pdf", usetex=False):
6358
x = range(5)
6459
fig.add_subplot(1, 6, 6).plot(x, x)
6560

66-
if six.PY2 and format == 'ps':
67-
stdout = io.StringIO()
68-
else:
69-
stdout = getattr(sys.stdout, 'buffer', sys.stdout)
61+
stdout = getattr(sys.stdout, 'buffer', sys.stdout)
7062
fig.savefig(stdout, format=format)
71-
if six.PY2 and format == 'ps':
72-
sys.stdout.write(stdout.getvalue())
7363

7464
# Restores SOURCE_DATE_EPOCH
7565
if sde is None:
@@ -94,14 +84,14 @@ def _determinism_check(objects='mhi', format="pdf", usetex=False):
9484
"""
9585
plots = []
9686
for i in range(3):
97-
result = check_output([sys.executable, '-R', '-c',
98-
'import matplotlib; '
99-
'matplotlib._called_from_pytest = True; '
100-
'matplotlib.use(%r); '
101-
'from matplotlib.testing.determinism '
102-
'import _determinism_save;'
103-
'_determinism_save(%r,%r,%r)'
104-
% (format, objects, format, usetex)])
87+
result = subprocess.check_output([
88+
sys.executable, '-R', '-c',
89+
'import matplotlib; '
90+
'matplotlib._called_from_pytest = True; '
91+
'matplotlib.use(%r); '
92+
'from matplotlib.testing.determinism import _determinism_save;'
93+
'_determinism_save(%r, %r, %r)'
94+
% (format, objects, format, usetex)])
10595
plots.append(result)
10696
for p in plots[1:]:
10797
if usetex:
@@ -128,14 +118,14 @@ def _determinism_source_date_epoch(format, string, keyword=b"CreationDate"):
128118
a string to look at when searching for the timestamp in the document
129119
(used in case the test fails).
130120
"""
131-
buff = check_output([sys.executable, '-R', '-c',
132-
'import matplotlib; '
133-
'matplotlib._called_from_pytest = True; '
134-
'matplotlib.use(%r); '
135-
'from matplotlib.testing.determinism '
136-
'import _determinism_save;'
137-
'_determinism_save(%r,%r)'
138-
% (format, "", format)])
121+
buff = subprocess.check_output([
122+
sys.executable, '-R', '-c',
123+
'import matplotlib; '
124+
'matplotlib._called_from_pytest = True; '
125+
'matplotlib.use(%r); '
126+
'from matplotlib.testing.determinism import _determinism_save;'
127+
'_determinism_save(%r, %r)'
128+
% (format, "", format)])
139129
find_keyword = re.compile(b".*" + keyword + b".*")
140130
key = find_keyword.search(buff)
141131
if key:
Collapse file

‎lib/matplotlib/tests/test_afm.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_afm.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from __future__ import absolute_import, division, print_function
4-
from six import BytesIO
1+
from io import BytesIO
52

63
import matplotlib.afm as afm
74

@@ -33,7 +30,7 @@
3330
def test_nonascii_str():
3431
# This tests that we also decode bytes as utf-8 properly.
3532
# Else, font files with non ascii characters fail to load.
36-
inp_str = u"привет"
33+
inp_str = "привет"
3734
byte_str = inp_str.encode("utf8")
3835

3936
ret = afm._to_str(byte_str)
Collapse file

‎lib/matplotlib/tests/test_animation.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_animation.py
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
from __future__ import absolute_import, division, print_function
2-
3-
import six
4-
51
import sys
62
import tempfile
73

@@ -205,14 +201,14 @@ def test_movie_writer_registry():
205201
assert len(animation.writers._registered) > 0
206202
animation.writers.list() # resets dirty state
207203
assert not animation.writers._dirty
208-
mpl.rcParams['animation.ffmpeg_path'] = u"not_available_ever_xxxx"
204+
mpl.rcParams['animation.ffmpeg_path'] = "not_available_ever_xxxx"
209205
assert animation.writers._dirty
210206
animation.writers.list() # resets
211207
assert not animation.writers._dirty
212208
assert not animation.writers.is_available("ffmpeg")
213209
# something which is guaranteed to be available in path
214210
# and exits immediately
215-
bin = u"true" if sys.platform != 'win32' else u"where"
211+
bin = "true" if sys.platform != 'win32' else "where"
216212
mpl.rcParams['animation.ffmpeg_path'] = bin
217213
assert animation.writers._dirty
218214
animation.writers.list() # resets
Collapse file

‎lib/matplotlib/tests/test_backend_pgf.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_pgf.py
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- encoding: utf-8 -*-
2-
from __future__ import absolute_import, division, print_function
3-
41
import os
52
import shutil
63
import subprocess
@@ -73,7 +70,7 @@ def create_figure():
7370

7471
# text and typesetting
7572
plt.plot([0.9], [0.5], "ro", markersize=3)
76-
plt.text(0.9, 0.5, u'unicode (ü, °, µ) and math ($\\mu_i = x_i^2$)',
73+
plt.text(0.9, 0.5, 'unicode (ü, °, µ) and math ($\\mu_i = x_i^2$)',
7774
ha='right', fontsize=20)
7875
plt.ylabel('sans-serif, blue, $\\frac{\\sqrt{x}}{y^2}$..',
7976
family='sans-serif', color='blue')
Collapse file

‎lib/matplotlib/tests/test_backend_ps.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_ps.py
+25-39Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from __future__ import absolute_import, division, print_function
4-
51
import io
62
import re
73

84
import numpy as np
95
import pytest
10-
import six
116

127
import matplotlib
138
import matplotlib.pyplot as plt
@@ -31,13 +26,14 @@
3126
@pytest.mark.flaky(reruns=3)
3227
@pytest.mark.parametrize('format, use_log, rcParams', [
3328
('ps', False, {}),
34-
needs_ghostscript(('ps', False, {'ps.usedistiller': 'ghostscript'})),
35-
needs_usetex(needs_ghostscript(('ps', False, {'text.latex.unicode': True,
36-
'text.usetex': True}))),
29+
needs_ghostscript(
30+
('ps', False, {'ps.usedistiller': 'ghostscript'})),
31+
needs_usetex(needs_ghostscript(
32+
('ps', False, {'text.latex.unicode': True, 'text.usetex': True}))),
3733
('eps', False, {}),
3834
('eps', True, {'ps.useafm': True}),
39-
needs_usetex(needs_ghostscript(('eps', False, {'text.latex.unicode': True,
40-
'text.usetex': True}))),
35+
needs_usetex(needs_ghostscript(
36+
('eps', False, {'text.latex.unicode': True, 'text.usetex': True}))),
4137
], ids=[
4238
'ps',
4339
'ps with distiller',
@@ -50,35 +46,25 @@ def test_savefig_to_stringio(format, use_log, rcParams):
5046
matplotlib.rcParams.update(rcParams)
5147

5248
fig, ax = plt.subplots()
53-
buffers = [
54-
six.moves.StringIO(),
55-
io.StringIO(),
56-
io.BytesIO()]
57-
58-
if use_log:
59-
ax.set_yscale('log')
60-
61-
ax.plot([1, 2], [1, 2])
62-
ax.set_title(u"Déjà vu")
63-
for buffer in buffers:
64-
fig.savefig(buffer, format=format)
65-
66-
values = [x.getvalue() for x in buffers]
67-
68-
if six.PY3:
69-
values = [
70-
values[0].encode('ascii'),
71-
values[1].encode('ascii'),
72-
values[2]]
73-
74-
# Remove comments from the output. This includes things that
75-
# could change from run to run, such as the time.
76-
values = [re.sub(b'%%.*?\n', b'', x) for x in values]
77-
78-
assert values[0] == values[1]
79-
assert values[1] == values[2].replace(b'\r\n', b'\n')
80-
for buffer in buffers:
81-
buffer.close()
49+
50+
with io.StringIO() as s_buf, io.BytesIO() as b_buf:
51+
52+
if use_log:
53+
ax.set_yscale('log')
54+
55+
ax.plot([1, 2], [1, 2])
56+
ax.set_title("Déjà vu")
57+
fig.savefig(s_buf, format=format)
58+
fig.savefig(b_buf, format=format)
59+
60+
s_val = s_buf.getvalue().encode('ascii')
61+
b_val = b_buf.getvalue()
62+
63+
# Remove comments from the output. This includes things that could
64+
# change from run to run, such as the time.
65+
s_val, b_val = [re.sub(b'%%.*?\n', b'', x) for x in [s_val, b_val]]
66+
67+
assert s_val == b_val.replace(b'\r\n', b'\n')
8268

8369

8470
def test_patheffects():
Collapse file

‎lib/matplotlib/tests/test_legend.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_legend.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_various_labels():
106106
fig = plt.figure()
107107
ax = fig.add_subplot(121)
108108
ax.plot(np.arange(4), 'o', label=1)
109-
ax.plot(np.linspace(4, 4.1), 'o', label=u'D\xe9velopp\xe9s')
109+
ax.plot(np.linspace(4, 4.1), 'o', label='Développés')
110110
ax.plot(np.arange(4, 1, -1), 'o', label='__nolegend__')
111111
ax.legend(numpoints=1, loc=0)
112112

Collapse file

‎lib/matplotlib/tests/test_ticker.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
from __future__ import absolute_import, division, print_function
1+
import warnings
22

3-
from numpy.testing import assert_almost_equal
43
import numpy as np
4+
from numpy.testing import assert_almost_equal
55
import pytest
66

77
import matplotlib
88
import matplotlib.pyplot as plt
99
import matplotlib.ticker as mticker
1010

11-
import warnings
12-
1311

1412
class TestMaxNLocator(object):
1513
basic_data = [
@@ -578,7 +576,7 @@ class TestEngFormatter(object):
578576
(-0.0, ('0', '0', '0.00')),
579577
(-0, ('0', '0', '0.00')),
580578
(0, ('0', '0', '0.00')),
581-
(1.23456789e-6, (u'1.23457 \u03bc', u'1 \u03bc', u'1.23 \u03bc')),
579+
(1.23456789e-6, ('1.23457 \u03bc', '1 \u03bc', '1.23 \u03bc')),
582580
(0.123456789, ('123.457 m', '123 m', '123.46 m')),
583581
(0.1, ('100 m', '100 m', '100.00 m')),
584582
(1, ('1', '1', '1.00')),

0 commit comments

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