Skip to content

Commit 38f0f0a

Browse files
committed
CLN/BUG: Revert 2/3 compat changes to vb_suite
1 parent 93158c5 commit 38f0f0a

File tree

9 files changed

+39
-47
lines changed

9 files changed

+39
-47
lines changed

vb_suite/groupby.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from vbench.api import Benchmark
22
from datetime import datetime
3-
from pandas.compat import map
43

54
common_setup = """from pandas_vb_common import *
65
"""
@@ -285,12 +284,12 @@ def f(g):
285284
share_na = 0.1
286285
287286
dates = date_range('1997-12-31', periods=n_dates, freq='B')
288-
dates = Index(lmap(lambda x: x.year * 10000 + x.month * 100 + x.day, dates))
287+
dates = Index(map(lambda x: x.year * 10000 + x.month * 100 + x.day, dates))
289288
290289
secid_min = int('10000000', 16)
291290
secid_max = int('F0000000', 16)
292291
step = (secid_max - secid_min) // (n_securities - 1)
293-
security_ids = lmap(lambda x: hex(x)[2:10].upper(), range(secid_min, secid_max + 1, step))
292+
security_ids = map(lambda x: hex(x)[2:10].upper(), range(secid_min, secid_max + 1, step))
294293
295294
data_index = MultiIndex(levels=[dates.values, security_ids],
296295
labels=[[i for i in xrange(n_dates) for _ in xrange(n_securities)], range(n_securities) * n_dates],

vb_suite/indexing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
start_date=datetime(2012, 1, 1))
107107

108108
setup = common_setup + """
109-
from pandas.compat import range
110109
import pandas.core.expressions as expr
111110
df = DataFrame(np.random.randn(50000, 100))
112111
df2 = DataFrame(np.random.randn(50000, 100))

vb_suite/make.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def auto_update():
7171
html()
7272
upload()
7373
sendmail()
74-
except (Exception, SystemExit) as inst:
74+
except (Exception, SystemExit), inst:
7575
msg += str(inst) + '\n'
7676
sendmail(msg)
7777

@@ -159,7 +159,7 @@ def _get_config():
159159
func = funcd.get(arg)
160160
if func is None:
161161
raise SystemExit('Do not know how to handle %s; valid args are %s' % (
162-
arg, list(funcd.keys())))
162+
arg, funcd.keys()))
163163
func()
164164
else:
165165
small_docs = False

vb_suite/measure_memory_consumption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def main():
4545

4646
s = Series(results)
4747
s.sort()
48-
print(s)
48+
print((s))
4949

5050
finally:
5151
shutil.rmtree(TMP_DIR)

vb_suite/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
start_date=datetime(2011, 11, 1))
4545

4646
setup = common_setup + """
47-
from pandas.compat import cStringIO as StringIO
47+
from cStringIO import StringIO
4848
import os
4949
N = 10000
5050
K = 8
@@ -63,7 +63,7 @@
6363
read_table_multiple_date = Benchmark(cmd, setup, start_date=sdate)
6464

6565
setup = common_setup + """
66-
from pandas.compat import cStringIO as StringIO
66+
from cStringIO import StringIO
6767
import os
6868
N = 10000
6969
K = 8

vb_suite/perf_HEAD.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
88
"""
99

10-
from pandas.io.common import urlopen
10+
import urllib2
11+
from contextlib import closing
12+
from urllib2 import urlopen
1113
import json
1214

1315
import pandas as pd
14-
import pandas.compat as compat
1516

1617
WEB_TIMEOUT = 10
1718

@@ -24,7 +25,7 @@ def get_travis_data():
2425
if not jobid:
2526
return None, None
2627

27-
with urlopen("https://api.travis-ci.org/workers/") as resp:
28+
with closing(urlopen("https://api.travis-ci.org/workers/")) as resp:
2829
workers = json.loads(resp.read())
2930

3031
host = njobs = None
@@ -71,7 +72,7 @@ def dump_as_gist(data, desc="The Commit", njobs=None):
7172
print("\n\n" + "-" * 80)
7273

7374
gist = json.loads(r.read())
74-
file_raw_url = list(gist['files'].items())[0][1]['raw_url']
75+
file_raw_url = gist['files'].items()[0][1]['raw_url']
7576
print("[vbench-gist-raw_url] %s" % file_raw_url)
7677
print("[vbench-html-url] %s" % gist['html_url'])
7778
print("[vbench-api-url] %s" % gist['url'])
@@ -103,7 +104,7 @@ def main():
103104

