[Scipy-svn] r2183 - in trunk/Lib: cluster fftpack fftpack/tests interpolate io io/tests linalg maxentropy misc ndimage optimize sandbox/ann sandbox/arraysetops sandbox/delaunay sandbox/ga sandbox/gplt sandbox/image sandbox/models sandbox/montecarlo/tests sandbox/numexpr/tests sandbox/odr sandbox/rkern sandbox/stats sandbox/svm sandbox/svm/tests sandbox/xplt signal sparse/tests special special/tests stats stats/tests stsci/convolve/lib stsci/image/lib tests weave weave/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Tue Aug 29 06:31:32 EDT 2006
Author: oliphant
Date: 2006-08-29 05:30:44 -0500 (Tue, 29 Aug 2006)
New Revision: 2183
Modified:
trunk/Lib/cluster/vq.py
trunk/Lib/fftpack/basic.py
trunk/Lib/fftpack/pseudo_diffs.py
trunk/Lib/fftpack/tests/test_pseudo_diffs.py
trunk/Lib/interpolate/fitpack.py
trunk/Lib/interpolate/fitpack2.py
trunk/Lib/interpolate/interpolate.py
trunk/Lib/io/mio.py
trunk/Lib/io/tests/test_array_import.py
trunk/Lib/linalg/basic.py
trunk/Lib/linalg/matfuncs.py
trunk/Lib/maxentropy/maxentropy.py
trunk/Lib/maxentropy/maxentutils.py
trunk/Lib/misc/common.py
trunk/Lib/ndimage/filters.py
trunk/Lib/ndimage/interpolation.py
trunk/Lib/ndimage/morphology.py
trunk/Lib/optimize/minpack.py
trunk/Lib/optimize/optimize.py
trunk/Lib/sandbox/ann/mlp.py
trunk/Lib/sandbox/ann/rbf.py
trunk/Lib/sandbox/ann/srn.py
trunk/Lib/sandbox/arraysetops/arraysetops.py
trunk/Lib/sandbox/delaunay/interpolate.py
trunk/Lib/sandbox/ga/ga_util.py
trunk/Lib/sandbox/ga/parallel_pop.py
trunk/Lib/sandbox/ga/selection.py
trunk/Lib/sandbox/gplt/new_plot.py
trunk/Lib/sandbox/image/color.py
trunk/Lib/sandbox/models/bsplines.py
trunk/Lib/sandbox/models/cox.py
trunk/Lib/sandbox/models/regression.py
trunk/Lib/sandbox/models/utils.py
trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py
trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py
trunk/Lib/sandbox/numexpr/tests/test_numexpr.py
trunk/Lib/sandbox/odr/models.py
trunk/Lib/sandbox/rkern/diffev.py
trunk/Lib/sandbox/rkern/pink.py
trunk/Lib/sandbox/stats/anova.py
trunk/Lib/sandbox/stats/obsolete.py
trunk/Lib/sandbox/svm/classification.py
trunk/Lib/sandbox/svm/dataset.py
trunk/Lib/sandbox/svm/predict.py
trunk/Lib/sandbox/svm/tests/test_regression.py
trunk/Lib/sandbox/xplt/Mplot.py
trunk/Lib/sandbox/xplt/NarPlotter.py
trunk/Lib/sandbox/xplt/demo5.py
trunk/Lib/sandbox/xplt/gist3dhelp.py
trunk/Lib/sandbox/xplt/gistdemo3d.py
trunk/Lib/sandbox/xplt/mesh3d.py
trunk/Lib/sandbox/xplt/pl3d.py
trunk/Lib/sandbox/xplt/slice3.py
trunk/Lib/sandbox/xplt/sphereisos.py
trunk/Lib/signal/filter_design.py
trunk/Lib/signal/ltisys.py
trunk/Lib/signal/signaltools.py
trunk/Lib/signal/wavelets.py
trunk/Lib/sparse/tests/test_sparse.py
trunk/Lib/special/basic.py
trunk/Lib/special/orthogonal.py
trunk/Lib/special/tests/Test.py
trunk/Lib/special/tests/test_basic.py
trunk/Lib/stats/_support.py
trunk/Lib/stats/distributions.py
trunk/Lib/stats/kde.py
trunk/Lib/stats/morestats.py
trunk/Lib/stats/stats.py
trunk/Lib/stats/tests/test_stats.py
trunk/Lib/stsci/convolve/lib/Convolve.py
trunk/Lib/stsci/image/lib/combine.py
trunk/Lib/tests/test_basic.py
trunk/Lib/tests/test_basic1a.py
trunk/Lib/tests/test_common.py
trunk/Lib/weave/size_check.py
trunk/Lib/weave/tests/test_blitz_tools.py
Log:
Add axis arguments to functions that changed in NumPy 1.0b2
Modified: trunk/Lib/cluster/vq.py
===================================================================
--- trunk/Lib/cluster/vq.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/cluster/vq.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -152,7 +152,7 @@
for o in obs:
subtract(code_book,o,diff) # faster version of --> diff = code_book - o
dist = sqrt(sum(diff*diff,-1))
- code.append(argmin(dist))
+ code.append(argmin(dist,axis=-1))
#something weird here dst does not work reliably because it sometime
#returns an array of goofy length. Try except fixes it, but is ugly.
dst = minimum.reduce(dist,0)
Modified: trunk/Lib/fftpack/basic.py
===================================================================
--- trunk/Lib/fftpack/basic.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/fftpack/basic.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -273,7 +273,7 @@
Optional input:
shape
Defines the shape of the Fourier transform. If shape is not
- specified then shape=take(x.shape,axes).
+ specified then shape=take(x.shape,axes,axis=0).
If shape[i]>x.shape[i] then the i-th dimension is padded with
zeros. If shape[i]<x.shape[i], then the i-th dimension is
truncated to desired length shape[i].
Modified: trunk/Lib/fftpack/pseudo_diffs.py
===================================================================
--- trunk/Lib/fftpack/pseudo_diffs.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/fftpack/pseudo_diffs.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -38,7 +38,7 @@
The assumed period of the sequence. Default is 2*pi.
Notes:
- If sum(x)=0 then
+ If sum(x,axis=0)=0 then
diff(diff(x,k),-k)==x (within numerical accuracy)
For odd order and even len(x), the Nyquist mode is taken zero.
"""
@@ -89,7 +89,7 @@
The assumed period of the sequence. Default period is 2*pi.
Notes:
- If sum(x)==0 and n=len(x) is odd then
+ If sum(x,axis=0)==0 and n=len(x) is odd then
tilbert(itilbert(x)) == x
If 2*pi*h/period is approximately 10 or larger then numerically
tilbert == hilbert
@@ -167,7 +167,7 @@
y_0 = 0
Notes:
- If sum(x)==0 then
+ If sum(x,axis=0)==0 then
hilbert(ihilbert(x)) == x
For even len(x), the Nyquist mode of x is taken zero.
"""
Modified: trunk/Lib/fftpack/tests/test_pseudo_diffs.py
===================================================================
--- trunk/Lib/fftpack/tests/test_pseudo_diffs.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/fftpack/tests/test_pseudo_diffs.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -156,11 +156,11 @@
for k in [0,2,4,6]:
for n in [60,32,64,56,55]:
f=random ((n,))
- af=sum(f)/n
+ af=sum(f,axis=0)/n
f=f-af
# zeroing Nyquist mode:
f = diff(diff(f,1),-1)
- assert_almost_equal(sum(f),0.0)
+ assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(diff(diff(f,k),-k),f)
assert_array_almost_equal(diff(diff(f,-k),k),f)
@@ -168,9 +168,9 @@
for k in [0,1,2,3,4,5,6]:
for n in [33,65,55]:
f=random ((n,))
- af=sum(f)/n
+ af=sum(f,axis=0)/n
f=f-af
- assert_almost_equal(sum(f),0.0)
+ assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(diff(diff(f,k),-k),f)
assert_array_almost_equal(diff(diff(f,-k),k),f)
@@ -178,11 +178,11 @@
for k in [0,1,2,3,4,5,6]:
for n in [32,33,64,56,55]:
f=random ((n,))
- af=sum(f)/n
+ af=sum(f,axis=0)/n
f=f-af
# zeroing Nyquist mode:
f = diff(diff(f,1),-1)
- assert_almost_equal(sum(f),0.0)
+ assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(diff(diff(f,k),-k),f)
assert_array_almost_equal(diff(diff(f,-k),k),f)
@@ -234,18 +234,18 @@
for h in [0.1,0.5,1,5.5,10]:
for n in [32,64,56]:
f=random ((n,))
- af=sum(f)/n
+ af=sum(f,axis=0)/n
f=f-af
- assert_almost_equal(sum(f),0.0)
+ assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(direct_tilbert(direct_itilbert(f,h),h),f)
def check_random_odd(self):
for h in [0.1,0.5,1,5.5,10]:
for n in [33,65,55]:
f=random ((n,))
- af=sum(f)/n
+ af=sum(f,axis=0)/n
f=f-af
- assert_almost_equal(sum(f),0.0)
+ assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(itilbert(tilbert(f,h),h),f)
assert_array_almost_equal(tilbert(itilbert(f,h),h),f)
@@ -315,20 +315,20 @@
def check_random_odd(self):
for n in [33,65,55]:
f=random ((n,))
- af=sum(f)/n
+ af=sum(f,axis=0)/n
f=f-af
- assert_almost_equal(sum(f),0.0)
+ assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(ihilbert(hilbert(f)),f)
assert_array_almost_equal(hilbert(ihilbert(f)),f)
def check_random_even(self):
for n in [32,64,56]:
f=random ((n,))
- af=sum(f)/n
+ af=sum(f,axis=0)/n
f=f-af
# zeroing Nyquist mode:
f = diff(diff(f,1),-1)
- assert_almost_equal(sum(f),0.0)
+ assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(direct_hilbert(direct_ihilbert(f)),f)
assert_array_almost_equal(hilbert(ihilbert(f)),f)
Modified: trunk/Lib/interpolate/fitpack.py
===================================================================
--- trunk/Lib/interpolate/fitpack.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/interpolate/fitpack.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -133,7 +133,7 @@
If task=-1 find the weighted least square spline for a given set of
knots, t.
s -- A smoothing condition. The amount of smoothness is determined by
- satisfying the conditions: sum((w * (y - g))**2) <= s where
+ satisfying the conditions: sum((w * (y - g))**2,axis=0) <= s where
g(x) is the smoothed interpolation of (x,y). The user can use s to
control the tradeoff between closeness and smoothness of fit. Larger
s means more smoothing while smaller values of s indicate less
@@ -278,7 +278,7 @@
a given set of knots, t. These should be interior knots
as knots on the ends will be added automatically.
s -- A smoothing condition. The amount of smoothness is determined by
- satisfying the conditions: sum((w * (y - g))**2) <= s where
+ satisfying the conditions: sum((w * (y - g))**2,axis=0) <= s where
g(x) is the smoothed interpolation of (x,y). The user can use s to
control the tradeoff between closeness and smoothness of fit. Larger
s means more smoothing while smaller values of s indicate less
Modified: trunk/Lib/interpolate/fitpack2.py
===================================================================
--- trunk/Lib/interpolate/fitpack2.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/interpolate/fitpack2.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -69,7 +69,7 @@
k=3 - degree of the univariate spline.
s - positive smoothing factor defined for
estimation condition:
- sum((w[i]*(y[i]-s(x[i])))**2) <= s
+ sum((w[i]*(y[i]-s(x[i])))**2,axis=0) <= s
Default s=len(w) which should be a good value
if 1/w[i] is an estimate of the standard
deviation of y[i].
@@ -166,7 +166,7 @@
def get_residual(self):
""" Return weighted sum of squared residuals of the spline
- approximation: sum ((w[i]*(y[i]-s(x[i])))**2)
+ approximation: sum ((w[i]*(y[i]-s(x[i])))**2,axis=0)
"""
return self._data[10]
@@ -240,7 +240,7 @@
if xe is None: xe = x[-1]
t = concatenate(([xb]*(k+1),t,[xe]*(k+1)))
n = len(t)
- if not alltrue(t[k+1:n-k]-t[k:n-k-1] > 0):
+ if not alltrue(t[k+1:n-k]-t[k:n-k-1] > 0,axis=0):
raise ValueError,\
'Interior knots t must satisfy Schoenberg-Whitney conditions'
data = dfitpack.fpcurfm1(x,y,k,t,w=w,xb=xb,xe=xe)
@@ -300,7 +300,7 @@
def get_residual(self):
""" Return weighted sum of squared residuals of the spline
- approximation: sum ((w[i]*(z[i]-s(x[i],y[i])))**2)
+ approximation: sum ((w[i]*(z[i]-s(x[i],y[i])))**2,axis=0)
"""
return self.fp
def get_knots(self):
@@ -340,7 +340,7 @@
kx,ky=3,3 - degrees of the bivariate spline.
s - positive smoothing factor defined for
estimation condition:
- sum((w[i]*(z[i]-s(x[i],y[i])))**2) <= s
+ sum((w[i]*(z[i]-s(x[i],y[i])))**2,axis=0) <= s
Default s=len(w) which should be a good value
if 1/w[i] is an estimate of the standard
deviation of z[i].
Modified: trunk/Lib/interpolate/interpolate.py
===================================================================
--- trunk/Lib/interpolate/interpolate.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/interpolate/interpolate.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -15,7 +15,7 @@
def reduce_sometrue(a):
all = a
while len(shape(all)) > 1:
- all = sometrue(all)
+ all = sometrue(all,axis=0)
return all
class interp2d:
@@ -163,7 +163,7 @@
# 4. Calculate the slope of regions that each x_new value falls in.
lo = x_new_indices - 1; hi = x_new_indices
- # !! take() should default to the last axis (IMHO) and remove
+ # !! take(,axis=0) should default to the last axis (IMHO) and remove
# !! the extra argument.
x_lo = take(self.x,lo,axis=self.interp_axis)
x_hi = take(self.x,hi,axis=self.interp_axis);
@@ -204,10 +204,10 @@
above_bounds = greater(x_new,self.x[-1])
# Note: sometrue has been redefined to handle length 0 arrays
# !! Could provide more information about which values are out of bounds
- if self.bounds_error and sometrue(below_bounds):
+ if self.bounds_error and sometrue(below_bounds,axis=0):
raise ValueError, " A value in x_new is below the"\
" interpolation range."
- if self.bounds_error and sometrue(above_bounds):
+ if self.bounds_error and sometrue(above_bounds,axis=0):
raise ValueError, " A value in x_new is above the"\
" interpolation range."
# !! Should we emit a warning if some values are out of bounds.
Modified: trunk/Lib/io/mio.py
===================================================================
--- trunk/Lib/io/mio.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/io/mio.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -174,7 +174,7 @@
if mtype is None:
mtype = data.dtype.char
howmany,mtype = getsize_type(mtype)
- count = product(data.shape)
+ count = product(data.shape,axis=0)
numpyio.fwrite(self.file,count,data,mtype,bs)
return
@@ -215,20 +215,20 @@
# allow -1 to specify unknown dimension size as in reshape
minus_ones = shape.count(-1)
if minus_ones == 0:
- count = product(shape)
+ count = product(shape,axis=0)
elif minus_ones == 1:
now = self.tell()
self.seek(0,2)
end = self.tell()
self.seek(now)
remaining_bytes = end - now
- know_dimensions_size = -product(count) * getsize_type(stype)[0]
+ know_dimensions_size = -product(count,axis=0) * getsize_type(stype)[0]
unknown_dimension_size, illegal = divmod(remaining_bytes,
know_dimensions_size)
if illegal:
raise ValueError("unknown dimension doesn't match filesize")
shape[shape.index(-1)] = unknown_dimension_size
- count = product(shape)
+ count = product(shape,axis=0)
else:
raise ValueError(
"illegal count; can only specify one unknown dimension")
@@ -302,7 +302,7 @@
sz,mtype = getsize_type(args[0])
else:
sz,mtype = getsize_type(fmt.dtype.char)
- count = product(fmt.shape)
+ count = product(fmt.shape,axis=0)
strlen = struct.pack(nfmt,count*sz)
self.write(strlen)
numpyio.fwrite(self.file,count,fmt,mtype,self.bs)
@@ -579,7 +579,7 @@
dims = result.shape
if len(dims) >= 2: # return array of strings
n_dims = dims[:-1]
- string_arr = reshape(result, (product(n_dims), dims[-1]))
+ string_arr = reshape(result, (product(n_dims,axis=0), dims[-1]))
result = empty(n_dims, dtype=object)
for i in range(0, n_dims[-1]):
result[...,i] = string_arr[i].tostring().decode(en)
@@ -595,7 +595,7 @@
result = squeeze(transpose(reshape(result,tupdims)))
elif dclass == mxCELL_CLASS:
- length = product(dims)
+ length = product(dims,axis=0)
result = empty(length, dtype=object)
for i in range(length):
result[i] = _get_element(fid)
@@ -604,7 +604,7 @@
result = result.item()
elif dclass == mxSTRUCT_CLASS:
- length = product(dims)
+ length = product(dims,axis=0)
result = zeros(length, object)
namelength = _get_element(fid)
# get field names
@@ -624,7 +624,7 @@
# object is like a structure with but with a class name
elif dclass == mxOBJECT_CLASS:
class_name = _get_element(fid).tostring()
- length = product(dims)
+ length = product(dims,axis=0)
result = zeros(length, object)
namelength = _get_element(fid)
# get field names
@@ -922,7 +922,7 @@
var = transpose(var)
if len(var.shape) > 2:
- var=var.reshape((product(var.shape[:-1]), var.shape[-1]))
+ var=var.reshape((product(var.shape[:-1],axis=0), var.shape[-1]))
imagf = var.dtype.char in ['F', 'D']
fid.fwrite([var.shape[1], var.shape[0], imagf, len(variable)+1],'int')
Modified: trunk/Lib/io/tests/test_array_import.py
===================================================================
--- trunk/Lib/io/tests/test_array_import.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/io/tests/test_array_import.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -31,7 +31,7 @@
print "\nDon't worry about a warning regarding the number of bytes read."
b = numpyio.fread(fid,1000000,N.Int16,N.Int)
fid.close()
- assert(N.product(a.astype(N.Int16) == b))
+ assert(N.product(a.astype(N.Int16) == b,axis=0))
os.remove(fname)
class test_read_array(ScipyTestCase):
Modified: trunk/Lib/linalg/basic.py
===================================================================
--- trunk/Lib/linalg/basic.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/linalg/basic.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -242,7 +242,7 @@
For vectors ord can be any real number including Inf or -Inf.
ord = Inf, computes the maximum of the magnitudes
ord = -Inf, computes minimum of the magnitudes
- ord is finite, computes sum(abs(x)**ord)**(1.0/ord)
+ ord is finite, computes sum(abs(x)**ord,axis=0)**(1.0/ord)
For matrices ord can only be one of the following values:
ord = 2 computes the largest singular value
@@ -251,7 +251,7 @@
ord = -1 computes the smallest column sum of absolute values
ord = Inf computes the largest row sum of absolute values
ord = -Inf computes the smallest row sum of absolute values
- ord = 'fro' computes the frobenius norm sqrt(sum(diag(X.H * X)))
+ ord = 'fro' computes the frobenius norm sqrt(sum(diag(X.H * X),axis=0))
For values ord < 0, the result is, strictly speaking, not a
mathematical 'norm', but it may still be useful for numerical purposes.
@@ -268,22 +268,22 @@
elif ord == -Inf:
return numpy.amin(abs(x))
elif ord == 1:
- return numpy.sum(abs(x)) # special case for speedup
+ return numpy.sum(abs(x),axis=0) # special case for speedup
elif ord == 2:
- return sqrt(numpy.sum(real((conjugate(x)*x)))) # special case for speedup
+ return sqrt(numpy.sum(real((conjugate(x)*x)),axis=0)) # special case for speedup
else:
- return numpy.sum(abs(x)**ord)**(1.0/ord)
+ return numpy.sum(abs(x)**ord,axis=0)**(1.0/ord)
elif nd == 2:
if ord == 2:
return numpy.amax(decomp.svd(x,compute_uv=0))
elif ord == -2:
return numpy.amin(decomp.svd(x,compute_uv=0))
elif ord == 1:
- return numpy.amax(numpy.sum(abs(x)))
+ return numpy.amax(numpy.sum(abs(x),axis=0))
elif ord == Inf:
return numpy.amax(numpy.sum(abs(x),axis=1))
elif ord == -1:
- return numpy.amin(numpy.sum(abs(x)))
+ return numpy.amin(numpy.sum(abs(x),axis=0))
elif ord == -Inf:
return numpy.amin(numpy.sum(abs(x),axis=1))
elif ord in ['fro','f']:
@@ -365,7 +365,7 @@
resids = asarray([], dtype=x.dtype)
if n<m:
x1 = x[:n]
- if rank==n: resids = sum(x[n:]**2)
+ if rank==n: resids = sum(x[n:]**2,axis=0)
x = x1
return x,resids,rank,s
Modified: trunk/Lib/linalg/matfuncs.py
===================================================================
--- trunk/Lib/linalg/matfuncs.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/linalg/matfuncs.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -199,7 +199,7 @@
if minden == 0.0:
minden = tol
err = min(1, max(tol,(tol/minden)*norm(triu(T,1),1)))
- if product(ravel(logical_not(isfinite(F)))):
+ if product(ravel(logical_not(isfinite(F))),axis=0):
err = Inf
if disp:
if err > 1000*tol:
Modified: trunk/Lib/maxentropy/maxentropy.py
===================================================================
--- trunk/Lib/maxentropy/maxentropy.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/maxentropy/maxentropy.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -86,7 +86,7 @@
self.verbose = False
self.maxgtol = 1e-5
- # Required tolerance of gradient on average (closeness to zero) for
+ # Required tolerance of gradient on average (closeness to zero,axis=0) for
# CG optimization:
self.avegtol = 1e-3
# Default tolerance for the other optimization algorithms:
@@ -1717,7 +1717,7 @@
self.external = None
self.clearcache()
- meandual = numpy.average(dualapprox)
+ meandual = numpy.average(dualapprox,axis=0)
self.external_duals[self.iters] = dualapprox
self.external_gradnorms[self.iters] = gradnorms
@@ -1727,7 +1727,7 @@
(len(self.externalFs), meandual)
print "** Mean mean square error of the (unregularized) feature" \
" expectation estimates from the external samples =" \
- " mean(|| \hat{\mu_e} - k ||) =", numpy.average(gradnorms)
+ " mean(|| \hat{\mu_e} - k ||,axis=0) =", numpy.average(gradnorms,axis=0)
# Track the parameter vector params with the lowest mean dual estimate
# so far:
if meandual < self.bestdual:
Modified: trunk/Lib/maxentropy/maxentutils.py
===================================================================
--- trunk/Lib/maxentropy/maxentutils.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/maxentropy/maxentutils.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -34,7 +34,7 @@
complex-numbered, such as the output of robustarraylog(). So we
expect:
- cmath.exp(logsumexpcomplex(robustarraylog(values))) ~= sum(values)
+ cmath.exp(logsumexpcomplex(robustarraylog(values))) ~= sum(values,axis=0)
except for a small rounding error in both real and imag components.
The output is complex. (To recover just the real component, use
Modified: trunk/Lib/misc/common.py
===================================================================
--- trunk/Lib/misc/common.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/misc/common.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -157,7 +157,7 @@
X = x**0.0
for k in range(1,Np):
X = hstack([X,x**k])
- w = product(arange(1,ndiv+1))*linalg.inv(X)[ndiv]
+ w = product(arange(1,ndiv+1),axis=0)*linalg.inv(X)[ndiv]
return w
def derivative(func,x0,dx=1.0,n=1,args=(),order=3):
@@ -200,7 +200,7 @@
ho = order >> 1
for k in range(order):
val += weights[k]*func(x0+(k-ho)*dx,*args)
- return val / product((dx,)*n)
+ return val / product((dx,)*n,axis=0)
def pade(an, m):
"""Given Taylor series coefficients in an, return a Pade approximation to
Modified: trunk/Lib/ndimage/filters.py
===================================================================
--- trunk/Lib/ndimage/filters.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/ndimage/filters.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -430,7 +430,7 @@
else:
footprint = numarray.asarray(footprint)
footprint = footprint.astype(bool)
- if numarray.alltrue(numarray.ravel(footprint)):
+ if numarray.alltrue(numarray.ravel(footprint),axis=0):
size = footprint.shape
footprint = None
separable = True
Modified: trunk/Lib/ndimage/interpolation.py
===================================================================
--- trunk/Lib/ndimage/interpolation.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/ndimage/interpolation.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -406,7 +406,7 @@
order, mode, cval, prefilter)
else:
coordinates = []
- size = numarray.product(input.shape)
+ size = numarray.product(input.shape,axis=0)
size /= input.shape[axes[0]]
size /= input.shape[axes[1]]
for ii in range(input.ndim):
Modified: trunk/Lib/ndimage/morphology.py
===================================================================
--- trunk/Lib/ndimage/morphology.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/ndimage/morphology.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -100,7 +100,7 @@
raise RuntimeError, 'structure rank must equal input rank'
if not structure.flags.contiguous:
structure = structure.copy()
- if numarray.product(structure.shape) < 1:
+ if numarray.product(structure.shape,axis=0) < 1:
raise RuntimeError, 'structure must not be empty'
if mask is not None:
mask = numarray.asarray(mask)
@@ -659,7 +659,7 @@
dt = numarray.where(input, -1, 0).astype(numarray.Int32)
rank = dt.ndim
if return_indices:
- sz = numarray.product(dt.shape)
+ sz = numarray.product(dt.shape,axis=0)
ft = numarray.arange(sz, dtype = numarray.Int32)
ft.shape = dt.shape
else:
Modified: trunk/Lib/optimize/minpack.py
===================================================================
--- trunk/Lib/optimize/minpack.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/optimize/minpack.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -145,7 +145,7 @@
(non-linear) equations in N unknowns given a starting estimate, x0,
using a modification of the Levenberg-Marquardt algorithm.
- x = arg min(sum(func(y)**2))
+ x = arg min(sum(func(y)**2,axis=0))
y
Inputs:
@@ -301,7 +301,7 @@
fvecp=fvecp.reshape((m,))
_minpack._chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,2,err)
- good = (product(greater(err,0.5)))
+ good = (product(greater(err,0.5),axis=0))
return (good,err)
Modified: trunk/Lib/optimize/optimize.py
===================================================================
--- trunk/Lib/optimize/optimize.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/optimize/optimize.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -51,11 +51,11 @@
elif ord == -Inf:
return numpy.amin(abs(x))
else:
- return numpy.sum(abs(x)**ord)**(1.0/ord)
+ return numpy.sum(abs(x)**ord,axis=0)**(1.0/ord)
def rosen(x): # The Rosenbrock function
x = asarray(x)
- return numpy.sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)
+ return numpy.sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0,axis=0)
def rosen_der(x):
x = asarray(x)
@@ -1580,7 +1580,7 @@
grid = (grid,)
Jout = vecfunc(*grid)
Nshape = shape(Jout)
- indx = argmin(Jout.ravel())
+ indx = argmin(Jout.ravel(),axis=-1)
Nindx = zeros(N,int)
xmin = zeros(N,float)
for k in range(N-1,-1,-1):
Modified: trunk/Lib/sandbox/ann/mlp.py
===================================================================
--- trunk/Lib/sandbox/ann/mlp.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/ann/mlp.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -118,7 +118,7 @@
Returns:
sum-squared-error over all data
"""
- return N.sum(self.errfxn(self.wp,x,t))
+ return N.sum(self.errfxn(self.wp,x,t),axis=0)
def main():
""" Build/train/test MLP
Modified: trunk/Lib/sandbox/ann/rbf.py
===================================================================
--- trunk/Lib/sandbox/ann/rbf.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/ann/rbf.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -86,7 +86,7 @@
d_max = 0.0
for i in self.centers:
for j in self.centers:
- tmp = N.sum(N.sqrt((i-j)**2))
+ tmp = N.sum(N.sqrt((i-j)**2),axis=0)
if tmp > d_max:
d_max = tmp
self.variance = d_max/(2.0*len(X))
@@ -105,7 +105,7 @@
Returns:
sum-squared-error over all data
"""
- return N.sum(self.err_fxn(self.wp,X,Y))
+ return N.sum(self.err_fxn(self.wp,X,Y),axis=0)
def main():
""" Build/train/test RBF net
Modified: trunk/Lib/sandbox/ann/srn.py
===================================================================
--- trunk/Lib/sandbox/ann/srn.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/ann/srn.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -136,7 +136,7 @@
Returns:
sum-squared-error over all data
"""
- return N.sum(self.errfxn(self.wp,x,t))
+ return N.sum(self.errfxn(self.wp,x,t),axis=0)
def main():
Modified: trunk/Lib/sandbox/arraysetops/arraysetops.py
===================================================================
--- trunk/Lib/sandbox/arraysetops/arraysetops.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/arraysetops/arraysetops.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -62,19 +62,19 @@
ar = numpy.array( ar1 ).ravel()
if retIndx:
perm = numpy.argsort( ar )
- aux = numpy.take( ar, perm 0)
+ aux = numpy.take( ar, perm 0,axis=0)
flag = ediff1d( aux, 1 ) != 0
- return numpy.compress( flag, perm ), numpy.compress( flag, aux )
+ return numpy.compress( flag, perm ,axis=-1), numpy.compress( flag, aux ,axis=-1)
else:
aux = numpy.sort( ar )
- return numpy.compress( ediff1d( aux, 1 ) != 0, aux )
+ return numpy.compress( ediff1d( aux, 1 ) != 0, aux ,axis=-1)
##
# 01.11.2005, c
def intersect1d( ar1, ar2 ):
"""Intersection of 1D arrays with unique elements."""
aux = numpy.sort( numpy.concatenate( (ar1, ar2 ) ) )
- return numpy.compress( (aux[1:] - aux[:-1]) == 0, aux )
+ return numpy.compress( (aux[1:] - aux[:-1]) == 0, aux ,axis=-1)
##
# 01.11.2005, c
@@ -83,7 +83,7 @@
# Might be faster then unique1d( intersect1d( ar1, ar2 ) )?
aux = numpy.sort( numpy.concatenate( (unique1d( ar1 ),
unique1d( ar2 )) ) )
- return numpy.compress( (aux[1:] - aux[:-1]) == 0, aux )
+ return numpy.compress( (aux[1:] - aux[:-1]) == 0, aux ,axis=-1)
##
# 01.11.2005, c
@@ -92,7 +92,7 @@
aux = numpy.sort( numpy.concatenate( (ar1, ar2 ) ) )
flag = ediff1d( aux, toEnd = 1, toBegin = 1 ) == 0
flag2 = ediff1d( flag, 0 ) == 0
- return numpy.compress( flag2, aux )
+ return numpy.compress( flag2, aux ,axis=-1)
##
# 03.11.2005, c
@@ -128,7 +128,7 @@
def setdiff1d( ar1, ar2 ):
"""Set difference of 1D arrays with unique elements."""
aux = setmember1d( ar1, ar2 )
- return numpy.compress( aux == 0, ar1 )
+ return numpy.compress( aux == 0, ar1 ,axis=-1)
##
# 03.11.2005, c
@@ -138,7 +138,7 @@
ec = numpy.array( [1, 2, 5, 7] )
c = unique1d( a )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
##
# 03.11.2005, c
@@ -149,7 +149,7 @@
ec = numpy.array( [1, 2, 5] )
c = intersect1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
##
# 03.11.2005, c
@@ -160,7 +160,7 @@
ec = numpy.array( [1, 2, 5] )
c = intersect1d_nu( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
##
# 03.11.2005, c
@@ -171,21 +171,21 @@
ec = numpy.array( [3, 4, 7] )
c = setxor1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
a = numpy.array( [1, 2, 3] )
b = numpy.array( [6, 5, 4] )
ec = numpy.array( [1, 2, 3, 4, 5, 6] )
c = setxor1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
a = numpy.array( [1, 8, 2, 3] )
b = numpy.array( [6, 5, 4, 8] )
ec = numpy.array( [1, 2, 3, 4, 5, 6] )
c = setxor1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
##
@@ -197,17 +197,17 @@
ec = numpy.array( [True, False, True, True] )
c = setmember1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
a[0] = 8
ec = numpy.array( [False, False, True, True] )
c = setmember1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
a[0], a[3] = 4, 8
ec = numpy.array( [True, False, True, False] )
c = setmember1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
##
# 03.11.2005, c
@@ -218,7 +218,7 @@
ec = numpy.array( [1, 2, 3, 4, 5, 7] )
c = union1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
##
# 03.11.2005, c
@@ -229,7 +229,7 @@
ec = numpy.array( [6, 7] )
c = setdiff1d( a, b )
- assert numpy.alltrue( c == ec )
+ assert numpy.alltrue( c == ec ,axis=0)
##
# 03.11.2005, c
@@ -241,7 +241,7 @@
c1 = intersect1d_nu( a, b )
c2 = unique1d( intersect1d( a, b ) )
- assert numpy.alltrue( c1 == c2 )
+ assert numpy.alltrue( c1 == c2 ,axis=0)
a = numpy.array( [5, 7, 1, 2, 8] )
b = numpy.array( [9, 8, 2, 4, 3, 1, 5] )
@@ -250,7 +250,7 @@
aux1 = intersect1d( a, b )
aux2 = union1d( a, b )
c2 = setdiff1d( aux2, aux1 )
- assert numpy.alltrue( c1 == c2 )
+ assert numpy.alltrue( c1 == c2 ,axis=0)
##
# 02.11.2005, c
@@ -292,7 +292,7 @@
dt1s.append( dt1 )
dt2s.append( dt2 )
- assert numpy.alltrue( b == c )
+ assert numpy.alltrue( b == c ,axis=0)
print nItems
Modified: trunk/Lib/sandbox/delaunay/interpolate.py
===================================================================
--- trunk/Lib/sandbox/delaunay/interpolate.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/delaunay/interpolate.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -126,7 +126,7 @@
from its original Voronoi polygon, stolen[i]. We define the natural
neighbors coordinates
- phi[i] = stolen[i] / sum(stolen)
+ phi[i] = stolen[i] / sum(stolen,axis=0)
We then use these phi[i] to weight the corresponding function values from
the input data z to compute the interpolated value.
Modified: trunk/Lib/sandbox/ga/ga_util.py
===================================================================
--- trunk/Lib/sandbox/ga/ga_util.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/ga/ga_util.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -58,4 +58,4 @@
def remove_NaN(z):
from numpy import isnan, isinf, compress, logical_not
- return compress(logical_not( isnan(z)+isinf(z)),z)
+ return compress(logical_not( isnan(z)+isinf(z)),z,axis=-1)
Modified: trunk/Lib/sandbox/ga/parallel_pop.py
===================================================================
--- trunk/Lib/sandbox/ga/parallel_pop.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/ga/parallel_pop.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -520,7 +520,7 @@
time.sleep(self.wait)
- return sum(genome.array())
+ return sum(genome.array(),axis=0)
Modified: trunk/Lib/sandbox/ga/selection.py
===================================================================
--- trunk/Lib/sandbox/ga/selection.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/ga/selection.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -40,7 +40,7 @@
(f_max <= 0 and f_min <= 0)):
raise GAError, 'srs_selector requires all fitnesses values to be either strictly positive or strictly negative'
if f_max == f_min: f = ones(shape(f),typecode = Float32)
- self.dart_board = add.accumulate(f / sum(f))
+ self.dart_board = add.accumulate(f / sum(f,axis=0))
def select(self,pop,cnt = 1):
returns = []
for i in range(cnt):
@@ -63,7 +63,7 @@
if not ( (f_max >= 0. and f_min >= 0.) or
(f_max <= 0. and f_min <= 0.)):
raise GAError, 'srs_selector requires all fitnesses values to be either strictly positive or strictly negative - min %f, max %f' %(f_min,f_max)
- f_avg = sum(f)/sz
+ f_avg = sum(f,axis=0)/sz
if f_avg == 0.: e = ones(shape(f),typecode = Float32)
else:
if pop.min_or_max() == 'max': e = f/f_avg
@@ -75,7 +75,7 @@
choices = []
for i in xrange(sz): choices = choices + [pop[i]] * int(garauntee[i])
#now deal with the remainder
- dart_board = add.accumulate(chance / sum(chance))
+ dart_board = add.accumulate(chance / sum(chance,axis=0))
for i in range(len(choices),sz):
dart = rv.random()
idx = 0
Modified: trunk/Lib/sandbox/gplt/new_plot.py
===================================================================
--- trunk/Lib/sandbox/gplt/new_plot.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/gplt/new_plot.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -7,8 +7,8 @@
def squeeze(a):
s = shape(a)
- dims = len(s) - sum(equal(1,s))
- new_s = compress(not_equal(1,s),s)
+ dims = len(s) - sum(equal(1,s),axis=0)
+ new_s = compress(not_equal(1,s),s,axis=-1)
return reshape(a,new_s)
Modified: trunk/Lib/sandbox/image/color.py
===================================================================
--- trunk/Lib/sandbox/image/color.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/image/color.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -63,7 +63,7 @@
# Vos, Estevez, and Walraven (1990)
# with alteration in S-cone sensitivity from
# Stockman and Sharpe (2000)
-# scaled so that sum(LMS) has a peak of 1
+# scaled so that sum(LMS,axis=0) has a peak of 1
# just like LMS_from_XYZ
lms_from_rgbsb = [[0.14266235473644004, 0.49009667755566039,
Modified: trunk/Lib/sandbox/models/bsplines.py
===================================================================
--- trunk/Lib/sandbox/models/bsplines.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/models/bsplines.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -48,7 +48,7 @@
_shape = x.shape
if _shape == ():
x.shape = (1,)
- x.shape = (N.product(_shape),)
+ x.shape = (N.product(_shape,axis=0),)
if i < self.tau.shape[0] - 1:
## TODO: OWNDATA flags...
v = _bspline.evaluate(x, self.tau, self.m, d, i, i+1)
@@ -65,7 +65,7 @@
_shape = x.shape
if _shape == ():
x.shape = (1,)
- x.shape = (N.product(_shape),)
+ x.shape = (N.product(_shape,axis=0),)
if upper is None:
upper = self.tau.shape[0] - self.m
Modified: trunk/Lib/sandbox/models/cox.py
===================================================================
--- trunk/Lib/sandbox/models/cox.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/models/cox.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -101,7 +101,7 @@
else:
self.design[t] = d
self.risk[t] = N.compress([s.atrisk(t) for s in self.subjects],
- N.arange(self.design[t].shape[0]))
+ N.arange(self.design[t].shape[0]),axis=-1)
def __del__(self):
shutil.rmtree(self.cachedir, ignore_errors=True)
Modified: trunk/Lib/sandbox/models/regression.py
===================================================================
--- trunk/Lib/sandbox/models/regression.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/models/regression.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -138,7 +138,7 @@
"""
Return the R^2 value for each row of the response Y.
"""
- self.Ssq = N.std(self.Z)**2
+ self.Ssq = N.std(self.Z,axis=0)**2
ratio = self.scale / self.Ssq
if not adjusted: ratio *= ((Y.shape[0] - 1) / self.df_resid)
return 1 - ratio
Modified: trunk/Lib/sandbox/models/utils.py
===================================================================
--- trunk/Lib/sandbox/models/utils.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/models/utils.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -22,7 +22,7 @@
"""
_shape = a.shape
- a.shape = N.product(a.shape)
+ a.shape = N.product(a.shape,axis=0)
m = scipy.median(N.fabs(a - scipy.median(a))) / c
a.shape = _shape
return m
@@ -123,7 +123,7 @@
"""
x = N.array(values, copy=True)
x.sort()
- x.shape = N.product(x.shape)
+ x.shape = N.product(x.shape,axis=0)
n = x.shape[0]
y = (N.arange(n) + 1.) / n
return StepFunction(x, y)
Modified: trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py
===================================================================
--- trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -37,7 +37,7 @@
#import pdb
#pdb.set_trace()
s = sampler.sample(n)
- assert sum(s[i]=='b' for i in range(n))*1./n > 0.75
+ assert sum(s[i]=='b' for i in range(n),axis=0)*1./n > 0.75
#lam = 10.0
#n = 35
@@ -68,8 +68,8 @@
v = x.var()
assert x.max() == 4
assert x.min() == 0
- assert sum(x==3) == 0
- assert 0.08 < average(x==1) < 0.12
+ assert sum(x==3,axis=0) == 0
+ assert 0.08 < average(x==1,axis=0) < 0.12
# Use a normal approx for confidence intervals for the mean
z = 2.5758 # = norminv(0.995), for a 1% confidence interval
assert abs(m - truemean) < z * sqrt(truevar/numsamples)
Modified: trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py
===================================================================
--- trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -62,8 +62,8 @@
v = x.var()
assert x.max() == 4
assert x.min() == 0
- assert sum(x==3) == 0
- assert 0.08 < average(x==1) < 0.12
+ assert sum(x==3,axis=0) == 0
+ assert 0.08 < average(x==1,axis=0) < 0.12
# Use a normal approx for confidence intervals for the mean
z = 2.5758 # = norminv(0.995), for a 1% confidence interval
assert abs(m - truemean) < z * sqrt(truevar/numsamples)
Modified: trunk/Lib/sandbox/numexpr/tests/test_numexpr.py
===================================================================
--- trunk/Lib/sandbox/numexpr/tests/test_numexpr.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/numexpr/tests/test_numexpr.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -49,8 +49,8 @@
('prod_ffn', 'r0', 't3', 2)])
# Check that full reductions work.
x = arange(10.0)
- assert_equal(evaluate("sum(x**2+2)"), sum(x**2+2))
- assert_equal(evaluate("prod(x**2+2)"), prod(x**2+2))
+ assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0))
+ assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0))
# Check that reductions along an axis work
y = arange(9.0).reshape(3,3)
assert_equal(evaluate("sum(y**2, axis=1)"), sum(y**2, axis=1))
@@ -61,16 +61,16 @@
assert_equal(evaluate("prod(y**2, axis=None)"), prod(y**2, axis=None))
# Check integers
x = x.astype(int)
- assert_equal(evaluate("sum(x**2+2)"), sum(x**2+2))
- assert_equal(evaluate("prod(x**2+2)"), prod(x**2+2))
+ assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0))
+ assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0))
# Check complex
x = x + 5j
- assert_equal(evaluate("sum(x**2+2)"), sum(x**2+2))
- assert_equal(evaluate("prod(x**2+2)"), prod(x**2+2))
+ assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0))
+ assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0))
# Check boolean (should cast to integer)
x = (arange(10) % 2).astype(bool)
- assert_equal(evaluate("prod(x)"), prod(x))
- assert_equal(evaluate("sum(x)"), sum(x))
+ assert_equal(evaluate("prod(x,axis=0)"), prod(x,axis=0))
+ assert_equal(evaluate("sum(x,axis=0)"), sum(x,axis=0))
def check_axis(self):
y = arange(9.0).reshape(3,3)
@@ -216,9 +216,9 @@
def equal(a, b, exact):
if exact:
- return (shape(a) == shape(b)) and alltrue(ravel(a) == ravel(b))
+ return (shape(a) == shape(b)) and alltrue(ravel(a) == ravel(b),axis=0)
else:
- return (shape(a) == shape(b)) and (allclose(ravel(a), ravel(b)) or alltrue(ravel(a) == ravel(b))) # XXX report a bug?
+ return (shape(a) == shape(b)) and (allclose(ravel(a), ravel(b)) or alltrue(ravel(a) == ravel(b),axis=0)) # XXX report a bug?
class Skip(Exception): pass
Modified: trunk/Lib/sandbox/odr/models.py
===================================================================
--- trunk/Lib/sandbox/odr/models.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/odr/models.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -9,7 +9,7 @@
a, b = B[0], B[1:]
b.shape = (b.shape[0], 1)
- return a + sum(x*b)
+ return a + sum(x*b,axis=0)
def _lin_fjb(B, x, concatenate=sb.concatenate, Float=sb.Float,
ones=sb.ones, ravel=sb.ravel):
@@ -20,7 +20,7 @@
def _lin_fjd(B, x, repeat=sb.repeat):
b = B[1:]
- b = repeat(b, (x.shape[-1],)*b.shape[-1])
+ b = repeat(b, (x.shape[-1],)*b.shape[-1],axis=0)
b.shape = x.shape
return b
@@ -40,7 +40,7 @@
a, b = B[0], B[1:]
b.shape = (b.shape[0], 1)
- return a + sum(b * power(x, powers))
+ return a + sum(b * power(x, powers),axis=0)
def _poly_fjacb(B, x, powers, power=sb.power,
concatenate=sb.concatenate, Float=sb.Float, ones=sb.ones):
@@ -54,7 +54,7 @@
b = b * powers
- return sum(b * power(x, powers-1))
+ return sum(b * power(x, powers-1),axis=0)
def _exp_fcn(B, x, exp=sb.exp):
return B[0] + exp(B[1] * x)
Modified: trunk/Lib/sandbox/rkern/diffev.py
===================================================================
--- trunk/Lib/sandbox/rkern/diffev.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/rkern/diffev.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -45,7 +45,7 @@
# S[i] = y_i
# else:
# Sa[i] = y_i
-# if alltrue(shift):
+# if alltrue(shift,axis=0):
# Find graph minima of f(x) using the Ng best points in S.
# Do local search from each minimum.
# Replace worst Ng points in S with best Ng points in Sa.
Modified: trunk/Lib/sandbox/rkern/pink.py
===================================================================
--- trunk/Lib/sandbox/rkern/pink.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/rkern/pink.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -9,7 +9,7 @@
m = 1
for i in range(k):
p = int(ceil(float(n) / m))
- pink += repeat(rvs(size=p), m)[:n]
+ pink += repeat(rvs(size=p), m,axis=0)[:n]
m <<= 1
return pink/k
Modified: trunk/Lib/sandbox/stats/anova.py
===================================================================
--- trunk/Lib/sandbox/stats/anova.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/stats/anova.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -72,7 +72,7 @@
Wscols = [0] + Wcolumns # w/i subj columns INCL col 0
Bscols = makelist(Bbetweens+1,Nfactors+1) #list of btw-subj cols,INCL col 0
Nwifactors = len(Wscols) - 1 # WAS len(Wcolumns)
- #Nwlevels = take(array(Nlevels),Wscols) # no.lvls for each w/i subj fact
+ #Nwlevels = take(array(Nlevels),Wscols,axis=0) # no.lvls for each w/i subj fact
#Nbtwfactors = len(Bscols) - 1 # WASNfactors - Nwifactors + 1
Nblevels = take(array(Nlevels),Bscols,0)
@@ -203,7 +203,7 @@
# dim-numbers change as you collapse). THIS WORKS BECAUSE WE'RE
# COLLAPSING ACROSS W/I SUBJECT AXES, WHICH WILL ALL HAVE THE
# SAME SUBJ IN THE SAME ARRAY LOCATIONS (i.e., dummyvals will still exist
- # but should remain the same value through the mean() function
+ # but should remain the same value through the mean(,axis=0) function
for i in range(len(Lwithinnonsource)-1,-1,-1):
dwsc = mean(dwsc,Lwithinnonsource[i])
mns = dwsc
@@ -287,7 +287,7 @@
idx[0] = -1
loopcap = array(tsubjslots.shape[0:-1]) -1
while incr(idx,loopcap) != -1:
- DNarray[idx] = float(sum(tsubjslots[idx]))
+ DNarray[idx] = float(sum(tsubjslots[idx],axis=0))
thismean = (add.reduce(tsubjslots[idx] * # 1=subj dim
transpose(D[dcount]),1) /
DNarray[idx])
@@ -354,9 +354,9 @@
## Calculate harmonic means for each level in source
sourceNarray = apply_over_axes(hmean, Narray,btwnonsourcedims)
- ## Calc grand average (ga), used for ALL effects
+ ## Calc grand average (ga,axis=0), used for ALL effects
ga = sum((sourceMarray*sourceNarray)/
- sum(sourceNarray))
+ sum(sourceNarray),axis=0),axis=0))
ga = reshape(ga,ones(len(Marray.shape)))
## If GRAND interaction, use harmonic mean of ALL cell Ns
@@ -379,7 +379,7 @@
## Calc and save sums of squares for this source
SS = sum((effect**2 *sourceNarray) *
- multiply.reduce(take(Marray.shape,btwnonsourcedims,0)))
+ multiply.reduce(take(Marray.shape,btwnonsourcedims,0)),axis=0)
## Save it so you don't have to calculate it again next time
SSlist.append(SS)
SSsources.append(source)
@@ -628,9 +628,9 @@
RSinter = zeros((levels,levels),PyObject)
for i in range(levels):
for j in range(i,levels):
- RSw[i,j] = RSw[j,i] = sum(tworkd[i]*tworkd[j])
+ RSw[i,j] = RSw[j,i] = sum(tworkd[i]*tworkd[j],axis=0)
cross = all_cellmeans[i] * all_cellmeans[j]
- multfirst = sum(cross*all_cellns[i])
+ multfirst = sum(cross*all_cellns[i],axis=0)
RSinter[i,j] = RSinter[j,i] = asarray(multfirst)
SSm[i,j] = SSm[j,i] = (mean(all_cellmeans[i],None) *
mean(all_cellmeans[j],None) *
@@ -654,7 +654,7 @@
# Calculate harmonic means for each level in source
sourceDNarray = apply_over_axes(hmean, DN[dindex],btwnonsourcedims)
- # Calc grand average (ga), used for ALL effects
+ # Calc grand average (ga,axis=0), used for ALL effects
variableNs = apply_over_axes(sum, sourceDNarray,
range(len(sourceDMarray.shape)-1))
ga = apply_over_axes(sum, (sourceDMarray*sourceDNarray) / \
@@ -745,7 +745,7 @@
while incr(idx,loopcap) != -1: # loop through source btw level-combos
mask = tsubjslots[idx]
thisgroup = tworkd*mask[newaxis,:]
- groupmns = mean(compress(mask,thisgroup),1)
+ groupmns = mean(compress(mask,thisgroup,axis=-1),1)
### THEN SUBTRACT THEM FROM APPROPRIATE SUBJECTS
errors = errors - multiply.outer(groupmns,mask)
Modified: trunk/Lib/sandbox/stats/obsolete.py
===================================================================
--- trunk/Lib/sandbox/stats/obsolete.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/stats/obsolete.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -30,7 +30,7 @@
def summult(array1, array2, axis=0):
"""
Multiplies elements in array1 and array2, element by element, and
-returns the sum (along 'axis') of all resulting multiplications.
+returns the sum (along 'axis',axis=0) of all resulting multiplications.
Axis can equal None (ravel array first), or an integer (the
axis over which to operate),
"""
Modified: trunk/Lib/sandbox/svm/classification.py
===================================================================
--- trunk/Lib/sandbox/svm/classification.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/svm/classification.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -55,7 +55,7 @@
d = {}
labels = self.labels
for v, (li, lj) in \
- izip(vv, chain(*[izip(repeat(x), labels[i+1:])
+ izip(vv, chain(*[izip(repeat(x,axis=0), labels[i+1:])
for i, x in enumerate(labels[:-1])])):
d[li, lj] = v
d[lj, li] = -v
Modified: trunk/Lib/sandbox/svm/dataset.py
===================================================================
--- trunk/Lib/sandbox/svm/dataset.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/svm/dataset.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -179,7 +179,7 @@
else:
y['index'][:-1] = N.arange(1,len(x) + 1)
y['value'][:-1] = x
- assert N.alltrue(y[:-1]['index'] >= 1), \
+ assert N.alltrue(y[:-1]['index'] >= 1,axis=0), \
'indexes must be positive'
assert len(x) == len(N.unique(y[:-1]['index'])), \
'indexes must be unique'
Modified: trunk/Lib/sandbox/svm/predict.py
===================================================================
--- trunk/Lib/sandbox/svm/predict.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/svm/predict.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -114,7 +114,7 @@
vote = N.zeros((nr_class, dec_values.shape[0]), N.uint32)
classidx = range(nr_class)
for pos, (i, j) in \
- enumerate(chain(*[izip(repeat(idx), classidx[k+1:])
+ enumerate(chain(*[izip(repeat(idx,axis=0), classidx[k+1:])
for k, idx in
enumerate(classidx[:-1])])):
ji = N.array((j, i))
Modified: trunk/Lib/sandbox/svm/tests/test_regression.py
===================================================================
--- trunk/Lib/sandbox/svm/tests/test_regression.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/svm/tests/test_regression.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -80,7 +80,7 @@
# use differences instead of assertAlmostEqual due to
# compiler-dependent variations in these values
diff = N.absolute(predictions - expected_y)
- self.assert_(N.alltrue(diff < 1e-3))
+ self.assert_(N.alltrue(diff < 1e-3,axis=0))
def check_cross_validate(self):
y = N.random.randn(100)
Modified: trunk/Lib/sandbox/xplt/Mplot.py
===================================================================
--- trunk/Lib/sandbox/xplt/Mplot.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/Mplot.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -1218,18 +1218,18 @@
img1 = DATA[imgsl1]
getdx1 = getdx.__copy__()
getdx1[slice1[0]] = 0
- dx1 = compress(getdx1,dx)
- xb1 = compress(getdx1,xb)
- xe1 = compress(getdx1,xe)
+ dx1 = compress(getdx1,dx,axis=-1)
+ xb1 = compress(getdx1,xb,axis=-1)
+ xe1 = compress(getdx1,xe,axis=-1)
imgsl2 = [slice(None,None),slice(None,None),slice(None,None)]
imgsl2[slice2[0]] = slice2[1]
img2 = DATA[imgsl2]
getdx2 = getdx.__copy__()
getdx2[slice2[0]] = 0
- dx2 = compress(getdx2,dx)
- xb2 = compress(getdx2,xb)
- xe2 = compress(getdx2,xe)
+ dx2 = compress(getdx2,dx,axis=-1)
+ xb2 = compress(getdx2,xb,axis=-1)
+ xe2 = compress(getdx2,xe,axis=-1)
if (slice1[0] == slice2[0]):
Modified: trunk/Lib/sandbox/xplt/NarPlotter.py
===================================================================
--- trunk/Lib/sandbox/xplt/NarPlotter.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/NarPlotter.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -1768,11 +1768,11 @@
val = s.val
elif s.plane is not None :
if len(s.val) == len (s.nv) :
- val = to_corners (s.val, s.nv, sum (s.nv))
+ val = to_corners (s.val, s.nv, sum (s.nv,axis=0))
else :
val = s.val
else :
- val = ones (sum (s.nv), Float) * s.iso
+ val = ones (sum (s.nv,axis=0), Float) * s.iso
else :
nv = concatenate ( (nv, s.nv))
x = concatenate ( (x, s.xyzv [:, 0]))
@@ -1784,13 +1784,13 @@
elif s.plane is not None :
if len(s.val) == len (s.nv) :
val = concatenate ( (val,
- to_corners (s.val, s.nv, sum (s.nv))))
+ to_corners (s.val, s.nv, sum (s.nv,axis=0))))
else :
val = concatenate ( (val, s.val))
else :
- val = concatenate ( (val, ones (sum (s.nv), Float) * s.iso))
+ val = concatenate ( (val, ones (sum (s.nv,axis=0), Float) * s.iso))
nc = len (nv)
- nv = concatenate ( (cumsum (nv), arange (len (x))))
+ nv = concatenate ( (cumsum (nv,axis=0), arange (len (x))))
## if isosurfaces_present :
## self.set_palette (self.split_palette)
self.set_color_card (graf._color_card)
Modified: trunk/Lib/sandbox/xplt/demo5.py
===================================================================
--- trunk/Lib/sandbox/xplt/demo5.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/demo5.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -215,7 +215,7 @@
n_zones = f.NumZones
# Put vertices in right order for Gist
n_z = transpose (
- take (transpose (n_z), array ( [0, 4, 3, 7, 1, 5, 2, 6])))
+ take (transpose (n_z), array ( [0, 4, 3, 7, 1, 5, 2, 6]),axis=0))
m3 = mesh3 (x, y, z, funcs = [c], verts = n_z ) # [0:10])
[nv, xyzv, cv] = slice3 (m3, 1, None, None, 1, value = .9 * max (c) )
pyz = plane3 ( array ([1, 0, 0], Float ), zeros (3, Float))
@@ -358,7 +358,7 @@
npyr = ZLsc [i]
# Now reorder the points (bill has the apex last instead of first)
nz_pyr = transpose (
- take (transpose (nz_pyr), array ( [4, 0, 1, 2, 3])))
+ take (transpose (nz_pyr), array ( [4, 0, 1, 2, 3]),axis=0))
istart = istart + ZLss [i] * ZLsc [i]
elif ZLss[i] == 6 : # PRISM
nz_prism = reshape (ZLsn [istart: istart + ZLss [i] * ZLsc [i]],
@@ -367,7 +367,7 @@
# now reorder the points (bill goes around a square face
# instead of traversing the opposite sides in the same direction.
nz_prism = transpose (
- take (transpose (nz_prism), array ( [0, 1, 3, 2, 4, 5])))
+ take (transpose (nz_prism), array ( [0, 1, 3, 2, 4, 5]),axis=0))
istart = istart + ZLss [i] * ZLsc [i]
elif ZLss[i] == 8 : # HEXAHEDRON
nz_hex = reshape (ZLsn [istart: istart + ZLss [i] * ZLsc [i]],
@@ -375,7 +375,7 @@
# now reorder the points (bill goes around a square face
# instead of traversing the opposite sides in the same direction.
nz_hex = transpose (
- take (transpose (nz_hex), array ( [0, 1, 3, 2, 4, 5, 7, 6])))
+ take (transpose (nz_hex), array ( [0, 1, 3, 2, 4, 5, 7, 6]),axis=0))
nhex = ZLsc [i]
istart = istart + ZLss [i] * ZLsc [i]
else :
Modified: trunk/Lib/sandbox/xplt/gist3dhelp.py
===================================================================
--- trunk/Lib/sandbox/xplt/gist3dhelp.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/gist3dhelp.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -217,7 +217,7 @@
or get3_light(xyz)
return 3D lighting for polygons with vertices XYZ. If NXYZ is
- specified, XYZ should be sum(nxyz)-by-3, with NXYZ being the
+ specified, XYZ should be sum(nxyz,axis=0)-by-3, with NXYZ being the
list of numbers of vertices for each polygon (as for the plfp
function). If NXYZ is not specified, XYZ should be a quadrilateral
mesh, ni-by-nj-by-3 (as for the plf function). In the first case,
@@ -235,7 +235,7 @@
or get3_normal(xyz)
return 3D normals for polygons with vertices XYZ. If NXYZ is
- specified, XYZ should be sum(nxyz)-by-3, with NXYZ being the
+ specified, XYZ should be sum(nxyz,axis=0)-by-3, with NXYZ being the
list of numbers of vertices for each polygon (as for the plfp
function). If NXYZ is not specified, XYZ should be a quadrilateral
mesh, ni-by-nj-by-3 (as for the plf function). In the first case,
@@ -257,7 +257,7 @@
or get3_centroid(xyz)
return 3D centroids for polygons with vertices XYZ. If NXYZ is
- specified, XYZ should be sum(nxyz)-by-3, with NXYZ being the
+ specified, XYZ should be sum(nxyz,axis=0)-by-3, with NXYZ being the
list of numbers of vertices for each polygon (as for the plfp
function). If NXYZ is not specified, XYZ should be a quadrilateral
mesh, ni-by-nj-by-3 (as for the plf function). In the first case,
@@ -332,7 +332,7 @@
"sort3d" :
"""
sort3d(z, npolys)
- given Z and NPOLYS, with len(Z)==sum(npolys), return
+ given Z and NPOLYS, with len(Z)==sum(npolys,axis=0), return
a 2-element list [LIST, VLIST] such that Z[VLIST] and NPOLYS[LIST] are
sorted from smallest average Z to largest average Z, where
the averages are taken over the clusters of length NPOLYS.
@@ -458,9 +458,9 @@
ravel(add.outer (adders,zeros(nj-1, Int))) +
arange((ni-1)*(nj-1), dtype = Int),
array ( [[0, 1], [nj + 1, nj]])))
- xyz=array([take(ravel(xyz[0]),list),
- take(ravel(xyz[1]),list),
- take(ravel(xyz[2]),list)])
+ xyz=array([take(ravel(xyz[0]),list,axis=0),
+ take(ravel(xyz[1]),list,axis=0),
+ take(ravel(xyz[2]),list,axis=0)])
nxyz= ones((ni-1)*(nj-1)) * 4;
The resulting array xyz is 3-by-(4*(nj-1)*(ni-1)).
xyz[0:3,4*i:4*(i+1)] are the clockwise coordinates of the
@@ -523,7 +523,7 @@
the list [NVERTS, XYZVERTS, color]. Note that it is impossible to
pass arguments as addresses, as yorick does in this routine.
NVERTS is the number of vertices in each polygon of the slice, and
- XYZVERTS is the 3-by-sum(NVERTS) list of polygon vertices. If the
+ XYZVERTS is the 3-by-sum(NVERTS,axis=0) list of polygon vertices. If the
FCOLOR argument is present, the values of that coloring function on
the polygons are returned as the value of the slice3 function
(numberof(color_values) == numberof(NVERTS) == number of polygons).
@@ -573,7 +573,7 @@
slice3mesh returns a triple [nverts, xyzverts, color]
nverts is no_cells long and the ith entry tells how many
vertices the ith cell has.
- xyzverts is sum (nverts) by 3 and gives the vertex
+ xyzverts is sum (nverts,axis=0) by 3 and gives the vertex
coordinates of the cells in order.
color, if present, is len (nverts) long and contains
a color value for each cell in the mesh.
@@ -781,7 +781,7 @@
Perform simple 3D rendering of an object created by slice3
(possibly followed by slice2). NVERTS and XYZVERTS are polygon
- lists as returned by slice3, so XYZVERTS is sum(NVERTS)-by-3,
+ lists as returned by slice3, so XYZVERTS is sum(NVERTS,axis=0)-by-3,
where NVERTS is a list of the number of vertices in each polygon.
If present, the VALUES should have the same length as NVERTS;
they are used to color the polygon. If VALUES is not specified,
@@ -797,7 +797,7 @@
cmin = None, cmax = None)
Add the polygon list specified by NVERTS (number of vertices in
- each polygon) and XYZVERTS (3-by-sum(NVERTS) vertex coordinates)
+ each polygon) and XYZVERTS (3-by-sum(NVERTS,axis=0) vertex coordinates)
to the currently displayed b-tree. If VALUES is specified, it
must have the same dimension as NVERTS, and represents the color
of each polygon. If VALUES is not specified, the polygons
Modified: trunk/Lib/sandbox/xplt/gistdemo3d.py
===================================================================
--- trunk/Lib/sandbox/xplt/gistdemo3d.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/gistdemo3d.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -255,7 +255,7 @@
# n_zones = f.NumZones
# # Put vertices in right order for Gist
# n_z = transpose (
-# take (transpose (n_z), array ( [0, 4, 3, 7, 1, 5, 2, 6])))
+# take (transpose (n_z), array ( [0, 4, 3, 7, 1, 5, 2, 6]),axis=0))
# m3 = mesh3 (x, y, z, funcs = [c], verts = n_z ) # [0:10])
# [nv, xyzv, cv] = slice3 (m3, 1, None, None, 1, value = .9 * max (c) )
# pyz = plane3 ( array ([1, 0, 0], Float ), zeros (3, Float))
@@ -400,7 +400,7 @@
# npyr = ZLsc [i]
# # Now reorder the points (bill has the apex last instead of first)
# nz_pyr = transpose (
-# take (transpose (nz_pyr), array ( [4, 0, 1, 2, 3])))
+# take (transpose (nz_pyr), array ( [4, 0, 1, 2, 3]),axis=0))
# istart = istart + ZLss [i] * ZLsc [i]
# elif ZLss[i] == 6 : # PRISM
# nz_prism = reshape (ZLsn [istart: istart + ZLss [i] * ZLsc [i]],
@@ -409,7 +409,7 @@
# # now reorder the points (bill goes around a square face
# # instead of traversing the opposite sides in the same direction.
# nz_prism = transpose (
-# take (transpose (nz_prism), array ( [0, 1, 3, 2, 4, 5])))
+# take (transpose (nz_prism), array ( [0, 1, 3, 2, 4, 5]),axis=0))
# istart = istart + ZLss [i] * ZLsc [i]
# elif ZLss[i] == 8 : # HEXAHEDRON
# nz_hex = reshape (ZLsn [istart: istart + ZLss [i] * ZLsc [i]],
@@ -417,7 +417,7 @@
# # now reorder the points (bill goes around a square face
# # instead of traversing the opposite sides in the same direction.
# nz_hex = transpose (
-# take (transpose (nz_hex), array ( [0, 1, 3, 2, 4, 5, 7, 6])))
+# take (transpose (nz_hex), array ( [0, 1, 3, 2, 4, 5, 7, 6]),axis=0))
# nhex = ZLsc [i]
# istart = istart + ZLss [i] * ZLsc [i]
# else :
Modified: trunk/Lib/sandbox/xplt/mesh3d.py
===================================================================
--- trunk/Lib/sandbox/xplt/mesh3d.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/mesh3d.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -212,10 +212,10 @@
n_z = self.cell_dict[k][1]
if n_z.shape [1] == 8 :
verts.append (
- take (n_z, array ( [0, 1, 3, 2, 4, 5, 7, 6])))
+ take (n_z, array ( [0, 1, 3, 2, 4, 5, 7, 6]),axis=0))
elif n_z.shape [1] == 6 :
verts.append (
- take (n_z, array ( [3, 0, 4, 1, 5, 2])))
+ take (n_z, array ( [3, 0, 4, 1, 5, 2]),axis=0))
else :
verts.append (n_z)
if len (verts) == 1 :
@@ -317,7 +317,7 @@
where :
nv is a one-dimensional integer array whose ith entry is the
number of vertices of the ith face.
- xyzv is a two-dimensional array dimensioned sum (nv) by 3.
+ xyzv is a two-dimensional array dimensioned sum (nv,axis=0) by 3.
The first nv [0] triples are the vertices of face [0],
the next nv [1] triples are the vertices of face [1], etc.
val (if present) is an array the same length as nv whose
Modified: trunk/Lib/sandbox/xplt/pl3d.py
===================================================================
--- trunk/Lib/sandbox/xplt/pl3d.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/pl3d.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -219,7 +219,7 @@
theta = kw ["theta"]
y = array ( [0., z [2], -z [1]])
x = dot (transpose (gr3), array ( [1., 0., 0.]))
- phi = arctan2 (sum (y * x), x [0])
+ phi = arctan2 (sum (y * x,axis=0), x [0])
else :
phi = kw ["phi"]
theta = kw ["theta"]
@@ -370,7 +370,7 @@
or get3_light(xyz)
return 3D lighting for polygons with vertices XYZ. If NXYZ is
- specified, XYZ should be sum(nxyz)-by-3, with NXYZ being the
+ specified, XYZ should be sum(nxyz,axis=0)-by-3, with NXYZ being the
list of numbers of vertices for each polygon (as for the plfp
function). If NXYZ is not specified, XYZ should be a quadrilateral
mesh, ni-by-nj-by-3 (as for the plf function). In the first case,
@@ -404,7 +404,7 @@
else :
view = array ( [0., 0., zc], Float) - get3_centroid (xyz, nxyz [0])
m1 = \
- sqrt ( sum (view * view))
+ sqrt ( sum (view * view,axis=0))
if m1 == 0. : m1 = 1.
view = view / m1
@@ -412,11 +412,11 @@
normal [2, ...] * view [2]
light = ambient + diffuse * abs (nv)
if specular != 0. :
- sv = transpose (transpose (sdir) / sqrt (sum (transpose (sdir*sdir))))
+ sv = transpose (transpose (sdir) / sqrt (sum (transpose (sdir*sdir),axis=0)))
sv = dot (sv, view)
if len (shape (sdir)) == 1 :
sn = sum(array([sdir[0]*normal[0],sdir[1]*normal[1],
- sdir[2]*normal[2]]))
+ sdir[2]*normal[2]]),axis=0)
####### I left out the specular_hook stuff.
m1 = maximum (sn * nv -0.5 * sv + 0.5, 1.e-30)
m1 = m1 ** spower
@@ -426,7 +426,7 @@
nsrc = len (shape (sdir))
for i in range (nsrc) :
sn = sum(array([sdir[i,0]*normal[0],sdir[i,1]*normal[1],
- sdir[i,2]*normal[2]]))
+ sdir[i,2]*normal[2]]),axis=0)
m1 = maximum (sn * nv -0.5 * sv [i] + 0.5, 1.e-30) ** spower [i]
light = light + specular * m1
return light
@@ -438,7 +438,7 @@
or get3_normal(xyz)
return 3D normals for polygons with vertices XYZ. If NXYZ is
- specified, XYZ should be sum(nxyz)-by-3, with NXYZ being the
+ specified, XYZ should be sum(nxyz,axis=0)-by-3, with NXYZ being the
list of numbers of vertices for each polygon (as for the plfp
function). If NXYZ is not specified, XYZ should be a quadrilateral
mesh, ni-by-nj-by-3 (as for the plf function). In the first case,
@@ -463,7 +463,7 @@
else :
# with polygon list, more elaborate calculation required
# (1) frst subscripts the first vertex of each polygon
- frst = cumsum (nxyz [0]) - nxyz [0]
+ frst = cumsum (nxyz [0],axis=0) - nxyz [0]
# form normal by getting two approximate diameters
# (reduces to above medians for quads)
@@ -508,7 +508,7 @@
or get3_centroid(xyz)
return 3D centroids for polygons with vertices XYZ. If NXYZ is
- specified, XYZ should be sum(nxyz)-by-3, with NXYZ being the
+ specified, XYZ should be sum(nxyz,axis=0)-by-3, with NXYZ being the
list of numbers of vertices for each polygon (as for the plfp
function). If NXYZ is not specified, XYZ should be a quadrilateral
mesh, ni-by-nj-by-3 (as for the plf function). In the first case,
@@ -526,9 +526,9 @@
centroid = zcen_ (zcen_ (xyz, 1), 0)
else :
# with polygon list, more elaborate calculation required
- last = cumsum (nxyz [0])
+ last = cumsum (nxyz [0],axis=0)
list = histogram (1 + last) [0:-1]
- list = cumsum (list)
+ list = cumsum (list,axis=0)
k = len (nxyz [0])
l = shape (xyz) [0]
centroid = zeros ( (k, 3))
@@ -807,7 +807,7 @@
"""
sort3d(z, npolys)
- given Z and NPOLYS, with len(Z)==sum(npolys), return
+ given Z and NPOLYS, with len(Z)==sum(npolys,axis=0), return
a 2-element list [LIST, VLIST] such that Z[VLIST] and NPOLYS[LIST] are
sorted from smallest average Z to largest average Z, where
the averages are taken over the clusters of length NPOLYS.
@@ -834,8 +834,8 @@
# get a list the same length as x, y, or z which is 1 for each
# vertex of poly 1, 2 for each vertex of poly2, etc.
# the goal is to make nlist with histogram(nlist)==npolys
- nlist = histogram(cumsum (npolys)) [0:-1]
- nlist = cumsum (nlist)
+ nlist = histogram(cumsum (npolys,axis=0)) [0:-1]
+ nlist = cumsum (nlist,axis=0)
# now sum the vertex values and divide by the number of vertices
z = histogram (nlist, z) / npolys
@@ -1079,7 +1079,7 @@
# label positions: first find shortest axis
xy = sqrt (x1 * x1 + y1 * y1)
xysum = add.reduce (xy)
- i = argmin (xy) # mnx (xy)
+ i = argmin (xy,axis=-1) # mnx (xy)
jk = [ [1, 2], [2, 0], [0, 1]] [i]
j = jk [0]
k = jk [1]
Modified: trunk/Lib/sandbox/xplt/slice3.py
===================================================================
--- trunk/Lib/sandbox/xplt/slice3.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/slice3.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -72,8 +72,8 @@
# the normal doesn't really need to be normalized, but this
# has the desirable side effect of blowing up if normal==0
newnorm = zeros (4, Float)
- newnorm [0:3] = normal / sqrt (sum (normal*normal))
- newnorm [3] = sum (multiply (normal, point))
+ newnorm [0:3] = normal / sqrt (sum (normal*normal,axis=0))
+ newnorm [3] = sum (multiply (normal, point),axis=0)
return newnorm
_Mesh3Error = "Mesh3Error"
@@ -255,7 +255,7 @@
the list [NVERTS, XYZVERTS, color]. Note that it is impossible to
pass arguments as addresses, as yorick does in this routine.
NVERTS is the number of vertices in each polygon of the slice, and
- XYZVERTS is the 3-by-sum(NVERTS) list of polygon vertices. If the
+ XYZVERTS is the 3-by-sum(NVERTS,axis=0) list of polygon vertices. If the
FCOLOR argument is present, the values of that coloring function on
the polygons are returned as the value of the slice3 function
(numberof(color_values) == numberof(NVERTS) == number of polygons).
@@ -442,8 +442,8 @@
critical_cells = bitwise_and (add.reduce \
(reshape (ravel (transpose (less (fs [0], slice3_precision))), \
(8, dim1))), 7)
- if (sum (critical_cells) != 0) :
- clist = take (fs [1], nonzero (critical_cells))
+ if (sum (critical_cells,axis=0) != 0) :
+ clist = take (fs [1], nonzero (critical_cells),axis=0)
ntotal8 = ntotal8 + len (clist)
else :
clist = None
@@ -457,8 +457,8 @@
(6, dim1)))
critical_cells = logical_and (greater (critical_cells, 0),
less (critical_cells, 6))
- if (sum (critical_cells) != 0) :
- clist = take (fs [1], nonzero (critical_cells))
+ if (sum (critical_cells,axis=0) != 0) :
+ clist = take (fs [1], nonzero (critical_cells),axis=0)
ntotal6 = ntotal6 + len (clist)
else :
clist = None
@@ -472,8 +472,8 @@
(5, dim1)))
critical_cells = logical_and (greater (critical_cells, 0),
less (critical_cells, 5))
- if (sum (critical_cells) != 0) :
- clist = take (fs [1], nonzero (critical_cells))
+ if (sum (critical_cells,axis=0) != 0) :
+ clist = take (fs [1], nonzero (critical_cells),axis=0)
ntotal5 = ntotal5 + len (clist)
else :
clist = None
@@ -485,8 +485,8 @@
critical_cells = bitwise_and (add.reduce \
(reshape (ravel (transpose (less (fs [0], slice3_precision))), \
(4, dim1))), 3)
- if (sum (critical_cells) != 0) :
- clist = take (fs [1], nonzero (critical_cells))
+ if (sum (critical_cells,axis=0) != 0) :
+ clist = take (fs [1], nonzero (critical_cells),axis=0)
ntotal4 = ntotal4 + len (clist)
else :
clist = None
@@ -501,7 +501,7 @@
clist1 = ravel (zcen_ (zcen_ (zcen_
(array (less (fs, slice3_precision), Float), 0), 1), 2))
clist1 = logical_and (less (clist1, .9), greater (clist1, .1))
- if sum (clist1) > 0 :
+ if sum (clist1,axis=0) > 0 :
clist = nonzero (clist1)
ntotal = ntotal + len (clist)
else :
@@ -516,30 +516,30 @@
# values at the vertices of these cells
if (irregular) :
# extract the portions of the data indexed by clist
- fs = take (fs [0], clist)
+ fs = take (fs [0], clist,axis=0)
if got_xyz :
- _xyz3 = take (_xyz3, clist)
+ _xyz3 = take (_xyz3, clist,axis=0)
if col :
- col = take (col, clist)
+ col = take (col, clist,axis=0)
else :
# extract the to_corners portions of the data indexed by clist
indices = to_corners3 (clist, dims [1], dims [2])
no_cells = shape (indices) [0]
indices = ravel (indices)
- fs = reshape (take (ravel (fs), indices),\
+ fs = reshape (take (ravel (fs), indices,axis=0),\
(no_cells, 2, 2, 2))
if got_xyz :
new_xyz3 = zeros ( (no_cells, 3, 2, 2, 2), Float )
new_xyz3 [:, 0, ...] = reshape (take (ravel (_xyz3 [0, ...]),\
- indices), (no_cells, 2, 2, 2))
+ indices,axis=0), (no_cells, 2, 2, 2))
new_xyz3 [:, 1, ...] = reshape (take (ravel (_xyz3 [1, ...]),\
- indices), (no_cells, 2, 2, 2))
+ indices,axis=0), (no_cells, 2, 2, 2))
new_xyz3 [:, 2, ...] = reshape (take (ravel (_xyz3 [2, ...]),\
- indices), (no_cells, 2, 2, 2))
+ indices,axis=0), (no_cells, 2, 2, 2))
_xyz3 = new_xyz3
del new_xyz3
if col != None :
- col = reshape (take (ravel (col), indices), (no_cells, 2, 2, 2))
+ col = reshape (take (ravel (col), indices,axis=0), (no_cells, 2, 2, 2))
# NB: col represents node colors, and is only used
# if those are requested.
# here, the iterator converts to absolute cell indices without
@@ -616,27 +616,27 @@
# construct edge endpoint indices in fs, xyz arrays
# the numbers are the endpoint indices corresponding to
# the order of the _no_edges [i] edges in the mask array
- lower = take (_lower_vert [i], edges) + _no_verts [i] * cells
- upper = take (_upper_vert [i], edges) + _no_verts [i] * cells
- fsl = take (ravel (fs), lower)
- fsu = take (ravel (fs), upper)
+ lower = take (_lower_vert [i], edges,axis=0) + _no_verts [i] * cells
+ upper = take (_upper_vert [i], edges,axis=0) + _no_verts [i] * cells
+ fsl = take (ravel (fs), lower,axis=0)
+ fsu = take (ravel (fs), upper,axis=0)
# following denominator guaranteed non-zero
denom = fsu - fsl
fsu = fsu / denom
fsl = fsl / denom
new_xyz = zeros ( (len (lower), 3), Float )
- new_xyz [:, 0] = reshape ( (take (ravel (xyz [:, 0]), lower) * fsu - \
- take (ravel (xyz [:, 0]), upper) * fsl), (len (lower),))
- new_xyz [:, 1] = reshape ( (take (ravel (xyz [:, 1]), lower) * fsu - \
- take (ravel (xyz [:, 1]), upper) * fsl), (len (lower),))
- new_xyz [:, 2] = reshape ( (take (ravel (xyz [:, 2]), lower) * fsu - \
- take (ravel (xyz [:, 2]), upper) * fsl), (len (lower),))
+ new_xyz [:, 0] = reshape ( (take (ravel (xyz [:, 0]), lower,axis=0) * fsu - \
+ take (ravel (xyz [:, 0]), upper,axis=0) * fsl), (len (lower),))
+ new_xyz [:, 1] = reshape ( (take (ravel (xyz [:, 1]), lower,axis=0) * fsu - \
+ take (ravel (xyz [:, 1]), upper,axis=0) * fsl), (len (lower),))
+ new_xyz [:, 2] = reshape ( (take (ravel (xyz [:, 2]), lower,axis=0) * fsu - \
+ take (ravel (xyz [:, 2]), upper,axis=0) * fsl), (len (lower),))
xyz = new_xyz
del new_xyz
if col != None :
# Extract subset of the data the same way
- col = take (ravel (col), lower) * fsu - \
- take (ravel (col), upper) * fsl
+ col = take (ravel (col), lower,axis=0) * fsu - \
+ take (ravel (col), upper,axis=0) * fsl
# The xyz array is now the output xyzverts array,
# but for the order of the points within each cell.
@@ -645,10 +645,10 @@
# above and below the slicing plane
p2 = left_shift (ones (_no_verts [i], Int) , array (
[0, 1, 2, 3, 4, 5, 6, 7], Int) [0: _no_verts [i]])
- pattern = transpose (sum (transpose (multiply (below, p2))))
+ pattern = transpose (sum (transpose (multiply (below, p2)),axis=0))
# broadcast the cell's pattern onto each of its sliced edges
- pattern = take (pattern, list / _no_edges [i])
+ pattern = take (pattern, list / _no_edges [i],axis=0)
# Let ne represent the number of edges of this type of cell,
# and nv the number of vertices.
# To each pattern, there corresponds a permutation of the
@@ -662,17 +662,17 @@
# Let these permutations be stored in a ne-by-2**nv - 2 array
# _poly_permutations (see next comment for explanation of 4 * ne):
pattern = take (ravel (transpose (_poly_permutations [i])),
- _no_edges [i] * (pattern - 1) + edges) + 4 * _no_edges [i] * cells
+ _no_edges [i] * (pattern - 1) + edges,axis=0) + 4 * _no_edges [i] * cells
order = argsort (pattern)
xyz1 = zeros ( (len (order), 3), Float )
- xyz1 [:,0] = take (ravel (xyz [:,0]), order)
- xyz1 [:,1] = take (ravel (xyz [:,1]), order)
- xyz1 [:,2] = take (ravel (xyz [:,2]), order)
+ xyz1 [:,0] = take (ravel (xyz [:,0]), order,axis=0)
+ xyz1 [:,1] = take (ravel (xyz [:,1]), order,axis=0)
+ xyz1 [:,2] = take (ravel (xyz [:,2]), order,axis=0)
xyz = xyz1
if col != None :
- col = take (col, order)
- edges = take (edges, order)
- pattern = take (pattern, order)
+ col = take (col, order,axis=0)
+ edges = take (edges, order,axis=0)
+ pattern = take (pattern, order,axis=0)
# cells(order) is same as cells by construction */
# There remains only the question of splitting the points in
@@ -697,7 +697,7 @@
list [1:] = nz + 1
newpat = zeros (len (pattern) + 1, Int)
newpat [0] = 1
- newpat [1:] = cumsum (not_equal (pattern, 0)) + 1
+ newpat [1:] = cumsum (not_equal (pattern, 0),axis=0) + 1
pattern = newpat
nverts = histogram (pattern) [1:]
xyzverts = xyz
@@ -709,7 +709,7 @@
# if some polys have been split, need to split clist as well
if len (list) > len (clist) :
- clist = take (clist, take (cells, list))
+ clist = take (clist, take (cells, list, axis=0),axis=0)
if col == None :
if nointerp == None :
if type (fcolor) == FunctionType :
@@ -780,7 +780,7 @@
slice3mesh returns a triple [nverts, xyzverts, color]
nverts is no_cells long and the ith entry tells how many
vertices the ith cell has.
- xyzverts is sum (nverts) by 3 and gives the vertex
+ xyzverts is sum (nverts,axis=0) by 3 and gives the vertex
coordinates of the cells in order.
color, if present, is len (nverts) long and contains
a color value for each cell in the mesh.
@@ -889,18 +889,18 @@
elif shape (color) == (ncx, ncy) and smooth == 0 :
col = ravel (color)
# Lower left, upper left, upper right, lower right
- col = 0.25 * (take (col, ravel (add.outer ( ncxx, ncyy))) +
- take (col, ravel (add.outer ( ncxx, ncyy + 1))) +
- take (col, ravel (add.outer ( ncxx + ncy, ncyy + 1))) +
- take (col, ravel (add.outer ( ncxx + ncy, ncyy))))
+ col = 0.25 * (take (col, ravel (add.outer ( ncxx, ncyy)),axis=0) +
+ take (col, ravel (add.outer ( ncxx, ncyy + 1)),axis=0) +
+ take (col, ravel (add.outer ( ncxx + ncy, ncyy + 1)),axis=0) +
+ take (col, ravel (add.outer ( ncxx + ncy, ncyy)),axis=0))
elif shape (color) == (ncx, ncy) and smooth != 0 :
# Node-centered colors are wanted (smooth plots)
col = ravel (color)
col = ravel (transpose (array ( [
- take (col, ravel (add.outer ( ncxx, ncyy))),
- take (col, ravel (add.outer ( ncxx, ncyy + 1))),
- take (col, ravel (add.outer ( ncxx + ncy, ncyy + 1))),
- take (col, ravel (add.outer ( ncxx + ncy, ncyy)))])))
+ take (col, ravel (add.outer ( ncxx, ncyy)),axis=0),
+ take (col, ravel (add.outer ( ncxx, ncyy + 1)),axis=0),
+ take (col, ravel (add.outer ( ncxx + ncy, ncyy + 1)),axis=0),
+ take (col, ravel (add.outer ( ncxx + ncy, ncyy)),axis=0)])))
else :
raise _Slice3MeshError, \
"color must be cell-centered or vertex centered."
@@ -920,22 +920,22 @@
else :
newx = ravel (x)
xyzverts [:, 0] = ravel (transpose (array ( [
- take (newx, ravel (add.outer ( ncxx, ncyy))),
- take (newx, ravel (add.outer ( ncxx, ncyy + 1))),
- take (newx, ravel (add.outer ( ncxx + ncy, ncyy + 1))),
- take (newx, ravel (add.outer ( ncxx + ncy, ncyy)))])))
+ take (newx, ravel (add.outer ( ncxx, ncyy)),axis=0),
+ take (newx, ravel (add.outer ( ncxx, ncyy + 1)),axis=0),
+ take (newx, ravel (add.outer ( ncxx + ncy, ncyy + 1)),axis=0),
+ take (newx, ravel (add.outer ( ncxx + ncy, ncyy)),axis=0)])))
newy = ravel (y)
xyzverts [:, 1] = ravel (transpose (array ( [
- take (newy, ravel (add.outer ( ncxx, ncyy))),
- take (newy, ravel (add.outer ( ncxx, ncyy + 1))),
- take (newy, ravel (add.outer ( ncxx + ncy, ncyy + 1))),
- take (newy, ravel (add.outer ( ncxx + ncy, ncyy)))])))
+ take (newy, ravel (add.outer ( ncxx, ncyy)),axis=0),
+ take (newy, ravel (add.outer ( ncxx, ncyy + 1)),axis=0),
+ take (newy, ravel (add.outer ( ncxx + ncy, ncyy + 1)),axis=0),
+ take (newy, ravel (add.outer ( ncxx + ncy, ncyy)),axis=0)])))
newz = ravel (z)
xyzverts [:, 2] = ravel (transpose (array ( [
- take (newz, ravel (add.outer ( ncxx, ncyy))),
- take (newz, ravel (add.outer ( ncxx, ncyy + 1))),
- take (newz, ravel (add.outer ( ncxx + ncy, ncyy + 1))),
- take (newz, ravel (add.outer ( ncxx + ncy, ncyy)))])))
+ take (newz, ravel (add.outer ( ncxx, ncyy)),axis=0),
+ take (newz, ravel (add.outer ( ncxx, ncyy + 1)),axis=0),
+ take (newz, ravel (add.outer ( ncxx + ncy, ncyy + 1)),axis=0),
+ take (newz, ravel (add.outer ( ncxx + ncy, ncyy)),axis=0)])))
return [nverts, xyzverts, col]
@@ -1041,7 +1041,7 @@
offsets = array ( [njnk, nj, 1], Int)
if clist != None :
# add offset for this chunk to clist and return
- return sum (offsets * ( chunk [0] - 1)) + clist
+ return sum (offsets * ( chunk [0] - 1),axis=0) + clist
# increment to next chunk
xi = chunk [1, 0]
@@ -1229,7 +1229,7 @@
indices = to_corners3 (chunk, dims [0] + 1, dims [1] + 1)
no_cells = shape (indices) [0]
indices = ravel (indices)
- retval = reshape (take (ravel (fi [i]), indices), (no_cells, 2, 2, 2))
+ retval = reshape (take (ravel (fi [i]), indices,axis=0), (no_cells, 2, 2, 2))
return [retval, chunk]
@@ -1282,13 +1282,13 @@
tc = shape (verts) [1]
# ZCM 2/4/97 the array of cell numbers must be relative
if tc == 8 : # hex cells
- return [ reshape (take (fi [i], indices), (no_cells, 2, 2, 2)),
+ return [ reshape (take (fi [i], indices,axis=0), (no_cells, 2, 2, 2)),
arange (0, no_cells, dtype = Int), oldstart]
elif tc == 6 : # pyramids
- return [ reshape (take (fi [i], indices), (no_cells, 3, 2)),
+ return [ reshape (take (fi [i], indices,axis=0), (no_cells, 3, 2)),
arange (0, no_cells, dtype = Int), oldstart]
else : # tetrahedron or pyramid
- return [ reshape (take (fi [i], indices), (no_cells, tc)),
+ return [ reshape (take (fi [i], indices,axis=0), (no_cells, tc)),
arange (0, no_cells, dtype = Int), oldstart]
_Getc3Error = "Getc3Error"
@@ -1362,7 +1362,7 @@
c [0, 2] - 1:1 + c [1, 2]]
else :
[k, l. m] = dims
- return reshape (take (ravel (fi [i - 1]), chunk),
+ return reshape (take (ravel (fi [i - 1]), chunk,axis=0),
(len (chunk), k, l, m))
else :
# it is vertex-centered, so we take averages to get cell quantity
@@ -1379,13 +1379,13 @@
indices = to_corners3 (chunk, dims [1] + 1, dims [2] + 1)
no_cells = shape (indices) [0]
indices = ravel (indices)
- corners = take (ravel (fi [i - 1]), indices)
+ corners = take (ravel (fi [i - 1]), indices,axis=0)
if l == None :
- return 0.125 * sum (transpose (reshape (corners, (no_cells, 8))))
+ return 0.125 * sum (transpose (reshape (corners, (no_cells, 8))),axis=0)
else :
# interpolate corner values to get edge values
- corners = (take (corners, l) * fsu -
- take (corners, u) * fsl) / (fsu -fsl)
+ corners = (take (corners, l,axis=0) * fsu -
+ take (corners, u,axis=0) * fsl) / (fsu -fsl)
# average edge values (vertex values of polys) on each poly
return histogram (cells, corners) / histogram (cells)
@@ -1420,7 +1420,7 @@
if type (chunk) == ListType :
return fi [i - 1] [chunk [0] [0]:chunk [0] [1]]
elif type (chunk) == ArrayType and len (shape (chunk)) == 1 :
- return take (fi [i - 1], chunk)
+ return take (fi [i - 1], chunk,axis=0)
else :
raise _Getc3Error, "chunk argument is incomprehensible."
@@ -1434,7 +1434,7 @@
if type (chunk) == ListType :
indices = verts [chunk [0] [0]:chunk [0] [1]]
elif type (chunk) == ArrayType and len (shape (chunk)) == 1 :
- indices = take (verts, chunk)
+ indices = take (verts, chunk,axis=0)
else :
raise _Getc3Error, "chunk argument is incomprehensible."
else :
@@ -1459,21 +1459,21 @@
ch = chunk
if j > 0 :
ch = chunk - totals [j - 1]
- indices = take (verts, ch)
+ indices = take (verts, ch,axis=0)
else :
raise _Getc3Error, "chunk argument is incomprehensible."
shp = shape (indices)
no_cells = shp [0]
indices = ravel (indices)
- corners = take (fi [i - 1], indices)
+ corners = take (fi [i - 1], indices,axis=0)
if l == None :
return (1. / shp [1]) * transpose ((sum (transpose (reshape (corners,
- (no_cells, shp [1]))) [0:shp [1]])))
+ (no_cells, shp [1]))) [0:shp [1]],axis=0)))
else :
# interpolate corner values to get edge values
- corners = (take (corners, l) * fsu -
- take (corners, u) * fsl) / (fsu -fsl)
+ corners = (take (corners, l,axis=0) * fsu -
+ take (corners, u,axis=0) * fsl) / (fsu -fsl)
# average edge values (vertex values of polys) on each poly
return histogram (cells, corners) / histogram (cells)
@@ -1913,7 +1913,7 @@
Perform simple 3D rendering of an object created by slice3
(possibly followed by slice2). NVERTS and XYZVERTS are polygon
- lists as returned by slice3, so XYZVERTS is sum(NVERTS)-by-3,
+ lists as returned by slice3, so XYZVERTS is sum(NVERTS,axis=0)-by-3,
where NVERTS is a list of the number of vertices in each polygon.
If present, the VALUES should have the same length as NVERTS;
they are used to color the polygon. If VALUES is not specified,
@@ -1953,10 +1953,10 @@
# xyzverts [:, 2] = z
values = get3_light (xyztmp, nverts)
[list, vlist] = sort3d (z, nverts)
- nverts = take (nverts, list)
- values = take (values, list)
- x = take (x, vlist)
- y = take (y, vlist)
+ nverts = take (nverts, list,axis=0)
+ values = take (values, list,axis=0)
+ x = take (x, vlist,axis=0)
+ y = take (y, vlist,axis=0)
_square = get_square_ ( )
[_xfactor, _yfactor] = get_factors_ ()
xmax = max (x)
@@ -1990,7 +1990,7 @@
nverts = array (nverts, Int)
xyzverts = array (xyzverts, Float )
- if shape (xyzverts) [0] != sum (nverts) or sum (less (nverts, 3)) or \
+ if shape (xyzverts) [0] != sum (nverts,axis=0) or sum (less (nverts, 3),axis=0) or \
nverts.dtype != Int :
raise _Pl3surfError, "illegal or inconsistent polygon list"
if values != None and len (values) != len (nverts) :
@@ -2023,7 +2023,7 @@
cmin = None, cmax = None)
Add the polygon list specified by NVERTS (number of vertices in
- each polygon) and XYZVERTS (3-by-sum(NVERTS) vertex coordinates)
+ each polygon) and XYZVERTS (3-by-sum(NVERTS,axis=0) vertex coordinates)
to the currently displayed b-tree. If VALUES is specified, it
must have the same dimension as NVERTS, and represents the color
of each polygon. If VALUES is not specified, the polygons
@@ -2096,22 +2096,22 @@
if plane != None :
plane = plane.astype (Float)
- if shape (xyzverts) [0] != sum (nverts) or sum (less (nverts, 3)) > 0 or \
+ if shape (xyzverts) [0] != sum (nverts,axis=0) or sum (less (nverts, 3),axis=0) > 0 or \
type (nverts [0]) != IntType :
- print "Dim1 of xyzverts ", shape (xyzverts) [0], " sum (nverts) ",\
- sum (nverts), " sum (less (nverts, 3)) ", sum (less (nverts, 3)), \
+ print "Dim1 of xyzverts ", shape (xyzverts) [0], " sum (nverts,axis=0) ",\
+ sum (nverts,axis=0), " sum (less (nverts, 3),axis=0) ", sum (less (nverts, 3),axis=0), \
" type (nverts [0]) ", `type (nverts [0])`
raise _Pl3treeError, "illegal or inconsistent polygon list."
if type (values) == ArrayType and len (values) != len (nverts) and \
- len (values) != sum (nverts) :
+ len (values) != sum (nverts,axis=0) :
raise _Pl3treeError, "illegal or inconsistent polygon color values"
- if type (values) == ArrayType and len (values) == sum (nverts) :
+ if type (values) == ArrayType and len (values) == sum (nverts,axis=0) :
# We have vertex-centered values, which for Gist must be
# averaged over each cell
- list = zeros (sum (nverts), Int)
- array_set (list, cumsum (nverts) [0:-1], ones (len (nverts), Int))
+ list = zeros (sum (nverts,axis=0), Int)
+ array_set (list, cumsum (nverts,axis=0) [0:-1], ones (len (nverts), Int))
tpc = values.dtype
- values = (histogram (cumsum (list), values) / nverts).astype (tpc)
+ values = (histogram (cumsum (list,axis=0), values) / nverts).astype (tpc)
if plane != None :
if (len (shape (plane)) != 1 or shape (plane) [0] != 4) :
raise _Pl3treeError, "illegal plane format, try plane3 function"
@@ -2694,11 +2694,11 @@
# sort the single polygon list
if not_plane :
[_list, _vlist] = sort3d (_z, _nverts)
- _nverts = take (_nverts, _list)
+ _nverts = take (_nverts, _list,axis=0)
if _values != "bg" :
- _values = take (_values, _list)
- _x = take (_x, _vlist)
- _y = take (_y, _vlist)
+ _values = take (_values, _list,axis=0)
+ _x = take (_x, _vlist,axis=0)
+ _y = take (_y, _vlist,axis=0)
_square = get_square_ ( )
[_xfactor, _yfactor] = get_factors_ ()
@@ -2950,7 +2950,7 @@
for leaf in list :
print indent + "leaf length= " + `len (leaf)`
print indent + "npolys= " + `len (leaf [0])` + \
- ", nverts= " + `sum (leaf [0])` + ", max= " + `max (leaf [0])`
+ ", nverts= " + `sum (leaf [0],axis=0)` + ", max= " + `max (leaf [0])`
print indent + "nverts= " + `shape (leaf [1]) [0]` + \
", nvals= " + `len (leaf [2])`
@@ -3059,11 +3059,11 @@
indices = ravel (indices)
retval = zeros ( (no_cells, 3, 2, 2, 2), Float )
m30 = ravel (m3 [1] [0, ...])
- retval [:, 0, ...] = reshape (take (m30, indices), (no_cells, 2, 2, 2))
+ retval [:, 0, ...] = reshape (take (m30, indices,axis=0), (no_cells, 2, 2, 2))
m31 = ravel (m3 [1] [1, ...])
- retval [:, 1, ...] = reshape (take (m31, indices), (no_cells, 2, 2, 2))
+ retval [:, 1, ...] = reshape (take (m31, indices,axis=0), (no_cells, 2, 2, 2))
m32 = ravel (m3 [1] [2, ...])
- retval [:, 2, ...] = reshape (take (m32, indices), (no_cells, 2, 2, 2))
+ retval [:, 2, ...] = reshape (take (m32, indices,axis=0), (no_cells, 2, 2, 2))
return retval
_xyz3Error = "xyz3Error"
@@ -3104,45 +3104,45 @@
else :
start = 0
verts = m3 [1] [0] [i]
- ns = take (verts, chunk - start)
+ ns = take (verts, chunk - start,axis=0)
shp = shape (verts)
else :
- ns = take (m3 [1] [0], chunk)
+ ns = take (m3 [1] [0], chunk,axis=0)
shp = shape (m3 [1] [0])
else :
raise _xyz3Error, "chunk parameter has the wrong type."
if shp [1] == 8 : # hex
retval = zeros ( (no_cells, 3, 2, 2, 2), Float)
retval [:, 0] = \
- reshape (take (xyz [0], ravel (ns)), (no_cells, 2, 2, 2))
+ reshape (take (xyz [0], ravel (ns),axis=0), (no_cells, 2, 2, 2))
retval [:, 1] = \
- reshape (take (xyz [1], ravel (ns)), (no_cells, 2, 2, 2))
+ reshape (take (xyz [1], ravel (ns),axis=0), (no_cells, 2, 2, 2))
retval [:, 2] = \
- reshape (take (xyz [2], ravel (ns)), (no_cells, 2, 2, 2))
+ reshape (take (xyz [2], ravel (ns),axis=0), (no_cells, 2, 2, 2))
elif shp [1] == 6 : # prism
retval = zeros ( (no_cells, 3, 3, 2), Float)
retval [:, 0] = \
- reshape (take (xyz [0], ravel (ns)), (no_cells, 3, 2))
+ reshape (take (xyz [0], ravel (ns),axis=0), (no_cells, 3, 2))
retval [:, 1] = \
- reshape (take (xyz [1], ravel (ns)), (no_cells, 3, 2))
+ reshape (take (xyz [1], ravel (ns),axis=0), (no_cells, 3, 2))
retval [:, 2] = \
- reshape (take (xyz [2], ravel (ns)), (no_cells, 3, 2))
+ reshape (take (xyz [2], ravel (ns),axis=0), (no_cells, 3, 2))
elif shp [1] == 5 : # pyramid
retval = zeros ( (no_cells, 3, 5), Float)
retval [:, 0] = \
- reshape (take (xyz [0], ravel (ns)), (no_cells, 5))
+ reshape (take (xyz [0], ravel (ns),axis=0), (no_cells, 5))
retval [:, 1] = \
- reshape (take (xyz [1], ravel (ns)), (no_cells, 5))
+ reshape (take (xyz [1], ravel (ns),axis=0), (no_cells, 5))
retval [:, 2] = \
- reshape (take (xyz [2], ravel (ns)), (no_cells, 5))
+ reshape (take (xyz [2], ravel (ns),axis=0), (no_cells, 5))
elif shp [1] == 4 : # tet
retval = zeros ( (no_cells, 3, 4), Float)
retval [:, 0] = \
- reshape (take (xyz [0], ravel (ns)), (no_cells, 4))
+ reshape (take (xyz [0], ravel (ns),axis=0), (no_cells, 4))
retval [:, 1] = \
- reshape (take (xyz [1], ravel (ns)), (no_cells, 4))
+ reshape (take (xyz [1], ravel (ns),axis=0), (no_cells, 4))
retval [:, 2] = \
- reshape (take (xyz [2], ravel (ns)), (no_cells, 4))
+ reshape (take (xyz [2], ravel (ns),axis=0), (no_cells, 4))
else :
raise _xyz3Error, "Funny number of cell faces: " + `shp [1]`
return retval
@@ -3211,11 +3211,11 @@
multiply.outer ( ones (n1, Float ), zz [i [2]: i[2] + n2]))
else :
# -- nonconsecutive values
- xyz [:, 0] = reshape (take (xx, ravel (add.outer (xchunk, ijk0))),
+ xyz [:, 0] = reshape (take (xx, ravel (add.outer (xchunk, ijk0)),axis=0),
(len (chunk), 2, 2, 2))
- xyz [:, 1] = reshape (take (yy, ravel (add.outer (ychunk, ijk1))),
+ xyz [:, 1] = reshape (take (yy, ravel (add.outer (ychunk, ijk1)),axis=0),
(len (chunk), 2, 2, 2))
- xyz [:, 2] = reshape (take (zz, ravel (add.outer (zchunk, ijk2))),
+ xyz [:, 2] = reshape (take (zz, ravel (add.outer (zchunk, ijk2)),axis=0),
(len (chunk), 2, 2, 2))
return xyz
Modified: trunk/Lib/sandbox/xplt/sphereisos.py
===================================================================
--- trunk/Lib/sandbox/xplt/sphereisos.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sandbox/xplt/sphereisos.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -29,7 +29,7 @@
n_zones = f.NumZones
# Put vertices in right order for Gist
## n_z = transpose (
-## take (transpose (n_z), array ( [0, 1, 3, 2, 4, 5, 7, 6])))
+## take (transpose (n_z), array ( [0, 1, 3, 2, 4, 5, 7, 6]),axis=0))
m1 = Mesh3d (x = x, y = y, z = z, c = c, avs = 1, hex = [n_zones, n_z])
Modified: trunk/Lib/signal/filter_design.py
===================================================================
--- trunk/Lib/signal/filter_design.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/signal/filter_design.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -22,7 +22,7 @@
if len(ep) == 0:
ep = atleast_1d(-1000)+0j
- ez = c_[numpy.compress(ep.imag >=0, ep), numpy.compress((abs(tz) < 1e5) & (tz.imag >=0),tz)]
+ ez = c_[numpy.compress(ep.imag >=0, ep,axis=-1), numpy.compress((abs(tz) < 1e5) & (tz.imag >=0),tz,axis=-1)]
integ = abs(ez) < 1e-10
hfreq = numpy.around(numpy.log10(numpy.max(3*abs(ez.real + integ)+1.5*ez.imag))+0.5)
@@ -967,7 +967,7 @@
mu = 1.0/N * numpy.log((1.0+numpy.sqrt(1+eps*eps)) / eps)
theta = pi/2.0 * (2*n-1.0)/N
p = -numpy.sinh(mu)*numpy.sin(theta) + 1j*numpy.cosh(mu)*numpy.cos(theta)
- k = numpy.prod(-p).real
+ k = numpy.prod(-p,axis=0).real
if N % 2 == 0:
k = k / sqrt((1+eps*eps))
return z, p, k
@@ -992,7 +992,7 @@
p = exp(1j*(pi*numpy.arange(1,2*N,2)/(2.0*N) + pi/2.0))
p = sinh(mu) * p.real + 1j*cosh(mu)*p.imag
p = 1.0 / p
- k = (numpy.prod(-p)/numpy.prod(-z)).real
+ k = (numpy.prod(-p,axis=0)/numpy.prod(-z,axis=0)).real
return z, p, k
@@ -1059,7 +1059,7 @@
jj = len(j)
[s,c,d,phi] = special.ellipj(j*capk/N,m*numpy.ones(jj))
- snew = numpy.compress(abs(s) > EPSILON, s)
+ snew = numpy.compress(abs(s) > EPSILON, s,axis=-1)
z = 1.0 / (sqrt(m)*snew)
z = 1j*z
z = numpy.concatenate((z,conjugate(z)))
@@ -1072,12 +1072,12 @@
p = -(c*d*sv*cv + 1j*s*dv) / (1-(d*sv)**2.0)
if N % 2:
- newp = numpy.compress(abs(p.imag) > EPSILON*numpy.sqrt(numpy.sum(p*numpy.conjugate(p)).real), p)
+ newp = numpy.compress(abs(p.imag) > EPSILON*numpy.sqrt(numpy.sum(p*numpy.conjugate(p),axis=0).real), p,axis=-1)
p = numpy.concatenate((p,conjugate(newp)))
else:
p = numpy.concatenate((p,conjugate(p)))
- k = (numpy.prod(-p) / numpy.prod(-z)).real
+ k = (numpy.prod(-p,axis=0) / numpy.prod(-z,axis=0)).real
if N % 2 == 0:
k = k / numpy.sqrt((1+eps*eps))
@@ -1539,4 +1539,4 @@
alpha = N//2
m = numpy.arange(0,N)
h = win*special.sinc(cutoff*(m-alpha))
- return h / sum(h)
+ return h / sum(h,axis=0)
Modified: trunk/Lib/signal/ltisys.py
===================================================================
--- trunk/Lib/signal/ltisys.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/signal/ltisys.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -141,9 +141,9 @@
den = poly(A)
- if (product(B.shape) == 0) and (product(C.shape) == 0):
+ if (product(B.shape,axis=0) == 0) and (product(C.shape,axis=0) == 0):
num = numpy.ravel(D)
- if (product(D.shape) == 0) and (product(A.shape) == 0):
+ if (product(D.shape,axis=0) == 0) and (product(A.shape,axis=0) == 0):
den = []
end
return num, den
Modified: trunk/Lib/signal/signaltools.py
===================================================================
--- trunk/Lib/signal/signaltools.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/signal/signaltools.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -68,7 +68,7 @@
kernel = asarray(in2)
if rank(volume) == rank(kernel) == 0:
return volume*kernel
- if (product(kernel.shape) > product(volume.shape)):
+ if (product(kernel.shape,axis=0) > product(volume.shape,axis=0)):
temp = kernel
kernel = volume
volume = temp
@@ -105,7 +105,7 @@
if mode == "full":
return ret
elif mode == "same":
- if product(s1) > product(s2):
+ if product(s1,axis=0) > product(s2,axis=0):
osize = s1
else:
osize = s2
@@ -144,7 +144,7 @@
kernel = asarray(in2)
if rank(volume) == rank(kernel) == 0:
return volume*kernel
- if (product(kernel.shape) > product(volume.shape)):
+ if (product(kernel.shape,axis=0) > product(volume.shape,axis=0)):
temp = kernel
kernel = volume
volume = temp
@@ -225,7 +225,7 @@
domain = ones(kernel_size)
- numels = product(kernel_size)
+ numels = product(kernel_size,axis=0)
order = int(numels/2)
return sigtools._order_filterND(volume,domain,order)
@@ -258,14 +258,14 @@
mysize = asarray(mysize);
# Estimate the local mean
- lMean = correlate(im,ones(mysize),1) / product(mysize)
+ lMean = correlate(im,ones(mysize),1) / product(mysize,axis=0)
# Estimate the local variance
- lVar = correlate(im**2,ones(mysize),1) / product(mysize) - lMean**2
+ lVar = correlate(im**2,ones(mysize),1) / product(mysize,axis=0) - lMean**2
# Estimate the noise power if needed.
if noise==None:
- noise = mean(ravel(lVar))
+ noise = mean(ravel(lVar),axis=0)
res = (im - lMean)
res *= (1-noise / lVar)
@@ -527,10 +527,10 @@
y = r_[y,zeros(N-L)]
for m in range(M):
- zi[m] = sum(b[m+1:]*x[:M-m])
+ zi[m] = sum(b[m+1:]*x[:M-m],axis=0)
for m in range(N):
- zi[m] -= sum(a[m+1:]*y[:N-m])
+ zi[m] -= sum(a[m+1:]*y[:N-m],axis=0)
return zi
@@ -808,7 +808,7 @@
k = m[newaxis,:]
AF = twoF*special.sinc(twoF*(n-k))
[lam,vec] = linalg.eig(AF)
- ind = argmax(abs(lam))
+ ind = argmax(abs(lam),axis=-1)
w = abs(vec[:,ind])
w = w / max(w)
@@ -1328,7 +1328,7 @@
rnk = len(dshape)
if axis < 0: axis = axis + rnk
newdims = r_[axis,0:axis,axis+1:rnk]
- newdata = reshape(transpose(data,tuple(newdims)),(N,prod(dshape)/N))
+ newdata = reshape(transpose(data,tuple(newdims)),(N,prod(dshape,axis=0)/N))
newdata = newdata.copy() # make sure we have a copy
if newdata.dtype.char not in 'dfDF':
newdata = newdata.astype(dtype)
Modified: trunk/Lib/signal/wavelets.py
===================================================================
--- trunk/Lib/signal/wavelets.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/signal/wavelets.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -130,7 +130,7 @@
# evaluation points x < 1 -- i.e. position is 0.xxxx
v = sb.real(v[:,ind])
# need scaling function to integrate to 1 so find
- # eigenvector normalized to sum(v)=1
+ # eigenvector normalized to sum(v,axis=0)=1
sm = sb.sum(v)
if sm < 0: # need scaling function to integrate to 1
v = -v
Modified: trunk/Lib/sparse/tests/test_sparse.py
===================================================================
--- trunk/Lib/sparse/tests/test_sparse.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/sparse/tests/test_sparse.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -39,7 +39,7 @@
assert_equal(self.datsp[2,1],2)
def check_sum(self):
- """Does the matrix's sum() method work?
+ """Does the matrix's sum(,axis=0) method work?
"""
assert_array_equal(self.dat.sum(), self.datsp.sum())
assert_array_equal(self.dat.sum(axis=None), self.datsp.sum(axis=None))
@@ -47,7 +47,7 @@
assert_array_equal(self.dat.sum(axis=1), self.datsp.sum(axis=1))
def check_mean(self):
- """Does the matrix's mean() method work?
+ """Does the matrix's mean(,axis=0) method work?
"""
assert_array_equal(self.dat.mean(), self.datsp.mean())
assert_array_equal(self.dat.mean(axis=None), self.datsp.mean(axis=None))
Modified: trunk/Lib/special/basic.py
===================================================================
--- trunk/Lib/special/basic.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/special/basic.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -412,7 +412,7 @@
n, x = asarray(n), asarray(x)
cond = (n==0)
fac2 = (-1.0)**(n+1) * gamma(n+1.0) * zeta(n+1,x)
- if sometrue(cond):
+ if sometrue(cond,axis=0):
return where(cond, psi(x), fac2)
return fac2
Modified: trunk/Lib/special/orthogonal.py
===================================================================
--- trunk/Lib/special/orthogonal.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/special/orthogonal.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -105,8 +105,8 @@
[x,v] = eig((diag(an)+diag(sqrt_bn,1)+diag(sqrt_bn,-1)))
answer = []
sortind = argsort(real(x))
- answer.append(take(x,sortind))
- answer.append(take(mu*v[0]**2,sortind))
+ answer.append(take(x,sortind,axis=0))
+ answer.append(take(mu*v[0]**2,sortind,axis=0))
return answer
# Jacobi Polynomials 1 P^(alpha,beta)_n(x)
Modified: trunk/Lib/special/tests/Test.py
===================================================================
--- trunk/Lib/special/tests/Test.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/special/tests/Test.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -89,7 +89,7 @@
for t in range(len(self.out_vars.keys())):
dev=abs(self.result[t]-self.out_vars[self.out_vars.keys()[t]])
ref=abs(self.result[t]+self.out_vars[self.out_vars.keys()[t]])/2
- mx_dev_idx=Numeric.argmax(dev)
+ mx_dev_idx=Numeric.argmax(dev,axis=-1)
if dev[mx_dev_idx] > 0.:
if ref[mx_dev_idx] > 0.:
self.max_rel_dev.append(dev[mx_dev_idx]/ref[mx_dev_idx])
Modified: trunk/Lib/special/tests/test_basic.py
===================================================================
--- trunk/Lib/special/tests/test_basic.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/special/tests/test_basic.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -2083,7 +2083,7 @@
def check_take(self):
a = array([0,1,2,3,4,5,6,7,8])
- tka = take(a,(0,4,5,8))
+ tka = take(a,(0,4,5,8),axis=0)
assert_array_equal(tka,array([0,4,5,8]))
class test_tandg(ScipyTestCase):
Modified: trunk/Lib/stats/_support.py
===================================================================
--- trunk/Lib/stats/_support.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stats/_support.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -50,7 +50,7 @@
else: # IT MUST BE A 2+D ARRAY
if inarray.typecode() != 'O': # not an Object array
for item in inarray[1:]:
- if not N.sum(N.alltrue(N.equal(uniques,item),1)):
+ if not N.sum(N.alltrue(N.equal(uniques,item),1),axis=0):
try:
uniques = N.concatenate( [uniques,item[N.newaxis,:]] )
except TypeError: # the item to add isn't a list
@@ -61,7 +61,7 @@
for item in inarray[1:]:
newflag = 1
for unq in uniques: # NOTE: cmp --> 0=same, -1=<, 1=>
- test = N.sum(abs(N.array(map(cmp,item,unq))))
+ test = N.sum(abs(N.array(map(cmp,item,unq))),axis=0)
if test == 0: # if item identical to any 1 row in uniques
newflag = 0 # then not a novel item to add
break
@@ -172,7 +172,7 @@
N of the mean are desired, set either or both parameters to 1.
Returns: unique 'conditions' specified by the contents of columns specified
- by keepcols, abutted with the mean(s) of column(s) specified by
+ by keepcols, abutted with the mean(s,axis=0) of column(s) specified by
collapsecols
"""
if cfcn is None:
Modified: trunk/Lib/stats/distributions.py
===================================================================
--- trunk/Lib/stats/distributions.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stats/distributions.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -211,7 +211,7 @@
def valarray(shape,value=nan,typecode=None):
"""Return an array of all value.
"""
- out = reshape(repeat([value],product(shape)),shape)
+ out = reshape(repeat([value],product(shape,axis=0),axis=0),shape)
if typecode is not None:
out = out.astype(typecode)
if not isinstance(out, ndarray):
@@ -261,7 +261,7 @@
- inverse survival function (inverse of sf)
generic.stats(<shape(s)>,loc=0,scale=1,moments='mv')
- - mean('m'), variance('v'), skew('s'), and/or kurtosis('k')
+ - mean('m',axis=0), variance('v'), skew('s'), and/or kurtosis('k')
generic.entropy(<shape(s)>,loc=0,scale=1)
- (differential) entropy of the RV.
@@ -428,7 +428,7 @@
if size is None:
size = 1
else:
- self._size = product(size)
+ self._size = product(size,axis=0)
if numpy.isscalar(size):
self._size = size
size = (size,)
@@ -720,10 +720,10 @@
return self._munp(n,*args)
def _nnlf(self, x, *args):
- return -sum(log(self._pdf(x, *args)))
+ return -sum(log(self._pdf(x, *args)),axis=0)
def nnlf(self, theta, x):
- # - sum (log pdf(x, theta))
+ # - sum (log pdf(x, theta),axis=0)
# where theta are the parameters (including loc and scale)
#
try:
@@ -1599,7 +1599,7 @@
return vals
def _munp(self, n, c):
k = arange(0,n+1)
- val = (-1.0/c)**n * sum(scipy.comb(n,k)*(-1)**k / (1.0-c*k))
+ val = (-1.0/c)**n * sum(scipy.comb(n,k)*(-1)**k / (1.0-c*k),axis=0)
return where(c*n < 1, val, inf)
def _entropy(self, c):
if (c > 0):
@@ -1657,7 +1657,7 @@
return 1.0/c*(1-(-log(q))**c)
def _munp(self, n, c):
k = arange(0,n+1)
- vals = 1.0/c**n * sum(scipy.comb(n,k) * (-1)**k * special.gamma(c*k + 1))
+ vals = 1.0/c**n * sum(scipy.comb(n,k) * (-1)**k * special.gamma(c*k + 1),axis=0)
return where(c*n > -1, vals, inf)
genextreme = genextreme_gen(name='genextreme',
longname="A generalized extreme value",
@@ -3173,28 +3173,28 @@
"""S = entropy(pk,qk=None)
calculate the entropy of a distribution given the p_k values
- S = -sum(pk * log(pk))
+ S = -sum(pk * log(pk),axis=0)
If qk is not None, then compute a relative entropy
- S = -sum(pk * log(pk / qk))
+ S = -sum(pk * log(pk / qk),axis=0)
Routine will normalize pk and qk if they don't sum to 1
"""
pk = arr(pk)
- pk = 1.0* pk / sum(pk)
+ pk = 1.0* pk / sum(pk,axis=0)
if qk is None:
vec = where(pk == 0, 0.0, pk*log(pk))
else:
qk = arr(qk)
if len(qk) != len(pk):
raise ValueError, "qk and pk must have same length."
- qk = 1.0*qk / sum(qk)
+ qk = 1.0*qk / sum(qk,axis=0)
# If qk is zero anywhere, then unless pk is zero at those places
# too, the relative entropy is infinite.
- if any(take(pk,nonzero(qk==0.0))!=0.0, 0):
+ if any(take(pk,nonzero(qk==0.0),axis=0)!=0.0, 0):
return inf
vec = where (pk == 0, 0.0, pk*log(pk / qk))
- return -sum(vec)
+ return -sum(vec,axis=0)
## Handlers for generic case where xk and pk are given
@@ -3208,11 +3208,11 @@
return 0.0
def _drv_cdf(self, xk, *args):
- indx = argmax((self.xk>xk))-1
+ indx = argmax((self.xk>xk),axis=-1)-1
return self.F[self.xk[indx]]
def _drv_ppf(self, q, *args):
- indx = argmax((self.qvals>=q))
+ indx = argmax((self.qvals>=q),axis=-1)
return self.Finv[self.qvals[indx]]
def _drv_nonzero(self, k, *args):
@@ -3320,7 +3320,7 @@
- inverse survival function (inverse of sf)
generic.stats(<shape(s)>,loc=0,moments='mv')
- - mean('m'), variance('v'), skew('s'), and/or kurtosis('k')
+ - mean('m',axis=0), variance('v'), skew('s'), and/or kurtosis('k')
generic.entropy(<shape(s)>,loc=0)
- entropy of the RV
@@ -3364,7 +3364,7 @@
self.a = self.xk[0]
self.b = self.xk[-1]
self.P = make_dict(self.xk, self.pk)
- self.qvals = numpy.cumsum(self.pk)
+ self.qvals = numpy.cumsum(self.pk,axis=0)
self.F = make_dict(self.xk, self.qvals)
self.Finv = reverse_dict(self.F)
self._ppf = new.instancemethod(sgf(_drv_ppf,otypes='d'),
@@ -3437,7 +3437,7 @@
def _cdfsingle(self, k, *args):
m = arange(int(self.a),k+1)
- return sum(self._pmf(m,*args))
+ return sum(self._pmf(m,*args),axis=0)
def _cdf(self, x, *args):
k = floor(x)
@@ -3469,7 +3469,7 @@
if size is None:
size = 1
else:
- self._size = product(size)
+ self._size = product(size,axis=0)
if numpy.isscalar(size):
self._size = size
size = (size,)
@@ -3818,7 +3818,7 @@
k = r_[0:n+1]
vals = self._pmf(k,n,pr)
lvals = where(vals==0,0.0,log(vals))
- return -sum(vals*lvals)
+ return -sum(vals*lvals,axis=0)
binom = binom_gen(name='binom',shapes="n,pr",extradoc="""
Binomial distribution
@@ -3969,7 +3969,7 @@
k = r_[N-(M-n):min(n,N)+1]
vals = self.pmf(k,M,n,N)
lvals = where(vals==0.0,0.0,log(vals))
- return -sum(vals*lvals)
+ return -sum(vals*lvals,axis=0)
hypergeom = hypergeom_gen(name='hypergeom',longname="A hypergeometric",
shapes="M,n,N", extradoc="""
Modified: trunk/Lib/stats/kde.py
===================================================================
--- trunk/Lib/stats/kde.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stats/kde.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -108,15 +108,15 @@
for i in range(self.n):
diff = self.dataset[:,i,newaxis] - points
tdiff = dot(self.inv_cov, diff)
- energy = sum(diff*tdiff)/2.0
+ energy = sum(diff*tdiff,axis=0)/2.0
result += exp(-energy)
else:
# loop over points
for i in range(m):
diff = self.dataset - points[:,i,newaxis]
tdiff = dot(self.inv_cov, diff)
- energy = sum(diff*tdiff)/2.0
- result[i] = sum(exp(-energy))
+ energy = sum(diff*tdiff,axis=0)/2.0
+ result[i] = sum(exp(-energy),axis=0)
det_cov = linalg.det(2*pi*self.covariance)
result /= sqrt(det_cov)*self.n
@@ -159,8 +159,8 @@
diff = self.dataset - mean
tdiff = dot(linalg.inv(sum_cov), diff)
- energies = sum(diff*tdiff)/2.0
- result = sum(exp(-energies))/sqrt(linalg.det(2*pi*sum_cov))/self.n
+ energies = sum(diff*tdiff,axis=0)/2.0
+ result = sum(exp(-energies),axis=0)/sqrt(linalg.det(2*pi*sum_cov))/self.n
return result
@@ -256,8 +256,8 @@
diff = large.dataset - mean
tdiff = dot(linalg.inv(sum_cov), diff)
- energies = sum(diff*tdiff)/2.0
- result += sum(exp(-energies))
+ energies = sum(diff*tdiff,axis=0)/2.0
+ result += sum(exp(-energies),axis=0)
result /= sqrt(linalg.det(2*pi*sum_cov))*large.n*small.n
Modified: trunk/Lib/stats/morestats.py
===================================================================
--- trunk/Lib/stats/morestats.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stats/morestats.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -39,7 +39,7 @@
### Bayesian confidence intervals for mean, variance, std
##########################################################
-## Assumes all is known is that mean, and std (variance) exist
+## Assumes all is known is that mean, and std (variance,axis=0) exist
## and are the same for all the data. Uses Jeffrey's prior
##
## Returns alpha confidence interval for the mean, variance,
@@ -142,7 +142,7 @@
data = ravel(data)
N = len(data)
for k in range(1,n+1):
- S[k] = sum(data**k)
+ S[k] = sum(data**k,axis=0)
if n==1:
return S[1]*1.0/N
elif n==2:
@@ -309,8 +309,8 @@
N = len(data)
y = boxcox(data,lmb)
my = stats.mean(y)
- f = (lmb-1)*sum(log(data))
- f -= N/2.0*log(sum((y-my)**2.0/N))
+ f = (lmb-1)*sum(log(data),axis=0)
+ f -= N/2.0*log(sum((y-my)**2.0/N,axis=0))
return f
def _boxcox_conf_interval(x, lmax, alpha):
@@ -497,8 +497,8 @@
a,b = ab
tmp = (xj-a)/b
tmp2 = exp(tmp)
- val = [sum(1.0/(1+tmp2))-0.5*N,
- sum(tmp*(1.0-tmp2)/(1+tmp2))+N]
+ val = [sum(1.0/(1+tmp2),axis=0)-0.5*N,
+ sum(tmp*(1.0-tmp2)/(1+tmp2),axis=0)+N]
return array(val)
sol0=array([xbar,stats.std(x)])
sol = optimize.fsolve(rootfunc,sol0,args=(x,N),xtol=1e-5)
@@ -510,17 +510,17 @@
def fixedsolve(th,xj,N):
val = stats.sum(xj)*1.0/N
tmp = exp(-xj/th)
- term = sum(xj*tmp)
- term /= sum(tmp)
+ term = sum(xj*tmp,axis=0)
+ term /= sum(tmp,axis=0)
return val - term
s = optimize.fixed_point(fixedsolve, 1.0, args=(x,N),xtol=1e-5)
- xbar = -s*log(sum(exp(-x/s))*1.0/N)
+ xbar = -s*log(sum(exp(-x/s),axis=0)*1.0/N)
w = (y-xbar)/s
z = distributions.gumbel_l.cdf(w)
sig = array([25,10,5,2.5,1])
critical = around(_Avals_gumbel / (1.0 + 0.2/sqrt(N)),3)
i = arange(1,N+1)
- S = sum((2*i-1.0)/N*(log(z)+log(1-z[::-1])))
+ S = sum((2*i-1.0)/N*(log(z)+log(1-z[::-1])),axis=0)
A2 = -N-S
return A2, critical, sig
@@ -575,7 +575,7 @@
xy = r_[x,y] # combine
rank = stats.rankdata(xy)
symrank = amin(array((rank,N-rank+1)),0)
- AB = sum(symrank[:n])
+ AB = sum(symrank[:n],axis=0)
uxy = unique(xy)
repeats = (len(uxy) != len(xy))
exact = ((m<55) and (n<55) and not repeats)
@@ -584,19 +584,19 @@
if exact:
astart, a1, ifault = statlib.gscale(n,m)
ind = AB-astart
- total = sum(a1)
+ total = sum(a1,axis=0)
if ind < len(a1)/2.0:
cind = int(ceil(ind))
if (ind == cind):
- pval = 2.0*sum(a1[:cind+1])/total
+ pval = 2.0*sum(a1[:cind+1],axis=0)/total
else:
- pval = 2.0*sum(a1[:cind])/total
+ pval = 2.0*sum(a1[:cind],axis=0)/total
else:
find = int(floor(ind))
if (ind == floor(ind)):
- pval = 2.0*sum(a1[find:])/total
+ pval = 2.0*sum(a1[find:],axis=0)/total
else:
- pval = 2.0*sum(a1[find+1:])/total
+ pval = 2.0*sum(a1[find+1:],axis=0)/total
return AB, min(1.0,pval)
# otherwise compute normal approximation
@@ -607,8 +607,8 @@
mnAB = n*(N+2.0)/4.0
varAB = m*n*(N+2)*(N-2.0)/48/(N-1.0)
if repeats: # adjust variance estimates
- # compute sum(tj * rj**2)
- fac = sum(symrank**2)
+ # compute sum(tj * rj**2,axis=0)
+ fac = sum(symrank**2,axis=0)
if N % 2: # N odd
varAB = m*n*(16*N*fac-(N+1)**4)/(16.0 * N**2 * (N-1))
else: # N even
@@ -648,10 +648,10 @@
for j in range(k):
Ni[j] = len(args[j])
ssq[j] = stats.var(args[j])
- Ntot = sum(Ni)
- spsq = sum((Ni-1)*ssq)/(1.0*(Ntot-k))
- numer = (Ntot*1.0-k)*log(spsq) - sum((Ni-1.0)*log(ssq))
- denom = 1.0 + (1.0/(3*(k-1)))*((sum(1.0/(Ni-1.0)))-1.0/(Ntot-k))
+ Ntot = sum(Ni,axis=0)
+ spsq = sum((Ni-1)*ssq,axis=0)/(1.0*(Ntot-k))
+ numer = (Ntot*1.0-k)*log(spsq) - sum((Ni-1.0)*log(ssq),axis=0)
+ denom = 1.0 + (1.0/(3*(k-1)))*((sum(1.0/(Ni-1.0),axis=0))-1.0/(Ntot-k))
T = numer / denom
pval = distributions.chi2.sf(T,k-1) # 1 - cdf
return T, pval
@@ -707,7 +707,7 @@
for j in range(k):
Ni[j] = len(args[j])
Yci[j] = func(args[j])
- Ntot = sum(Ni)
+ Ntot = sum(Ni,axis=0)
# compute Zij's
Zij = [None]*k
@@ -721,12 +721,12 @@
Zbar += Zbari[i]*Ni[i]
Zbar /= Ntot
- numer = (Ntot-k)*sum(Ni*(Zbari-Zbar)**2)
+ numer = (Ntot-k)*sum(Ni*(Zbari-Zbar)**2,axis=0)
# compute denom_variance
dvar = 0.0
for i in range(k):
- dvar += sum((Zij[i]-Zbari[i])**2)
+ dvar += sum((Zij[i]-Zbari[i])**2,axis=0)
denom = (k-1.0)*dvar
@@ -767,11 +767,11 @@
rerr = 1+1e-7
if (x < p*n):
i = arange(x+1,n+1)
- y = sum(distributions.binom.pmf(i,n,p) <= d*rerr)
+ y = sum(distributions.binom.pmf(i,n,p) <= d*rerr,axis=0)
pval = distributions.binom.cdf(x,n,p) + distributions.binom.sf(n-y,n,p)
else:
i = arange(0,x)
- y = sum(distributions.binom.pmf(i,n,p) <= d*rerr)
+ y = sum(distributions.binom.pmf(i,n,p) <= d*rerr,axis=0)
pval = distributions.binom.cdf(y-1,n,p) + distributions.binom.sf(x-1,n,p)
return min(1.0,pval)
@@ -828,7 +828,7 @@
Ni = asarray([len(args[j]) for j in range(k)])
Yci = asarray([func(args[j]) for j in range(k)])
- Ntot = sum(Ni)
+ Ntot = sum(Ni,axis=0)
# compute Zij's
Zij = [abs(asarray(args[i])-Yci[i]) for i in range(k)]
allZij = []
@@ -844,7 +844,7 @@
anbar = stats.mean(a)
varsq = stats.var(a)
- Xsq = sum(Ni*(asarray(Aibar)-anbar)**2.0)/varsq
+ Xsq = sum(Ni*(asarray(Aibar)-anbar)**2.0,axis=0)/varsq
pval = distributions.chi2.sf(Xsq,k-1) # 1 - cdf
return Xsq, pval
@@ -869,7 +869,7 @@
raise ValueError, "Not enough observations."
ranks = stats.rankdata(xy)
Ri = ranks[:n]
- M = sum((Ri - (N+1.0)/2)**2)
+ M = sum((Ri - (N+1.0)/2)**2,axis=0)
# Approx stat.
mnM = n*(N*N-1.0)/12
varM = m*n*(N+1.0)*(N+2)*(N-2)/180
@@ -903,16 +903,16 @@
Mi = array([stats.mean(args[i]) for i in range(k)])
Vi = array([stats.var(args[i]) for i in range(k)])
Wi = Ni / Vi
- swi = sum(Wi)
- N = sum(Ni)
- my = sum(Mi*Ni)*1.0/N
- tmp = sum((1-Wi/swi)**2 / (Ni-1.0))/(k*k-1.0)
+ swi = sum(Wi,axis=0)
+ N = sum(Ni,axis=0)
+ my = sum(Mi*Ni,axis=0)*1.0/N
+ tmp = sum((1-Wi/swi)**2 / (Ni-1.0),axis=0)/(k*k-1.0)
if evar:
- F = ((sum(Ni*(Mi-my)**2) / (k-1.0)) / (sum((Ni-1.0)*Vi) / (N-k)))
+ F = ((sum(Ni*(Mi-my)**2,axis=0) / (k-1.0)) / (sum((Ni-1.0)*Vi,axis=0) / (N-k)))
pval = distributions.f.sf(F,k-1,N-k) # 1-cdf
else:
- m = sum(Wi*Mi)*1.0/swi
- F = sum(Wi*(Mi-m)**2) / ((k-1.0)*(1+2*(k-2)*tmp))
+ m = sum(Wi*Mi,axis=0)*1.0/swi
+ F = sum(Wi*(Mi-m)**2,axis=0) / ((k-1.0)*(1+2*(k-2)*tmp))
pval = distributions.f.sf(F,k-1.0,1.0/(3*tmp))
return F, pval
@@ -932,13 +932,13 @@
if len(x) <> len(y):
raise ValueError, 'Unequal N in wilcoxon. Aborting.'
d = x-y
- d = compress(not_equal(d,0),d) # Keep all non-zero differences
+ d = compress(not_equal(d,0),d,axis=-1) # Keep all non-zero differences
count = len(d)
if (count < 10):
print "Warning: sample size too small for normal approximation."
r = stats.rankdata(abs(d))
- r_plus = sum((d > 0)*r)
- r_minus = sum((d < 0)*r)
+ r_plus = sum((d > 0)*r,axis=0)
+ r_minus = sum((d < 0)*r,axis=0)
T = min(r_plus, r_minus)
mn = count*(count+1.0)*0.25
se = math.sqrt(count*(count+1)*(2*count+1.0)/24)
Modified: trunk/Lib/stats/stats.py
===================================================================
--- trunk/Lib/stats/stats.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stats/stats.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -284,7 +284,7 @@
def _nanmedian(arr1d): # This only works on 1d arrays
cond = 1-isnan(arr1d)
- x = sort(compress(cond,arr1d))
+ x = sort(compress(cond,arr1d,axis=-1))
return median(x)
def nanmedian(x, axis=0):
@@ -340,7 +340,7 @@
return size / np.sum(1.0/a, axis)
def mean(a, axis=0):
- # fixme: This seems to be redundant with numpy.mean() or even
+ # fixme: This seems to be redundant with numpy.mean(,axis=0) or even
# the ndarray.mean() method.
"""Returns the arithmetic mean of m along the given dimension.
@@ -945,7 +945,7 @@
Returns: percentile-position of score (0-100) relative to a
"""
h, lrl, binsize, extras = histogram(a,histbins,defaultlimits)
- cumhist = cumsum(h*1)
+ cumhist = cumsum(h*1,axis=0)
i = int((score - lrl)/float(binsize))
pct = (cumhist[i-1]+((score-(lrl+binsize*i))/float(binsize))*h[i])/float(len(a)) * 100
return pct
@@ -1031,7 +1031,7 @@
Returns: array of cumfreq bin values, lowerreallimit, binsize, extrapoints
"""
h,l,b,e = histogram(a,numbins,defaultreallimits)
- cumhist = cumsum(h*1)
+ cumhist = cumsum(h*1,axis=0)
return cumhist,l,b,e
@@ -1267,7 +1267,7 @@
upper tails.
"""
newa = trimboth(sort(a),proportiontocut)
- return mean(newa)
+ return mean(newa,axis=0)
@@ -1734,7 +1734,7 @@
f_obs = asarray(f_obs)
k = len(f_obs)
if f_exp is None:
- f_exp = array([sum(f_obs)/float(k)] * len(f_obs),Float)
+ f_exp = array([sum(f_obs,axis=0)/float(k)] * len(f_obs),Float)
f_exp = f_exp.astype(Float)
chisq = add.reduce((f_obs-f_exp)**2 / f_exp)
return chisq, chisqprob(chisq, k-1)
@@ -1797,7 +1797,7 @@
ranked = rankdata(concatenate((x,y)))
rankx = ranked[0:n1] # get the x-ranks
#ranky = ranked[n1:] # the rest are y-ranks
- u1 = n1*n2 + (n1*(n1+1))/2.0 - sum(rankx) # calc U for x
+ u1 = n1*n2 + (n1*(n1+1))/2.0 - sum(rankx,axis=0) # calc U for x
u2 = n1*n2 - u1 # remainder is U for y
bigu = max(u1,u2)
smallu = min(u1,u2)
@@ -1848,7 +1848,7 @@
ranked = rankdata(alldata)
x = ranked[:n1]
y = ranked[n1:]
- s = sum(x)
+ s = sum(x,axis=0)
expected = n1*(n1+n2+1) / 2.0
z = (s - expected) / math.sqrt(n1*n2*(n1+n2+1)/12.0)
prob = 2*(1.0 -zprob(abs(z)))
@@ -1878,10 +1878,10 @@
del ranked[0:n[i]]
rsums = []
for i in range(len(args)):
- rsums.append(sum(args[i])**2)
+ rsums.append(sum(args[i],axis=0)**2)
rsums[i] = rsums[i] / float(n[i])
- ssbn = sum(rsums)
- totaln = sum(n)
+ ssbn = sum(rsums,axis=0)
+ totaln = sum(n,axis=0)
h = 12.0 / (totaln*(totaln+1)) * ssbn - 3*(totaln+1)
df = len(args) - 1
if T == 0:
@@ -1909,7 +1909,7 @@
data = data.astype(Float)
for i in range(len(data)):
data[i] = rankdata(data[i])
- ssbn = sum(sum(args,1)**2)
+ ssbn = sum(sum(args,1)**2,axis=0)
chisq = 12.0 / (k*n*(k+1)) * ssbn - 3*n*(k+1)
return chisq, chisqprob(chisq,k-1)
@@ -1998,7 +1998,7 @@
if len(p) == 2: # ttest_ind
c = array([1,-1])
df = n-2
- fact = sum(1.0/sum(x,0)) # i.e., 1/n1 + 1/n2 + 1/n3 ...
+ fact = sum(1.0/sum(x,0),axis=0) # i.e., 1/n1 + 1/n2 + 1/n3 ...
t = dot(c,b) / sqrt(s_sq*fact)
probs = betai(0.5*df,0.5,float(df)/(df+t*t))
return t, probs
Modified: trunk/Lib/stats/tests/test_stats.py
===================================================================
--- trunk/Lib/stats/tests/test_stats.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stats/tests/test_stats.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -725,7 +725,7 @@
def check_signaltonoise(self):
"""
this is not in R, so used
- mean(testcase)/(sqrt(var(testcase)*3/4)) """
+ mean(testcase,axis=0)/(sqrt(var(testcase)*3/4)) """
#y = scipy.stats.signaltonoise(self.shoes[0])
#assert_approx_equal(y,4.5709967)
y = scipy.stats.signaltonoise(self.testcase)
@@ -753,7 +753,7 @@
def check_z(self):
"""
not in R, so used
- (10-mean(testcase))/sqrt(var(testcase)*3/4)
+ (10-mean(testcase,axis=0))/sqrt(var(testcase)*3/4)
"""
y = scipy.stats.z(self.testcase,scipy.stats.mean(self.testcase))
assert_almost_equal(y,0.0)
@@ -761,7 +761,7 @@
def check_zs(self):
"""
not in R, so tested by using
- (testcase[i]-mean(testcase))/sqrt(var(testcase)*3/4)
+ (testcase[i]-mean(testcase,axis=0))/sqrt(var(testcase)*3/4)
"""
y = scipy.stats.zs(self.testcase)
desired = ([-1.3416407864999, -0.44721359549996 , 0.44721359549996 , 1.3416407864999])
@@ -783,7 +783,7 @@
testmathworks = [1.165 , 0.6268, 0.0751, 0.3516, -0.6965]
def check_moment(self):
"""
- mean((testcase-mean(testcase))**power))"""
+ mean((testcase-mean(testcase))**power,axis=0),axis=0))**power))"""
y = scipy.stats.moment(self.testcase,1)
assert_approx_equal(y,0.0,10)
y = scipy.stats.moment(self.testcase,2)
@@ -802,7 +802,7 @@
def check_skewness(self):
"""
- sum((testmathworks-mean(testmathworks))**3)/((sqrt(var(testmathworks)*4/5))**3)/5
+ sum((testmathworks-mean(testmathworks,axis=0))**3,axis=0)/((sqrt(var(testmathworks)*4/5))**3)/5
"""
y = scipy.stats.skew(self.testmathworks)
assert_approx_equal(y,-0.29322304336607,10)
@@ -812,8 +812,8 @@
assert_approx_equal(y,0.0,10)
def check_kurtosis(self):
"""
- sum((testcase-mean(testcase))**4)/((sqrt(var(testcase)*3/4))**4)/4
- sum((test2-mean(testmathworks))**4)/((sqrt(var(testmathworks)*4/5))**4)/5
+ sum((testcase-mean(testcase,axis=0))**4,axis=0)/((sqrt(var(testcase)*3/4))**4)/4
+ sum((test2-mean(testmathworks,axis=0))**4,axis=0)/((sqrt(var(testmathworks)*4/5))**4)/5
Set flags for axis = 0 and
fisher=0 (Pearson's defn of kurtosis for compatiability with Matlab)
"""
Modified: trunk/Lib/stsci/convolve/lib/Convolve.py
===================================================================
--- trunk/Lib/stsci/convolve/lib/Convolve.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stsci/convolve/lib/Convolve.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -374,7 +374,7 @@
def _fbroadcast(f, N, shape, args, params=()):
"""_fbroadcast(f, N, args, shape, params=()) calls 'f' for each of the
'N'-dimensional inner subnumarray of 'args'. Each subarray has
- .shape == 'shape'[-N:]. There are a total of product(shape[:-N])
+ .shape == 'shape'[-N:]. There are a total of product(shape[:-N],axis=0)
calls to 'f'.
"""
if len(shape) == N:
Modified: trunk/Lib/stsci/image/lib/combine.py
===================================================================
--- trunk/Lib/stsci/image/lib/combine.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/stsci/image/lib/combine.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -71,7 +71,7 @@
return _combine_f("median", arrays, output, outtype, nlow, nhigh, badmasks)
def average( arrays, output=None, outtype=None, nlow=0, nhigh=0, badmasks=None):
- """average() nominally computes the average pixel value for a stack of
+ """average(,axis=0) nominally computes the average pixel value for a stack of
identically shaped images.
arrays specifies a sequence of inputs arrays, which are nominally a
@@ -97,7 +97,7 @@
>>> a = num.arange(4)
>>> a = a.reshape((2,2))
>>> arrays = [a*16, a*4, a*2, a*8]
- >>> average(arrays)
+ >>> average(arrays,axis=0)
array([[ 0, 7],
[15, 22]])
>>> average(arrays, nhigh=1)
Modified: trunk/Lib/tests/test_basic.py
===================================================================
--- trunk/Lib/tests/test_basic.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/tests/test_basic.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -269,7 +269,7 @@
class test_ptp(unittest.TestCase):
def check_basic(self):
a = [3,4,5,10,-3,-5,6.0]
- assert_equal(ptp(a),15.0)
+ assert_equal(ptp(a,axis=0),15.0)
b = [[3,6.0, 9.0],
[4,10.0,5.0],
[8,3.0,2.0]]
@@ -284,8 +284,8 @@
for ctype in ['1','b','s','i','l','f','d','F','D']:
a = array(ba,ctype)
a2 = array(ba2,ctype)
- assert_array_equal(cumsum(a), array([1,3,13,24,30,35,39],ctype))
- assert_array_equal(cumsum(a2),
+ assert_array_equal(cumsum(a,axis=0), array([1,3,13,24,30,35,39],ctype))
+ assert_array_equal(cumsum(a2,axis=0),
array([[1,2,3,4],[6,8,10,13],
[16,11,14,18]],ctype))
assert_array_equal(cumsum(a2,axis=1),
@@ -305,8 +305,8 @@
self.failUnlessRaises(ArithmeticError, prod, a2, 1)
self.failUnlessRaises(ArithmeticError, prod, a)
else:
- assert_equal(prod(a),26400)
- assert_array_equal(prod(a2), array([50,36,84,180],ctype))
+ assert_equal(prod(a,axis=0),26400)
+ assert_array_equal(prod(a2,axis=0), array([50,36,84,180],ctype))
assert_array_equal(prod(a2,axis=1),
array([24, 1890, 600],ctype))
@@ -322,10 +322,10 @@
self.failUnlessRaises(ArithmeticError, cumprod, a2, 1)
self.failUnlessRaises(ArithmeticError, cumprod, a)
else:
- assert_array_equal(cumprod(a),
+ assert_array_equal(cumprod(a,axis=0),
array([1, 2, 20, 220,
1320, 6600, 26400],ctype))
- assert_array_equal(cumprod(a2),
+ assert_array_equal(cumprod(a2,axis=0),
array([[ 1, 2, 3, 4],
[ 5, 12, 21, 36],
[50, 36, 84, 180]],ctype))
Modified: trunk/Lib/tests/test_basic1a.py
===================================================================
--- trunk/Lib/tests/test_basic1a.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/tests/test_basic1a.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -27,7 +27,7 @@
class test_factorial(unittest.TestCase):
def check_basic(self):
for k in range(0,13):
- assert_equal(factorial(k),product(grid[1:k+1]))
+ assert_equal(factorial(k),product(grid[1:k+1],axis=0))
self.failUnlessRaises(ValueError, factorial, -10)
def check_exact(self):
@@ -41,7 +41,7 @@
def check_basic(self):
for N in range(0,11):
for k in range(0,N+1):
- ans = product(grid[N-k+1:N+1]) / product(grid[1:k+1])
+ ans = product(grid[N-k+1:N+1],axis=0) / product(grid[1:k+1],axis=0)
assert_almost_equal(comb(N,k),ans,9)
self.failUnlessRaises(ValueError, comb, -10,1)
self.failUnlessRaises(ValueError, comb, 10,-1)
Modified: trunk/Lib/tests/test_common.py
===================================================================
--- trunk/Lib/tests/test_common.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/tests/test_common.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -49,7 +49,7 @@
class test_factorial(unittest.TestCase):
def check_basic(self):
for k in range(0,13):
- assert_equal(factorial(k),product(mgrid[1:k+1]))
+ assert_equal(factorial(k),product(mgrid[1:k+1],axis=0))
assert_equal(factorial(-10),0)
def check_exact(self):
@@ -63,7 +63,7 @@
def check_basic(self):
for N in range(0,11):
for k in range(0,N+1):
- ans = product(mgrid[N-k+1:N+1]) / product(mgrid[1:k+1])
+ ans = product(mgrid[N-k+1:N+1],axis=0) / product(mgrid[1:k+1],axis=0)
assert_almost_equal(comb(N,k),ans,9)
assert_equal(comb(-10,1),0)
assert_equal(comb(10,-1),0)
Modified: trunk/Lib/weave/size_check.py
===================================================================
--- trunk/Lib/weave/size_check.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/weave/size_check.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -127,7 +127,7 @@
return 0
if len(self.shape) == len(other.shape) == 0:
return 0
- return not alltrue(equal(self.shape,other.shape))
+ return not alltrue(equal(self.shape,other.shape),axis=0)
def __add__(self,other): return self.binary_op(other)
def __radd__(self,other): return self.binary_op(other)
Modified: trunk/Lib/weave/tests/test_blitz_tools.py
===================================================================
--- trunk/Lib/weave/tests/test_blitz_tools.py 2006-08-29 07:22:11 UTC (rev 2182)
+++ trunk/Lib/weave/tests/test_blitz_tools.py 2006-08-29 10:30:44 UTC (rev 2183)
@@ -90,7 +90,7 @@
print diff[:4,-4:]
print diff[-4:,:4]
print diff[-4:,-4:]
- print sum(abs(diff.ravel()))
+ print sum(abs(diff.ravel()),axis=0)
raise AssertionError
return standard,compiled
More information about the Scipy-svn
mailing list