Skip to content

Commit

Permalink
WHT: break long lines + pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
pv committed Aug 24, 2015
1 parent 8f31e5e commit 02ae0e3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
10 changes: 7 additions & 3 deletions benchmarks/benchmarks/bench_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def setup(self, update):
dy2 = (dy * dy)

def num_update(u, dx2, dy2):
u[1:(-1), 1:(-1)] = ((((u[2:, 1:(-1)] + u[:(-2), 1:(-1)]) * dy2) + ((u[1:(-1), 2:] + u[1:(-1), :(-2)]) * dx2)) / (2 * (dx2 + dy2)))
u[1:(-1), 1:(-1)] = ((((u[2:, 1:(-1)] + u[:(-2), 1:(-1)]) * dy2) +
((u[1:(-1), 2:] + u[1:(-1), :(-2)]) * dx2))
/ (2 * (dx2 + dy2)))

def num_inplace(u, dx2, dy2):
tmp = u[:(-2), 1:(-1)].copy()
Expand All @@ -28,7 +30,8 @@ def num_inplace(u, dx2, dy2):
np.add(tmp2, u[1:(-1), :(-2)], out=tmp2)
np.multiply(tmp2, dx2, out=tmp2)
np.add(tmp, tmp2, out=tmp)
np.multiply(tmp, (1.0 / (2.0 * (dx2 + dy2))), out=u[1:(-1), 1:(-1)])
np.multiply(tmp, (1.0 / (2.0 * (dx2 + dy2))),
out=u[1:(-1), 1:(-1)])

def laplace(N, Niter=100, func=num_update, args=()):
u = np.zeros([N, N], order='C')
Expand All @@ -55,7 +58,8 @@ def setup(self):
nfeat = 100
ntime = 200

self.arrays = [np.random.normal(size=(ntime, nfeat)) for i in xrange(nsubj)]
self.arrays = [np.random.normal(size=(ntime, nfeat))
for i in xrange(nsubj)]

def maxes_of_dots(self, arrays):
"""
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/benchmarks/bench_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ def setup(self, indexes, sel, op):
'indexes_rand_': indexes_rand_}

if sys.version_info[0] >= 3:
code = "def run():\n for a in squares_.values(): a[%s]%s" % (sel, op)
code = "def run():\n for a in squares_.values(): a[%s]%s"
else:
code = "def run():\n for a in squares_.itervalues(): a[%s]%s" % (sel, op)
code = "def run():\n for a in squares_.itervalues(): a[%s]%s"
code = code % (sel, op)

six.exec_(code, ns)
self.func = ns['run']
Expand Down
1 change: 1 addition & 0 deletions benchmarks/benchmarks/bench_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np


class Eindot(Benchmark):
def setup(self):
self.a = np.arange(60000.0).reshape(150, 400)
Expand Down
19 changes: 10 additions & 9 deletions benchmarks/benchmarks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@

# a set of interesting types to test
TYPES1 = [
'int16', 'float16',
'int32', 'float32',
'int64', 'float64', 'complex64',
'longfloat', 'complex128',
'complex256',
]
'int16', 'float16',
'int32', 'float32',
'int64', 'float64', 'complex64',
'longfloat', 'complex128',
'complex256',
]

# values which will be used to construct our sample data matrices
# replicate 10 times to speed up initial imports of this helper
# and generate some redundancy
values = [random.uniform(0, 100) for x in range(nx*ny/10)]*10

squares = {t: numpy.array(values, dtype=getattr(numpy, t)).reshape((nx, ny))
squares = {t: numpy.array(values,
dtype=getattr(numpy, t)).reshape((nx, ny))
for t in TYPES1}

# adjust complex ones to have non-degenerated imagery part -- use
Expand All @@ -38,9 +39,9 @@
v += v.T*1j

# smaller squares
squares_ = {t: s[:nxs, :nys] for t, s in squares.iteritems()}
squares_ = {t: s[:nxs, :nys] for t, s in squares.iteritems()}
# vectors
vectors = {t: s[0] for t, s in squares.iteritems()}
vectors = {t: s[0] for t, s in squares.iteritems()}

indexes = range(nx)
# so we do not have all items
Expand Down
15 changes: 10 additions & 5 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def main(argv):
gcov_reset_counters()

if args.debug and args.bench:
print("*** Benchmarks should not be run against debug version; remove -g flag ***")
print("*** Benchmarks should not be run against debug "
"version; remove -g flag ***")

if not args.no_build:
site_dir = build_project(args)
Expand Down Expand Up @@ -210,19 +211,23 @@ def main(argv):

# Check for uncommitted files
if commit_b == 'HEAD':
r1 = subprocess.call(['git', 'diff-index', '--quiet', '--cached', 'HEAD'])
r1 = subprocess.call(['git', 'diff-index', '--quiet',
'--cached', 'HEAD'])
r2 = subprocess.call(['git', 'diff-files', '--quiet'])
if r1 != 0 or r2 != 0:
print("*"*80)
print("WARNING: you have uncommitted changes --- these will NOT be benchmarked!")
print("WARNING: you have uncommitted changes --- "
"these will NOT be benchmarked!")
print("*"*80)

# Fix commit ids (HEAD is local to current repo)
p = subprocess.Popen(['git', 'rev-parse', commit_b], stdout=subprocess.PIPE)
p = subprocess.Popen(['git', 'rev-parse', commit_b],
stdout=subprocess.PIPE)
out, err = p.communicate()
commit_b = out.strip()

p = subprocess.Popen(['git', 'rev-parse', commit_a], stdout=subprocess.PIPE)
p = subprocess.Popen(['git', 'rev-parse', commit_a],
stdout=subprocess.PIPE)
out, err = p.communicate()
commit_a = out.strip()

Expand Down

0 comments on commit 02ae0e3

Please sign in to comment.