104105
except Exception as e:
105106
exit_code = 1
106-
if (isinstance(e, KeyboardInterrupt) or
107+
if (type(e) == KeyboardInterrupt or
107108
'KeyboardInterrupt' in str(d)):
108109
raise KeyboardInterrupt()
109110

@@ -113,7 +114,7 @@ def main():
113114
if d['succeeded']:
114115
print("\nException:\n%s\n" % str(e))
115116
else:
116-
for k, v in sorted(compat.iteritems(d)):
117+
for k, v in sorted(d.iteritems()):
117118
print("{k}: {v}".format(k=k, v=v))
118119

119120
print("------->\n")
@@ -132,7 +133,7 @@ def main():
132133

133134

134135
def get_vbench_log(build_url):
135-
with urlopen(build_url) as r:
136+
with closing(urllib2.urlopen(build_url)) as r:
136137
if not (200 <= r.getcode() < 300):
137138
return
138139

@@ -143,7 +144,7 @@ def get_vbench_log(build_url):
143144
if not s:
144145
return
145146
id = s[0]['id'] # should be just one for now
146-
with urlopen("https://api.travis-ci.org/jobs/%s" % id) as r2:
147+
with closing(urllib2.urlopen("https://api.travis-ci.org/jobs/%s" % id)) as r2:
147148
if not 200 <= r.getcode() < 300:
148149
return
149150
s2 = json.loads(r2.read())
@@ -171,7 +172,7 @@ def convert_json_to_df(results_url):
171172
df contains timings for all successful vbenchmarks
172173
"""
173174

174-
with urlopen(results_url) as resp:
175+
with closing(urlopen(results_url)) as resp:
175176
res = json.loads(resp.read())
176177
timings = res.get("timings")
177178
if not timings:
@@ -215,7 +216,7 @@ def get_results_from_builds(builds):
215216
dfs = OrderedDict()
216217

217218
while True:
218-
with urlopen(url) as r:
219+
with closing(urlopen(url)) as r:
219220
if not (200 <= r.getcode() < 300):
220221
break
221222
builds = json.loads(r.read())
@@ -237,6 +238,6 @@ def mk_unique(df):
237238
dfs = get_all_results(repo_id)
238239
for k in dfs:
239240
dfs[k] = mk_unique(dfs[k])
240-
ss = [pd.Series(v.timing, name=k) for k, v in compat.iteritems(dfs)]
241+
ss = [pd.Series(v.timing, name=k) for k, v in dfs.iteritems()]
241242
results = pd.concat(reversed(ss), 1)
242243
return results

vb_suite/source/conf.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import sys
1414
import os
1515

16-
from pandas.compat import u
17-
1816
# If extensions (or modules to document with autodoc) are in another directory,
1917
# add these directories to sys.path here. If the directory is relative to the
2018
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -51,8 +49,8 @@
5149
master_doc = 'index'
5250

5351
# General information about the project.
54-
project = u('pandas')
55-
copyright = u('2008-2011, the pandas development team')
52+
project = u'pandas'
53+
copyright = u'2008-2011, the pandas development team'
5654

5755
# The version info for the project you're documenting, acts as replacement for
5856
# |version| and |release|, also used in various other places throughout the
@@ -199,8 +197,8 @@
199197
# (source start file, target name, title, author, documentclass [howto/manual]).
200198
latex_documents = [
201199
('index', 'performance.tex',
202-
u('pandas vbench Performance Benchmarks'),
203-
u('Wes McKinney'), 'manual'),
200+
u'pandas vbench Performance Benchmarks',
201+
u'Wes McKinney', 'manual'),
204202
]
205203

206204
# The name of an image file (relative to this directory) to place at the top of

vb_suite/suite.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
from vbench.api import Benchmark, GitRepo
32
from datetime import datetime
43

@@ -91,15 +90,15 @@ def generate_rst_files(benchmarks):
9190
fig_base_path = os.path.join(vb_path, 'figures')
9291

9392
if not os.path.exists(vb_path):
94-
print('creating %s' % vb_path)
93+
print 'creating %s' % vb_path
9594
os.makedirs(vb_path)
9695

9796
if not os.path.exists(fig_base_path):
98-
print('creating %s' % fig_base_path)
97+
print 'creating %s' % fig_base_path
9998
os.makedirs(fig_base_path)
10099

101100
for bmk in benchmarks:
102-
print('Generating rst file for %s' % bmk.name)
101+
print 'Generating rst file for %s' % bmk.name
103102
rst_path = os.path.join(RST_BASE, 'vbench/%s.txt' % bmk.name)
104103

105104
fig_full_path = os.path.join(fig_base_path, '%s.png' % bmk.name)
@@ -121,7 +120,7 @@ def generate_rst_files(benchmarks):
121120
f.write(rst_text)
122121

123122
with open(os.path.join(RST_BASE, 'index.rst'), 'w') as f:
124-
print("""
123+
print >> f, """
125124
Performance Benchmarks
126125
======================
127126
@@ -142,15 +141,15 @@ def generate_rst_files(benchmarks):
142141
.. toctree::
143142
:hidden:
144143
:maxdepth: 3
145-
""", file=f)
144+
"""
146145
for modname, mod_bmks in sorted(by_module.items()):
147-
print(' vb_%s' % modname, file=f)
146+
print >> f, ' vb_%s' % modname
148147
modpath = os.path.join(RST_BASE, 'vb_%s.rst' % modname)
149148
with open(modpath, 'w') as mh:
150149
header = '%s\n%s\n\n' % (modname, '=' * len(modname))
151-
print(header, file=mh)
150+
print >> mh, header
152151

153152
for bmk in mod_bmks:
154-
print(bmk.name, file=mh)
155-
print('-' * len(bmk.name), file=mh)
156-
print('.. include:: vbench/%s.txt\n' % bmk.name, file=mh)
153+
print >> mh, bmk.name
154+
print >> mh, '-' * len(bmk.name)
155+
print >> mh, '.. include:: vbench/%s.txt\n' % bmk.name

vb_suite/test_perf.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
5) print the results to the log file and to stdout.
2626
2727
"""
28-
from __future__ import print_function
2928

