summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJarrod Millman <millman@berkeley.edu>2008-09-02 20:32:38 +0000
committerJarrod Millman <millman@berkeley.edu>2008-09-02 20:32:38 +0000
commitd29107a248130bbb68ecac58d6720d716529141c (patch)
tree9e1408025c80d63fe9fa6151343a7b265ec3f654 /doc
parenta4a7966cf7191c28a7054127fd3717d6c760d556 (diff)
downloadnumpy-d29107a248130bbb68ecac58d6720d716529141c.tar.gz
reindenting prior to release
Diffstat (limited to 'doc')
-rw-r--r--doc/numpybook/comparison/ctypes/filter.py3
-rw-r--r--doc/numpybook/comparison/ctypes/interface.py7
-rw-r--r--doc/numpybook/comparison/pyrex/setup.py4
-rw-r--r--doc/numpybook/comparison/timing.py18
-rw-r--r--doc/numpybook/comparison/weave/filter.py11
-rw-r--r--doc/numpybook/comparison/weave/inline.py10
-rw-r--r--doc/numpybook/runcode.py16
7 files changed, 30 insertions, 39 deletions
diff --git a/doc/numpybook/comparison/ctypes/filter.py b/doc/numpybook/comparison/ctypes/filter.py
index e92aa5eab..1b322aca3 100644
--- a/doc/numpybook/comparison/ctypes/filter.py
+++ b/doc/numpybook/comparison/ctypes/filter.py
@@ -21,6 +21,3 @@ def filter2d(a):
b = N.zeros_like(a)
lib.dfilter2d(a, b, a.ctypes.strides, a.ctypes.shape)
return b
-
-
-
diff --git a/doc/numpybook/comparison/ctypes/interface.py b/doc/numpybook/comparison/ctypes/interface.py
index 06c12aef3..e237f8ded 100644
--- a/doc/numpybook/comparison/ctypes/interface.py
+++ b/doc/numpybook/comparison/ctypes/interface.py
@@ -27,7 +27,7 @@ lib.dfilter2d.argtypes = [N.ctypeslib.ndpointer(float, ndim=2,
flags='aligned, contiguous,'\
'writeable'),
ctypes.POINTER(N.ctypeslib.c_intp),
- ctypes.POINTER(N.ctypeslib.c_intp)]
+ ctypes.POINTER(N.ctypeslib.c_intp)]
def select(dtype):
if dtype.char in ['?bBhHf']:
@@ -49,12 +49,9 @@ def add(a, b):
c = N.empty_like(a)
func(a,b,c,a.size)
return c
-
+
def filter2d(a):
a = N.require(a, float, ['ALIGNED'])
b = N.zeros_like(a)
lib.dfilter2d(a, b, a.ctypes.strides, a.ctypes.shape)
return b
-
-
-
diff --git a/doc/numpybook/comparison/pyrex/setup.py b/doc/numpybook/comparison/pyrex/setup.py
index 64cf12bc8..695639d9e 100644
--- a/doc/numpybook/comparison/pyrex/setup.py
+++ b/doc/numpybook/comparison/pyrex/setup.py
@@ -16,8 +16,8 @@ pyx_ext = Extension('add',
include_dirs = [numpy.get_include()])
pyx_ext2 = Extension('blur',
- ['blur.pyx'],
- include_dirs = [numpy.get_include()])
+ ['blur.pyx'],
+ include_dirs = [numpy.get_include()])
# Call the routine which does the real work
diff --git a/doc/numpybook/comparison/timing.py b/doc/numpybook/comparison/timing.py
index 14841d7cb..92f6a50d2 100644
--- a/doc/numpybook/comparison/timing.py
+++ b/doc/numpybook/comparison/timing.py
@@ -51,13 +51,11 @@ import sys
path = sys.path
for kind in ['f2py']:#['ctypes', 'pyrex', 'weave', 'f2py']:
- res[kind] = []
- sys.path = ['/Users/oliphant/numpybook/%s' % (kind,)] + path
- print sys.path
- for n in N:
- print "%s - %d" % (kind, n)
- t = timeit.Timer(eval('%s_run'%kind), eval('%s_pre %% (%d,%d)'%(kind,n,n)))
- mytime = min(t.repeat(3,100))
- res[kind].append(mytime)
-
-
+ res[kind] = []
+ sys.path = ['/Users/oliphant/numpybook/%s' % (kind,)] + path
+ print sys.path
+ for n in N:
+ print "%s - %d" % (kind, n)
+ t = timeit.Timer(eval('%s_run'%kind), eval('%s_pre %% (%d,%d)'%(kind,n,n)))
+ mytime = min(t.repeat(3,100))
+ res[kind].append(mytime)
diff --git a/doc/numpybook/comparison/weave/filter.py b/doc/numpybook/comparison/weave/filter.py
index b2fdb277e..6fc16c79f 100644
--- a/doc/numpybook/comparison/weave/filter.py
+++ b/doc/numpybook/comparison/weave/filter.py
@@ -8,11 +8,11 @@ def filter(a):
for(i=1;i<Na[0]-1;i++) {
for(j=1;j<Na[1]-1;j++) {
B2(i,j) = A2(i,j) + (A2(i-1,j) +
- A2(i+1,j) + A2(i,j-1)
- + A2(i,j+1))*0.5
- + (A2(i-1,j-1)
- + A2(i-1,j+1)
- + A2(i+1,j-1)
+ A2(i+1,j) + A2(i,j-1)
+ + A2(i,j+1))*0.5
+ + (A2(i-1,j-1)
+ + A2(i-1,j+1)
+ + A2(i+1,j-1)
+ A2(i+1,j+1))*0.25;
}
}
@@ -20,4 +20,3 @@ def filter(a):
b = zeros_like(a)
weave.inline(code,['a','b'])
return b
-
diff --git a/doc/numpybook/comparison/weave/inline.py b/doc/numpybook/comparison/weave/inline.py
index 31499213e..bfac588aa 100644
--- a/doc/numpybook/comparison/weave/inline.py
+++ b/doc/numpybook/comparison/weave/inline.py
@@ -24,11 +24,11 @@ def arr(a):
for(i=1;i<Na[0]-1;i++) {
for(j=1;j<Na[1]-1;j++) {
B2(i,j) = A2(i,j) + A2(i-1,j)*0.5 +
- A2(i+1,j)*0.5 + A2(i,j-1)*0.5
- + A2(i,j+1)*0.5
- + A2(i-1,j-1)*0.25
- + A2(i-1,j+1)*0.25
- + A2(i+1,j-1)*0.25
+ A2(i+1,j)*0.5 + A2(i,j-1)*0.5
+ + A2(i,j+1)*0.5
+ + A2(i-1,j-1)*0.25
+ + A2(i-1,j+1)*0.25
+ + A2(i+1,j-1)*0.25
+ A2(i+1,j+1)*0.25;
}
}
diff --git a/doc/numpybook/runcode.py b/doc/numpybook/runcode.py
index a0b82340b..7e696c9b3 100644
--- a/doc/numpybook/runcode.py
+++ b/doc/numpybook/runcode.py
@@ -11,7 +11,7 @@
#
# Options:
# -n name of code section (default MyCode)
-#
+#
import sys
import optparse
@@ -23,13 +23,13 @@ newre = re.compile(r"\\begin_inset Note.*PYNEW\s+\\end_inset", re.DOTALL)
def getoutput(tstr, dic):
print "\n\nRunning..."
- print tstr,
+ print tstr,
tempstr = cStringIO.StringIO()
sys.stdout = tempstr
code = compile(tstr, '<input>', 'exec')
try:
res = eval(tstr, dic)
- sys.stdout = sys.__stdout__
+ sys.stdout = sys.__stdout__
except SyntaxError:
try:
res = None
@@ -42,7 +42,7 @@ def getoutput(tstr, dic):
res = tempstr.getvalue() + '\n' + repr(res)
if res != '':
print "\nOutput is"
- print res,
+ print res,
return res
# now find the code in the code segment
@@ -75,7 +75,7 @@ def getnewcodestr(substr, dic):
if line != 'dummy':
outlines.append(line)
return "\n\\newline \n".join(outlines), end
-
+
def runpycode(lyxstr, name='MyCode'):
schobj = re.compile(r"\\layout %s\s+>>> " % name)
@@ -85,7 +85,7 @@ def runpycode(lyxstr, name='MyCode'):
for it in schobj.finditer(lyxstr):
indx.extend([it.start(), it.end()])
num += 1
-
+
if num == 0:
print "Nothing found for %s" % name
return lyxstr
@@ -103,14 +103,14 @@ def runpycode(lyxstr, name='MyCode'):
for k in range(num):
# first write everything up to the start of the code segment
substr = lyxstr[start:indx[2*k]]
- outstr.write(substr)
+ outstr.write(substr)
if start > 0:
mat = newre.search(substr)
# if PYNEW found, then start a new namespace
if mat:
edic = {}
exec 'from numpy import *' in edic
- exec 'set_printoptions(linewidth=65)' in edic
+ exec 'set_printoptions(linewidth=65)' in edic
# now find the code in the code segment
# endoutput will contain the index just past any output
# already present in the lyx string.