[Numpy-svn] r4594 - in branches/numpy.scons: . benchmarks numpy/doc
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Dec 15 23:49:24 EST 2007
Author: cdavid
Date: 2007-12-15 22:49:12 -0600 (Sat, 15 Dec 2007)
New Revision: 4594
Modified:
branches/numpy.scons/
branches/numpy.scons/benchmarks/benchmark.py
branches/numpy.scons/benchmarks/creating.py
branches/numpy.scons/benchmarks/simpleindex.py
branches/numpy.scons/benchmarks/sorting.py
branches/numpy.scons/numpy/doc/HOWTO_DOCUMENT.txt
Log:
Merged revisions 4582-4593 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r4588 | jarrod.millman | 2007-12-16 05:35:18 +0900 (Sun, 16 Dec 2007) | 2 lines
updating to us import numpy as np convention
........
r4590 | jarrod.millman | 2007-12-16 07:29:10 +0900 (Sun, 16 Dec 2007) | 2 lines
added new import standards to how to doc
........
Property changes on: branches/numpy.scons
___________________________________________________________________
Name: svnmerge-integrated
- /branches/distutils-revamp:1-2752 /branches/multicore:1-3687 /trunk:1-4581
+ /branches/distutils-revamp:1-2752 /branches/multicore:1-3687 /trunk:1-4593
Modified: branches/numpy.scons/benchmarks/benchmark.py
===================================================================
--- branches/numpy.scons/benchmarks/benchmark.py 2007-12-16 04:44:49 UTC (rev 4593)
+++ branches/numpy.scons/benchmarks/benchmark.py 2007-12-16 04:49:12 UTC (rev 4594)
@@ -17,7 +17,7 @@
modules = [module]
for m in modules:
- setup_str = 'import %s; import %s as N; ' % (m,m) \
+ setup_str = 'import %s; import %s as np; ' % (m,m) \
+ setup_str
self.module_test[m] = Timer(test_str, setup_str)
Modified: branches/numpy.scons/benchmarks/creating.py
===================================================================
--- branches/numpy.scons/benchmarks/creating.py 2007-12-16 04:44:49 UTC (rev 4593)
+++ branches/numpy.scons/benchmarks/creating.py 2007-12-16 04:49:12 UTC (rev 4594)
@@ -7,8 +7,8 @@
title='Creating %s zeros.' % N,
runs=3,reps=10000)
-b['numpy'] = ('a=N.zeros(shape,type)', 'shape=%s;type=float' % N)
-b['Numeric'] = ('a=N.zeros(shape,type)', 'shape=%s;type=N.Float' % N)
-b['numarray'] = ('a=N.zeros(shape,type)', "shape=%s;type=N.Float" % N)
+b['numpy'] = ('a=np.zeros(shape,type)', 'shape=%s;type=float' % N)
+b['Numeric'] = ('a=np.zeros(shape,type)', 'shape=%s;type=np.Float' % N)
+b['numarray'] = ('a=np.zeros(shape,type)', "shape=%s;type=np.Float" % N)
b.run()
Modified: branches/numpy.scons/benchmarks/simpleindex.py
===================================================================
--- branches/numpy.scons/benchmarks/simpleindex.py 2007-12-16 04:44:49 UTC (rev 4593)
+++ branches/numpy.scons/benchmarks/simpleindex.py 2007-12-16 04:49:12 UTC (rev 4594)
@@ -5,21 +5,25 @@
# in the first place.
N = 30
+
code2 = r"""
for k in xrange(%d):
for l in xrange(%d):
res = a[k,l].item() + a[l,k].item()
""" % (N,N)
+
code3 = r"""
for k in xrange(%d):
for l in xrange(%d):
res = a[k][l] + a[l][k]
""" % (N,N)
+
code = r"""
for k in xrange(%d):
for l in xrange(%d):
res = a[k,l] + a[l,k]
""" % (N,N)
+
setup3 = r"""
import random
a = [[None for k in xrange(%d)] for l in xrange(%d)]
@@ -27,16 +31,19 @@
for l in xrange(%d):
a[k][l] = random.random()
""" % (N,N,N,N)
-t1 = timeit.Timer(code, 'import numpy as N; a = N.random.rand(%d,%d)' % (N,N))
-t2 = timeit.Timer(code, 'import MLab as N; a=N.rand(%d,%d)' % (N,N))
-t3 = timeit.Timer(code, 'import numarray.mlab as N; a=N.rand(%d,%d)' % (N,N))
-t4 = timeit.Timer(code2, 'import numpy as N; a = N.random.rand(%d,%d)' % (N,N))
-t5 = timeit.Timer(code3, setup3)
-t6 = timeit.Timer("res = a + a.transpose()","import numpy as N; a=N.random.rand(%d,%d)" % (N,N))
+
+numpy_timer1 = timeit.Timer(code, 'import numpy as np; a = np.random.rand(%d,%d)' % (N,N))
+numeric_timer = timeit.Timer(code, 'import MLab as np; a=np.rand(%d,%d)' % (N,N))
+numarray_timer = timeit.Timer(code, 'import numarray.mlab as np; a=np.rand(%d,%d)' % (N,N))
+numpy_timer2 = timeit.Timer(code2, 'import numpy as np; a = np.random.rand(%d,%d)' % (N,N))
+python_timer = timeit.Timer(code3, setup3)
+numpy_timer3 = timeit.Timer("res = a + a.transpose()","import numpy as np; a=np.random.rand(%d,%d)" % (N,N))
+
print "shape = ", (N,N)
-print "NumPy 1: ", t1.repeat(3,100)
-print "NumPy 2: ", t4.repeat(3,100)
-print "Numeric: ", t2.repeat(3,100)
-print "Numarray: ", t3.repeat(3,100)
-print "Python: ", t5.repeat(3,100)
-print "Optimized: ", t6.repeat(3,100)
+print "NumPy 1: ", numpy_timer1.repeat(3,100)
+print "NumPy 2: ", numpy_timer2.repeat(3,100)
+print "Numeric: ", numeric_timer.repeat(3,100)
+print "Numarray: ", numarray_timer.repeat(3,100)
+print "Python: ", python_timer.repeat(3,100)
+print "Optimized: ", numpy_timer3.repeat(3,100)
+
Modified: branches/numpy.scons/benchmarks/sorting.py
===================================================================
--- branches/numpy.scons/benchmarks/sorting.py 2007-12-16 04:44:49 UTC (rev 4593)
+++ branches/numpy.scons/benchmarks/sorting.py 2007-12-16 04:49:12 UTC (rev 4594)
@@ -5,21 +5,21 @@
N = 10000
b.title = 'Sorting %d elements' % N
-b['numarray'] = ('a=N.array(None,shape=%d,typecode="i");a.sort()'%N,'')
-b['numpy'] = ('a=N.empty(shape=%d, dtype="i");a.sort()'%N,'')
-b['Numeric'] = ('a=N.empty(shape=%d, typecode="i");N.sort(a)'%N,'')
+b['numarray'] = ('a=np.array(None,shape=%d,typecode="i");a.sort()'%N,'')
+b['numpy'] = ('a=np.empty(shape=%d, dtype="i");a.sort()'%N,'')
+b['Numeric'] = ('a=np.empty(shape=%d, typecode="i");np.sort(a)'%N,'')
b.run()
N1,N2 = 100,100
b.title = 'Sorting (%d,%d) elements, last axis' % (N1,N2)
-b['numarray'] = ('a=N.array(None,shape=(%d,%d),typecode="i");a.sort()'%(N1,N2),'')
-b['numpy'] = ('a=N.empty(shape=(%d,%d), dtype="i");a.sort()'%(N1,N2),'')
-b['Numeric'] = ('a=N.empty(shape=(%d,%d),typecode="i");N.sort(a)'%(N1,N2),'')
+b['numarray'] = ('a=np.array(None,shape=(%d,%d),typecode="i");a.sort()'%(N1,N2),'')
+b['numpy'] = ('a=np.empty(shape=(%d,%d), dtype="i");a.sort()'%(N1,N2),'')
+b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a)'%(N1,N2),'')
b.run()
N1,N2 = 100,100
b.title = 'Sorting (%d,%d) elements, first axis' % (N1,N2)
-b['numarray'] = ('a=N.array(None,shape=(%d,%d), typecode="i");a.sort(0)'%(N1,N2),'')
-b['numpy'] = ('a=N.empty(shape=(%d,%d),dtype="i");N.sort(a,0)'%(N1,N2),'')
-b['Numeric'] = ('a=N.empty(shape=(%d,%d),typecode="i");N.sort(a,0)'%(N1,N2),'')
+b['numarray'] = ('a=np.array(None,shape=(%d,%d), typecode="i");a.sort(0)'%(N1,N2),'')
+b['numpy'] = ('a=np.empty(shape=(%d,%d),dtype="i");np.sort(a,0)'%(N1,N2),'')
+b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a,0)'%(N1,N2),'')
b.run()
Modified: branches/numpy.scons/numpy/doc/HOWTO_DOCUMENT.txt
===================================================================
--- branches/numpy.scons/numpy/doc/HOWTO_DOCUMENT.txt 2007-12-16 04:44:49 UTC (rev 4593)
+++ branches/numpy.scons/numpy/doc/HOWTO_DOCUMENT.txt 2007-12-16 04:49:12 UTC (rev 4594)
@@ -19,6 +19,10 @@
* `pylint <http://www.logilab.org/857>`__
* `pep8.py <http://svn.browsershots.org/trunk/devtools/pep8/pep8.py>`__
+Common import standards:
+ * import numpy as np
+ * import scipy as sp
+
Docstring Standard
------------------
More information about the Numpy-svn
mailing list