30-
from pandas.compat import range, lmap
3129
import shutil
3230
import os
3331
import sys
@@ -139,11 +137,11 @@ def get_results_df(db, rev):
139137
"""Takes a git commit hash and returns a Dataframe of benchmark results
140138
"""
141139
bench = DataFrame(db.get_benchmarks())
142-
results = DataFrame(lmap(list,db.get_rev_results(rev).values()))
140+
results = DataFrame(map(list,db.get_rev_results(rev).values()))
143141

144142
# Sinch vbench.db._reg_rev_results returns an unlabeled dict,
145143
# we have to break encapsulation a bit.
146-
results.columns = list(db._results.c.keys())
144+
results.columns = db._results.c.keys()
147145
results = results.join(bench['name'], on='checksum').set_index("checksum")
148146
return results
149147

@@ -277,8 +275,7 @@ def profile_head_single(benchmark):
277275
err = str(e)
278276
except:
279277
pass
280-
print("%s died with:\n%s\nSkipping...\n" % (benchmark.name,
281-
err))
278+
print("%s died with:\n%s\nSkipping...\n" % (benchmark.name, err))
282279

283280
results.append(d.get('timing',np.nan))
284281
gc.enable()
@@ -299,8 +296,7 @@ def profile_head_single(benchmark):
299296
# return df.set_index("name")[HEAD_COL]
300297

301298
def profile_head(benchmarks):
302-
print("Performing %d benchmarks (%d runs each)" % (len(benchmarks),
303-
args.hrepeats))
299+
print( "Performing %d benchmarks (%d runs each)" % ( len(benchmarks), args.hrepeats))
304300

305301
ss= [profile_head_single(b) for b in benchmarks]
306302
print("\n")
@@ -466,7 +462,7 @@ def main():
466462
def _parse_commit_log(this,repo_path,base_commit=None):
467463
from vbench.git import _convert_timezones
468464
from pandas import Series
469-
from pandas.compat import parse_date
465+
from dateutil import parser as dparser
470466

471467
git_cmd = 'git --git-dir=%s/.git --work-tree=%s ' % (repo_path, repo_path)
472468
githist = git_cmd + ('log --graph --pretty=format:'+
@@ -488,7 +484,7 @@ def _parse_commit_log(this,repo_path,base_commit=None):
488484
_, sha, stamp, message, author = line.split('::', 4)
489485

490486
# parse timestamp into datetime object
491-
stamp = parse_date(stamp)
487+
stamp = dparser.parse(stamp)
492488

493489
shas.append(sha)
494490
timestamps.append(stamp)

0 commit comments

Comments
 (0)