Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commita7aaa83

Browse files
committed
Merge pull request#1195 from pelson/pickle_fix_2
Fixed pickle tests to use the BufferIO object for python3 support.
2 parents0eb6c8c +40fc5d6 commita7aaa83

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

‎lib/matplotlib/tests/test_pickle.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
importcPickleaspickle
1212
#import pickle
1313

14-
fromcStringIOimportStringIO
14+
fromioimportBytesIO
1515

1616

1717
defdepth_getter(obj,
@@ -87,7 +87,7 @@ def recursive_pickle(top_obj):
8787
for_,obj,locationinobjs:
8888
# print('trying %s' % location)
8989
try:
90-
pickle.dump(obj,StringIO(),pickle.HIGHEST_PROTOCOL)
90+
pickle.dump(obj,BytesIO(),pickle.HIGHEST_PROTOCOL)
9191
exceptException,err:
9292
print(obj)
9393
print('Failed to pickle %s.\n Type: %s. Traceback follows:'% (location,type(obj)))
@@ -99,21 +99,21 @@ def test_simple():
9999
fig=plt.figure()
100100
# un-comment to debug
101101
# recursive_pickle(fig)
102-
pickle.dump(fig,StringIO(),pickle.HIGHEST_PROTOCOL)
102+
pickle.dump(fig,BytesIO(),pickle.HIGHEST_PROTOCOL)
103103

104104
ax=plt.subplot(121)
105-
pickle.dump(ax,StringIO(),pickle.HIGHEST_PROTOCOL)
105+
pickle.dump(ax,BytesIO(),pickle.HIGHEST_PROTOCOL)
106106

107107
ax=plt.axes(projection='polar')
108108
plt.plot(range(10),label='foobar')
109109
plt.legend()
110110

111111
# recursive_pickle(fig)
112-
pickle.dump(ax,StringIO(),pickle.HIGHEST_PROTOCOL)
112+
pickle.dump(ax,BytesIO(),pickle.HIGHEST_PROTOCOL)
113113

114114
# ax = plt.subplot(121, projection='hammer')
115115
# recursive_pickle(ax, 'figure')
116-
# pickle.dump(ax,StringIO(), pickle.HIGHEST_PROTOCOL)
116+
# pickle.dump(ax,BytesIO(), pickle.HIGHEST_PROTOCOL)
117117

118118

119119
@image_comparison(baseline_images=['multi_pickle'],
@@ -163,7 +163,7 @@ def test_complete():
163163
# Uncomment to debug any unpicklable objects. This is slow (~200 seconds).
164164
# recursive_pickle(fig)
165165

166-
result_fh=StringIO()
166+
result_fh=BytesIO()
167167
pickle.dump(fig,result_fh,pickle.HIGHEST_PROTOCOL)
168168

169169
plt.close('all')
@@ -196,4 +196,4 @@ def test_no_pyplot():
196196
# Uncomment to debug any unpicklable objects. This is slow so is not
197197
# uncommented by default.
198198
# recursive_pickle(fig)
199-
pickle.dump(fig,StringIO(),pickle.HIGHEST_PROTOCOL)
199+
pickle.dump(fig,BytesIO(),pickle.HIGHEST_PROTOCOL)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp