[Scipy-svn] r2149 - in trunk/Lib: fftpack fftpack/tests ndimage ndimage/tests sandbox/xplt stats stats/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Aug 5 02:28:01 CDT 2006


Author: oliphant
Date: 2006-08-05 02:27:52 -0500 (Sat, 05 Aug 2006)
New Revision: 2149

Modified:
   trunk/Lib/fftpack/helper.py
   trunk/Lib/fftpack/tests/test_basic.py
   trunk/Lib/ndimage/filters.py
   trunk/Lib/ndimage/measurements.py
   trunk/Lib/ndimage/morphology.py
   trunk/Lib/ndimage/tests/test_ndimage.py
   trunk/Lib/sandbox/xplt/shapetest.py
   trunk/Lib/stats/distributions.py
   trunk/Lib/stats/tests/test_distributions.py
Log:
Updates to work with NumPy 1.0b2

Modified: trunk/Lib/fftpack/helper.py
===================================================================
--- trunk/Lib/fftpack/helper.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/fftpack/helper.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -1,7 +1,7 @@
 __all__ = ['fftshift', 'ifftshift', 'fftfreq', 'rfftfreq']
 
 from numpy import array
-from numpy.dft.helper import fftshift, ifftshift, fftfreq
+from numpy.fft.helper import fftshift, ifftshift, fftfreq
 
 def rfftfreq(n,d=1.0):
     """ rfftfreq(n, d=1.0) -> f

Modified: trunk/Lib/fftpack/tests/test_basic.py
===================================================================
--- trunk/Lib/fftpack/tests/test_basic.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/fftpack/tests/test_basic.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -19,7 +19,7 @@
 
 from numpy import arange, add, array, asarray, zeros, dot, exp, pi,\
      swapaxes, double, cdouble
-import numpy.dft
+import numpy.fft
 
 from numpy.random import rand
 def random(size):
@@ -121,13 +121,13 @@
             n = 2**i
             x = range(n)
             y = fftpack.zfft(x)
-            y2 = numpy.dft.fft(x)
+            y2 = numpy.fft.fft(x)
             assert_array_almost_equal(y,y2)
             y = fftpack.zrfft(x)
             assert_array_almost_equal(y,y2)
 
     def bench_random(self,level=5):
-        from numpy.dft import fft as numpy_fft
+        from numpy.fft import fft as numpy_fft
         print
         print '                 Fast Fourier Transform'
         print '================================================='
@@ -183,7 +183,7 @@
             n = 2**i
             x = range(n)
             y = fftpack.zfft(x,direction=-1)
-            y2 = numpy.dft.ifft(x)
+            y2 = numpy.fft.ifft(x)
             assert_array_almost_equal(y,y2)
             y = fftpack.zrfft(x,direction=-1)
             assert_array_almost_equal(y,y2)
@@ -202,7 +202,7 @@
             assert_array_almost_equal (fft(ifft(x)),x)
 
     def bench_random(self,level=5):
-        from numpy.dft import ifft as numpy_ifft
+        from numpy.fft import ifft as numpy_ifft
         print
         print '       Inverse Fast Fourier Transform'
         print '==============================================='
@@ -250,7 +250,7 @@
         assert_array_almost_equal(y,y1)
 
     def check_djbfft(self):
-        from numpy.dft import fft as numpy_fft
+        from numpy.fft import fft as numpy_fft
         for i in range(2,14):
             n = 2**i
             x = range(n)
@@ -265,7 +265,7 @@
             assert_array_almost_equal(y,y1)
 
     def bench_random(self,level=5):
-        from numpy.dft import rfft as numpy_rfft
+        from numpy.fft import rfft as numpy_rfft
         print
         print 'Fast Fourier Transform (real data)'
         print '=================================='
@@ -309,7 +309,7 @@
         assert_array_almost_equal(y,ifft(x1))
 
     def check_djbfft(self):
-        from numpy.dft import ifft as numpy_ifft
+        from numpy.fft import ifft as numpy_ifft
         for i in range(2,14):
             n = 2**i
             x = range(n)
@@ -330,7 +330,7 @@
             assert_array_almost_equal (rfft(irfft(x)),x)
 
     def bench_random(self,level=5):
-        from numpy.dft import irfft as numpy_irfft
+        from numpy.fft import irfft as numpy_irfft
 
         print
         print 'Inverse Fast Fourier Transform (real data)'
@@ -496,7 +496,7 @@
             fftn(swapaxes(large_x1,-1,-2)),-1,-2))
 
     def bench_random(self,level=5):
-        from numpy.dft import fftn as numpy_fftn
+        from numpy.fft import fftn as numpy_fftn
         print
         print '    Multi-dimensional Fast Fourier Transform'
         print '==================================================='

Modified: trunk/Lib/ndimage/filters.py
===================================================================
--- trunk/Lib/ndimage/filters.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/ndimage/filters.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -429,7 +429,7 @@
             separable= True
         else:
             footprint = numarray.asarray(footprint)
-            footprint = footprint.astype(numarray.Bool)
+            footprint = footprint.astype(bool)
             if numarray.alltrue(numarray.ravel(footprint)):
                 size = footprint.shape
                 footprint = None
@@ -440,10 +440,10 @@
         structure = numarray.asarray(structure, dtype = numarray.Float64)
         separable = False
         if footprint is None:
-            footprint = numarray.ones(structure.shape, numarray.Bool)
+            footprint = numarray.ones(structure.shape, bool)
         else:
             footprint = numarray.asarray(footprint)
-            footprint = footprint.astype(numarray.Bool)
+            footprint = footprint.astype(bool)
     input = numarray.asarray(input)
     if numarray.iscomplexobj(input):
         raise TypeError, 'Complex type not supported'
@@ -520,9 +520,9 @@
         if size == None:
             raise RuntimeError, "no footprint or filter size provided"
         sizes = _ni_support._normalize_sequence(size, input.ndim)
-        footprint = numarray.ones(sizes, dtype = numarray.Bool)
+        footprint = numarray.ones(sizes, dtype = bool)
     else:
-        footprint = numarray.asarray(footprint, dtype = numarray.Bool)
+        footprint = numarray.asarray(footprint, dtype = bool)
     fshape = [ii for ii in footprint.shape if ii > 0]
     if len(fshape) != input.ndim:
         raise RuntimeError, 'filter footprint array has incorrect shape.'
@@ -656,10 +656,10 @@
         if size == None:
             raise RuntimeError, "no footprint or filter size provided"
         sizes = _ni_support._normalize_sequence(size, input.ndim)
-        footprint = numarray.ones(size, dtype = numarray.Bool)
+        footprint = numarray.ones(size, dtype = bool)
     else:
         footprint = numarray.asarray(footprint)
-        footprint = footprint.astype(numarray.Bool)
+        footprint = footprint.astype(bool)
     fshape = [ii for ii in footprint.shape if ii > 0]
     if len(fshape) != input.ndim:
         raise RuntimeError, 'filter footprint array has incorrect shape.'

Modified: trunk/Lib/ndimage/measurements.py
===================================================================
--- trunk/Lib/ndimage/measurements.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/ndimage/measurements.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -31,6 +31,7 @@
 import types
 import math
 import numpy.oldnumeric as numarray
+import numpy
 import _ni_support
 import _nd_image
 import morphology
@@ -50,7 +51,7 @@
         raise TypeError, 'Complex type not supported'
     if structure == None:
         structure = morphology.generate_binary_structure(input.ndim, 1)
-    structure = numarray.asarray(structure, dtype = numarray.Bool)
+    structure = numarray.asarray(structure, dtype = bool)
     if structure.ndim != input.ndim:
         raise RuntimeError, 'structure and input must have equal rank'
     for ii in structure.shape:
@@ -58,7 +59,7 @@
             raise  RuntimeError, 'structure dimensions must be equal to 3'
     if not structure.flags.contiguous:
         structure = structure.copy()
-    if isinstance(output, numarray.ndarray):
+    if isinstance(output, numpy.ndarray):
         if output.dtype.type != numarray.int32:
             raise RuntimeError, 'output type must be Int32'
     else:
@@ -344,7 +345,7 @@
         raise TypeError, 'only 8 and 16 unsigned inputs are supported'
     if structure == None:
         structure = morphology.generate_binary_structure(input.ndim, 1)
-    structure = numarray.asarray(structure, dtype = numarray.Bool)
+    structure = numarray.asarray(structure, dtype = bool)
     if structure.ndim != input.ndim:
         raise RuntimeError, 'structure and input must have equal rank'
     for ii in structure.shape:
@@ -356,18 +357,18 @@
     if input.shape != markers.shape:
         raise RuntimeError, 'input and markers must have equal shape'
 
-    integral_types = [numarray.int0,
-                      numarray.int8,
-                      numarray.int16,
-                      numarray.int32,
-                      numarray.int_,
-                      numarray.int64,
-                      numarray.intc,
-                      numarray.intp]
+    integral_types = [numpy.int0,
+                      numpy.int8,
+                      numpy.int16,
+                      numpy.int32,
+                      numpy.int_,
+                      numpy.int64,
+                      numpy.intc,
+                      numpy.intp]
 
     if markers.dtype.type not in integral_types:
         raise RuntimeError, 'marker should be of integer type'
-    if isinstance(output, numarray.ndarray):
+    if isinstance(output, numpy.ndarray):
         if output.dtype.type not in integral_types:
             raise RuntimeError, 'output should be of integer type'
     else:

Modified: trunk/Lib/ndimage/morphology.py
===================================================================
--- trunk/Lib/ndimage/morphology.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/ndimage/morphology.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -29,6 +29,7 @@
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import numpy.oldnumeric as numarray
+import numpy
 import _ni_support
 import _nd_image
 import filters
@@ -56,7 +57,7 @@
     pos = [ni * (structure.shape[ii] / 2) for ii in range(len(shape))]
     slc = [slice(pos[ii], pos[ii] + structure.shape[ii], None)
            for ii in range(len(shape))]
-    out = numarray.zeros(shape, numarray.Bool)
+    out = numarray.zeros(shape, bool)
     out[slc] = structure != 0
     out = binary_dilation(out, structure, iterations = ni)
     if origin is None:
@@ -76,13 +77,13 @@
         connectivity = 1
     if rank < 1:
         if connectivity < 1:
-            return numarray.array(0, dtype = numarray.Bool)
+            return numarray.array(0, dtype = bool)
         else:
-            return numarray.array(1, dtype = numarray.Bool)
-    output = numarray.zeros([3] * rank, numarray.Bool)
+            return numarray.array(1, dtype = bool)
+    output = numarray.zeros([3] * rank, bool)
     output = numarray.fabs(numarray.indices([3] * rank) - 1)
     output = numarray.add.reduce(output, 0)
-    return numarray.asarray(output <= connectivity, dtype = numarray.Bool)
+    return numarray.asarray(output <= connectivity, dtype = bool)
 
 
 def _binary_erosion(input, structure, iterations, mask, output,
@@ -94,7 +95,7 @@
         structure = generate_binary_structure(input.ndim, 1)
     else:
         structure = numarray.asarray(structure)
-        structure = structure.astype(numarray.Bool)
+        structure = structure.astype(bool)
     if structure.ndim != input.ndim:
         raise RuntimeError, 'structure rank must equal input rank'
     if not structure.flags.contiguous:
@@ -107,11 +108,11 @@
             raise RuntimeError, 'mask and input must have equal sizes'
     origin = _ni_support._normalize_sequence(origin, input.ndim)
     cit = _center_is_true(structure, origin)
-    if isinstance(output, numarray.ndarray):
+    if isinstance(output, numpy.ndarray):
         if numarray.iscomplexobj(output):
             raise TypeError, 'Complex output type not supported'
     else:
-        output = numarray.Bool
+        output = bool
     output, return_value = _ni_support._get_output(output, input)
 
 
@@ -140,11 +141,11 @@
                                   origin, invert, coordinate_list)
         return return_value
     else:
-        tmp_in = numarray.zeros(input.shape, numarray.Bool)
+        tmp_in = numarray.zeros(input.shape, bool)
         if return_value == None:
             tmp_out = output
         else:
-            tmp_out = numarray.zeros(input.shape, numarray.Bool)
+            tmp_out = numarray.zeros(input.shape, bool)
         if not iterations & 1:
             tmp_in, tmp_out = tmp_out, tmp_in
         changed = _nd_image.binary_erosion(input, structure, mask,
@@ -269,7 +270,7 @@
 
     tmp1 = _binary_erosion(input, structure1, 1, None, None, 0, origin1,
                            0, False)
-    inplace = isinstance(output, numarray.ndarray)
+    inplace = isinstance(output, numpy.ndarray)
     result = _binary_erosion(input, structure2, 1, None, output, 0,
                              origin2, 1, False)
     if inplace:
@@ -305,8 +306,8 @@
     to one.
     """
     mask = numarray.logical_not(input)
-    tmp = numarray.zeros(mask.shape, numarray.Bool)
-    inplace = isinstance(output, numarray.ndarray)
+    tmp = numarray.zeros(mask.shape, bool)
+    inplace = isinstance(output, numpy.ndarray)
     if inplace:
         binary_dilation(tmp, structure, -1, mask, output, 1, origin)
         numarray.logical_not(output, output)
@@ -407,7 +408,7 @@
     """
     tmp = grey_dilation(input, size, footprint, structure, None, mode,
                         cval, origin)
-    if isinstance(output, numarray.ndarray):
+    if isinstance(output, numpy.ndarray):
         grey_erosion(input, size, footprint, structure, output, mode,
                      cval, origin)
         return numarray.subtract(tmp, output, output)
@@ -429,7 +430,7 @@
     """
     tmp1 = grey_dilation(input, size, footprint, structure, None, mode,
                          cval, origin)
-    if isinstance(output, numarray.ndarray):
+    if isinstance(output, numpy.ndarray):
         grey_erosion(input, size, footprint, structure, output, mode,
                      cval, origin)
         numarray.add(tmp1, output, output)
@@ -458,7 +459,7 @@
     """
     tmp = grey_erosion(input, size, footprint, structure, None, mode,
                        cval, origin)
-    if isinstance(output, numarray.ndarray):
+    if isinstance(output, numpy.ndarray):
         grey_dilation(tmp, size, footprint, structure, output, mode, cval,
                       origin)
         del tmp
@@ -482,7 +483,7 @@
     """
     tmp = grey_dilation(input, size, footprint, structure, None, mode,
                         cval, origin)
-    if isinstance(output, numarray.ndarray):
+    if isinstance(output, numpy.ndarray):
         grey_erosion(tmp, size, footprint, structure, output, mode, cval,
                       origin)
         del tmp
@@ -573,7 +574,7 @@
         dt = None
     _nd_image.distance_transform_bf(tmp1, metric, sampling, dt, ft)
     if return_indices:
-        if isinstance(indices, numarray.ndarray):
+        if isinstance(indices, numpy.ndarray):
             if indices.dtype.type != numarray.int32:
                 raise RuntimeError, 'indices must of Int32 type'
             if indices.shape != (tmp1.ndim,) + tmp1.shape:
@@ -589,9 +590,9 @@
         ft = tmp2
     # construct and return the result
     result = []
-    if return_distances and not isinstance(distances, numarray.ndarray):
+    if return_distances and not isinstance(distances, numpy.ndarray):
         result.append(dt)
-    if return_indices and not isinstance(indices, numarray.ndarray):
+    if return_indices and not isinstance(indices, numpy.ndarray):
         result.append(ft)
     if len(result) == 2:
         return tuple(result)
@@ -628,8 +629,8 @@
     if (not return_distances) and (not return_indices):
         msg = 'at least one of distances/indices must be specified'
         raise RuntimeError, msg
-    ft_inplace = isinstance(indices, numarray.ndarray)
-    dt_inplace = isinstance(distances, numarray.ndarray)
+    ft_inplace = isinstance(indices, numpy.ndarray)
+    dt_inplace = isinstance(distances, numpy.ndarray)
     input = numarray.asarray(input)
     if structure == 'cityblock':
         rank = input.ndim
@@ -725,8 +726,8 @@
     if (not return_distances) and (not return_indices):
         msg = 'at least one of distances/indices must be specified'
         raise RuntimeError, msg
-    ft_inplace = isinstance(indices, numarray.ndarray)
-    dt_inplace = isinstance(distances, numarray.ndarray)
+    ft_inplace = isinstance(indices, numpy.ndarray)
+    dt_inplace = isinstance(distances, numpy.ndarray)
     # calculate the feature transform
     input = numarray.where(input, 1, 0).astype(numarray.Int8)
     if sampling is not None:

Modified: trunk/Lib/ndimage/tests/test_ndimage.py
===================================================================
--- trunk/Lib/ndimage/tests/test_ndimage.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/ndimage/tests/test_ndimage.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -32,7 +32,8 @@
 import unittest
 import math
 import numpy.oldnumeric as numarray
-from numpy import dft
+import numpy
+from numpy import fft
 from numpy.testing import *
 set_package_path()
 import scipy.ndimage as ndimage
@@ -42,9 +43,9 @@
 eps = 1e-12
 
 def diff(a, b):
-    if not isinstance(a, numarray.ndarray):
+    if not isinstance(a, numpy.ndarray):
         a = numarray.asarray(a)
-    if not isinstance(b, numarray.ndarray):
+    if not isinstance(b, numpy.ndarray):
         b = numarray.asarray(b)
     if (0 in a.shape) and (0 in b.shape):
         return 0.0
@@ -1302,12 +1303,12 @@
             for type in [numarray.float32, numarray.float64]:
                 a = numarray.zeros(shape, type)
                 a[0, 0] = 1.0
-                a = dft.rfft(a, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.rfft(a, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_gaussian(a, [5.0, 2.5],
                                                        shape[0], 0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.irfft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.irfft(a, shape[0], 0)
                 self.failUnless(diff(ndimage.sum(a), 1.0) < eps)
 
     def test_fourier_gaussian_complex01(self):
@@ -1316,12 +1317,12 @@
             for type in [numarray.complex64, numarray.complex128]:
                 a = numarray.zeros(shape, type)
                 a[0, 0] = 1.0
-                a = dft.fft(a, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.fft(a, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_gaussian(a, [5.0, 2.5], -1,
                                                        0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.ifft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.ifft(a, shape[0], 0)
                 error = diff(ndimage.sum(a.real), 1.0)
                 self.failUnless(error < eps)
 
@@ -1331,12 +1332,12 @@
             for type in [numarray.float32, numarray.float64]:
                 a = numarray.zeros(shape, type)
                 a[0, 0] = 1.0
-                a = dft.rfft(a, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.rfft(a, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_uniform(a, [5.0, 2.5],
                                                       shape[0], 0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.irfft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.irfft(a, shape[0], 0)
                 self.failUnless(diff(ndimage.sum(a), 1.0) < eps)
 
     def test_fourier_uniform_complex01(self):
@@ -1345,11 +1346,11 @@
             for type in [numarray.complex64, numarray.complex128]:
                 a = numarray.zeros(shape, type)
                 a[0, 0] = 1.0
-                a = dft.fft(a, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.fft(a, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_uniform(a, [5.0, 2.5], -1, 0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.ifft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.ifft(a, shape[0], 0)
                 error = diff(ndimage.sum(a.real), 1.0)
                 self.failUnless(error < eps)
 
@@ -1359,11 +1360,11 @@
             for dtype in [numarray.float32, numarray.float64]:
                 true = numarray.arange(shape[0] * shape[1], dtype = dtype)
                 true.shape = shape
-                a = dft.rfft(true, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.rfft(true, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_shift(a, [1, 1], shape[0], 0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.irfft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.irfft(a, shape[0], 0)
                 error1 = diff(a[1:, 1:], true[:-1, :-1])
                 error2 = diff(a.imag, numarray.zeros(shape))
                 self.failUnless(error1 < 1e-10 and error2 < 1e-10)
@@ -1375,11 +1376,11 @@
                 true = numarray.arange(shape[0] * shape[1],
                                        dtype = type)
                 true.shape = shape
-                a = dft.fft(true, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.fft(true, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_shift(a, [1, 1], -1, 0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.ifft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.ifft(a, shape[0], 0)
                 error1 = diff(a.real[1:, 1:], true[:-1, :-1])
                 error2 = diff(a.imag, numarray.zeros(shape))
                 self.failUnless(error1 < 1e-10 and error2 < 1e-10)
@@ -1390,12 +1391,12 @@
             for type in [numarray.float32, numarray.float64]:
                 a = numarray.zeros(shape, type)
                 a[0, 0] = 1.0
-                a = dft.rfft(a, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.rfft(a, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_ellipsoid(a, [5.0, 2.5],
                                                         shape[0], 0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.irfft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.irfft(a, shape[0], 0)
                 self.failUnless(diff(ndimage.sum(a), 1.0) < eps)
 
     def test_fourier_ellipsoid_complex01(self):
@@ -1404,12 +1405,12 @@
             for type in [numarray.complex64, numarray.complex128]:
                 a = numarray.zeros(shape, type)
                 a[0, 0] = 1.0
-                a = dft.fft(a, shape[0], 0)
-                a = dft.fft(a, shape[1], 1)
+                a = fft.fft(a, shape[0], 0)
+                a = fft.fft(a, shape[1], 1)
                 a = ndimage.fourier_ellipsoid(a, [5.0, 2.5], -1,
                                                         0)
-                a = dft.ifft(a, shape[1], 1)
-                a = dft.ifft(a, shape[0], 0)
+                a = fft.ifft(a, shape[1], 1)
+                a = fft.ifft(a, shape[0], 0)
                 error = diff(ndimage.sum(a.real), 1.0)
                 self.failUnless(error < eps)
 
@@ -2745,7 +2746,7 @@
 
     def test_sum06(self):
         "sum 6"
-        labels = numarray.array([], numarray.Bool)
+        labels = numarray.array([], bool)
         for type in self.types:
             input = numarray.array([], type)
             output = ndimage.sum(input, labels = labels)
@@ -2753,7 +2754,7 @@
 
     def test_sum07(self):
         "sum 7"
-        labels = numarray.ones([0, 4], numarray.Bool)
+        labels = numarray.ones([0, 4], bool)
         for type in self.types:
             input = numarray.zeros([0, 4], type)
             output = ndimage.sum(input, labels = labels)
@@ -2761,7 +2762,7 @@
 
     def test_sum08(self):
         "sum 8"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([1, 2], type)
             output = ndimage.sum(input, labels = labels)
@@ -2769,7 +2770,7 @@
 
     def test_sum09(self):
         "sum 9"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([[1, 2], [3, 4]], type)
             output = ndimage.sum(input, labels = labels)
@@ -2777,8 +2778,8 @@
 
     def test_sum10(self):
         "sum 10"
-        labels = numarray.array([1, 0], numarray.Bool)
-        input = numarray.array([[1, 2], [3, 4]], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
+        input = numarray.array([[1, 2], [3, 4]], bool)
         output = ndimage.sum(input, labels = labels)
         self.failUnless(output == 2.0)
 
@@ -2802,7 +2803,7 @@
 
     def test_mean01(self):
         "mean 1"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([[1, 2], [3, 4]], type)
             output = ndimage.mean(input, labels = labels)
@@ -2810,8 +2811,8 @@
 
     def test_mean02(self):
         "mean 2"
-        labels = numarray.array([1, 0], numarray.Bool)
-        input = numarray.array([[1, 2], [3, 4]], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
+        input = numarray.array([[1, 2], [3, 4]], bool)
         output = ndimage.mean(input, labels = labels)
         self.failUnless(output == 1.0)
 
@@ -2835,7 +2836,7 @@
 
     def test_minimum01(self):
         "minimum 1"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([[1, 2], [3, 4]], type)
             output = ndimage.minimum(input, labels = labels)
@@ -2843,8 +2844,8 @@
 
     def test_minimum02(self):
         "minimum 2"
-        labels = numarray.array([1, 0], numarray.Bool)
-        input = numarray.array([[2, 2], [2, 4]], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
+        input = numarray.array([[2, 2], [2, 4]], bool)
         output = ndimage.minimum(input, labels = labels)
         self.failUnless(output == 1.0)
 
@@ -2868,7 +2869,7 @@
 
     def test_maximum01(self):
         "maximum 1"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([[1, 2], [3, 4]], type)
             output = ndimage.maximum(input, labels = labels)
@@ -2876,8 +2877,8 @@
 
     def test_maximum02(self):
         "maximum 2"
-        labels = numarray.array([1, 0], numarray.Bool)
-        input = numarray.array([[2, 2], [2, 4]], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
+        input = numarray.array([[2, 2], [2, 4]], bool)
         output = ndimage.maximum(input, labels = labels)
         self.failUnless(output == 1.0)
 
@@ -2922,7 +2923,7 @@
 
     def test_variance04(self):
         "variance 4"
-        input = numarray.array([1, 0], numarray.Bool)
+        input = numarray.array([1, 0], bool)
         output = ndimage.variance(input)
         self.failUnless(output == 0.5)
 
@@ -2965,7 +2966,7 @@
 
     def test_standard_deviation04(self):
         "standard deviation 4"
-        input = numarray.array([1, 0], numarray.Bool)
+        input = numarray.array([1, 0], bool)
         output = ndimage.standard_deviation(input)
         self.failUnless(output == math.sqrt(0.5))
 
@@ -2989,7 +2990,7 @@
 
     def test_minimum_position01(self):
         "minimum position 1"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([[1, 2], [3, 4]], type)
             output = ndimage.minimum_position(input,
@@ -3009,7 +3010,7 @@
         "minimum position 3"
         input = numarray.array([[5, 4, 2, 5],
                                 [3, 7, 0, 2],
-                                [1, 5, 1, 1]], numarray.Bool)
+                                [1, 5, 1, 1]], bool)
         output = ndimage.minimum_position(input)
         self.failUnless(output == (1, 2))
 
@@ -3017,7 +3018,7 @@
         "minimum position 4"
         input = numarray.array([[5, 4, 2, 5],
                                 [3, 7, 1, 2],
-                                [1, 5, 1, 1]], numarray.Bool)
+                                [1, 5, 1, 1]], bool)
         output = ndimage.minimum_position(input)
         self.failUnless(output == (0, 0))
 
@@ -3054,7 +3055,7 @@
 
     def test_maximum_position01(self):
         "maximum position 1"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([[1, 2], [3, 4]], type)
             output = ndimage.maximum_position(input,
@@ -3074,7 +3075,7 @@
         "maximum position 3"
         input = numarray.array([[5, 4, 2, 5],
                                 [3, 7, 8, 2],
-                                [1, 5, 1, 1]], numarray.Bool)
+                                [1, 5, 1, 1]], bool)
         output = ndimage.maximum_position(input)
         self.failUnless(output == (0, 0))
 
@@ -3111,7 +3112,7 @@
 
     def test_extrema01(self):
         "extrema 1"
-        labels = numarray.array([1, 0], numarray.Bool)
+        labels = numarray.array([1, 0], bool)
         for type in self.types:
             input = numarray.array([[1, 2], [3, 4]], type)
             output1 = ndimage.extrema(input, labels = labels)
@@ -3225,7 +3226,7 @@
     def test_center_of_mass06(self):
         "center of mass 6"
         true = [0.5, 0.5]
-        input = numarray.array([[1, 2], [3, 1]], numarray.Bool)
+        input = numarray.array([[1, 2], [3, 1]], bool)
         output = ndimage.center_of_mass(input)
         e = diff(true, output)
         self.failUnless(e < eps)
@@ -3234,7 +3235,7 @@
         "center of mass 7"
         labels = [1, 0]
         true = [0.5, 0.0]
-        input = numarray.array([[1, 2], [3, 1]], numarray.Bool)
+        input = numarray.array([[1, 2], [3, 1]], bool)
         output = ndimage.center_of_mass(input, labels)
         e = diff(true, output)
         self.failUnless(e < eps)
@@ -3243,7 +3244,7 @@
         "center of mass 8"
         labels = [1, 2]
         true = [0.5, 1.0]
-        input = numarray.array([[5, 2], [3, 1]], numarray.Bool)
+        input = numarray.array([[5, 2], [3, 1]], bool)
         output = ndimage.center_of_mass(input, labels, 2)
         e = diff(true, output)
         self.failUnless(e < eps)
@@ -3253,7 +3254,7 @@
         "center of mass 9"
         labels = [1, 2]
         true = [(0.5, 0.0), (0.5, 1.0)]
-        input = numarray.array([[1, 2], [1, 1]], numarray.Bool)
+        input = numarray.array([[1, 2], [1, 1]], bool)
         output = ndimage.center_of_mass(input, labels, [1, 2])
         e = diff(true, output)
         self.failUnless(e < eps)
@@ -4163,7 +4164,7 @@
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
                                [0, 0, 0, 1, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_erosion(data, struct,
                                          border_value = 1, iterations = 2)
         self.failUnless(diff(out, true) < eps)
@@ -4186,8 +4187,8 @@
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
                                [0, 0, 0, 1, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
-        out = numarray.zeros(data.shape, numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0]], bool)
+        out = numarray.zeros(data.shape, bool)
         ndimage.binary_erosion(data, struct, border_value = 1,
                                          iterations = 2, output = out)
         self.failUnless(diff(out, true) < eps)
@@ -4210,7 +4211,7 @@
                                [1, 1, 1, 1, 1, 1, 1],
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
-                               [0, 0, 0, 1, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 1, 0, 0, 0]], bool)
         out = ndimage.binary_erosion(data, struct,
                                          border_value = 1, iterations = 3)
         self.failUnless(diff(out, true) < eps)
@@ -4233,8 +4234,8 @@
                                [1, 1, 1, 1, 1, 1, 1],
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
-                               [0, 0, 0, 1, 0, 0, 0]], numarray.Bool)
-        out = numarray.zeros(data.shape, numarray.Bool)
+                               [0, 0, 0, 1, 0, 0, 0]], bool)
+        out = numarray.zeros(data.shape, bool)
         ndimage.binary_erosion(data, struct, border_value = 1,
                                          iterations = 3, output = out)
         self.failUnless(diff(out, true) < eps)
@@ -4257,8 +4258,8 @@
                                [1, 1, 1, 1, 1, 1, 1],
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
-                               [0, 0, 0, 1, 0, 0, 0]], numarray.Bool)
-        out = numarray.zeros(data.shape, numarray.Bool)
+                               [0, 0, 0, 1, 0, 0, 0]], bool)
+        out = numarray.zeros(data.shape, bool)
         ndimage.binary_erosion(data, struct, border_value = 1,
                           iterations = 1, output = out, origin = (-1, -1))
         self.failUnless(diff(out, true) < eps)
@@ -4281,7 +4282,7 @@
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
                                [0, 0, 0, 1, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_erosion(data, struct,
                                          border_value = 1, iterations = 2)
         self.failUnless(diff(out, true) < eps)
@@ -4311,7 +4312,7 @@
                                [0, 0, 1, 1, 1, 0, 0],
                                [0, 0, 1, 1, 1, 0, 0],
                                [0, 0, 0, 1, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_erosion(data, struct,
                             border_value = 1, mask = mask, iterations = -1)
         self.failUnless(diff(out, true) < eps)
@@ -4341,7 +4342,7 @@
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
                                [0, 0, 0, 1, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_erosion(data, struct,
                                             border_value = 1, mask = mask)
         self.failUnless(diff(out, true) < eps)
@@ -4364,7 +4365,7 @@
                                [1, 1, 1, 1, 1, 1, 1],
                                [0, 1, 1, 1, 1, 1, 0],
                                [0, 0, 1, 1, 1, 0, 0],
-                               [0, 0, 0, 1, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 1, 0, 0, 0]], bool)
         tmp = [[0, 0, 1, 0, 0, 0, 0],
                [0, 1, 1, 1, 0, 0, 0],
                [1, 1, 1, 1, 1, 0, 1],
@@ -4375,7 +4376,7 @@
         true = numarray.logical_and(tmp, mask)
         tmp = numarray.logical_and(data, numarray.logical_not(mask))
         true = numarray.logical_or(true, tmp)
-        out = numarray.zeros(data.shape, numarray.Bool)
+        out = numarray.zeros(data.shape, bool)
         ndimage.binary_erosion(data, struct, border_value = 1,
                                          iterations = 1, output = out,
                                          origin = (-1, -1), mask = mask)
@@ -4762,7 +4763,7 @@
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 1, 0],
-                               [0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_dilation(data, struct,
                                                 iterations = 2)
         self.failUnless(diff(out, true) < eps)
@@ -4781,8 +4782,8 @@
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 1, 0],
-                               [0, 0, 0, 0, 0]], numarray.Bool)
-        out = numarray.zeros(data.shape, numarray.Bool)
+                               [0, 0, 0, 0, 0]], bool)
+        out = numarray.zeros(data.shape, bool)
         ndimage.binary_dilation(data, struct, iterations = 2,
                                           output = out)
         self.failUnless(diff(out, true) < eps)
@@ -4801,7 +4802,7 @@
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 1, 0],
-                               [0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_dilation(data, struct,
                                                 iterations = 3)
         self.failUnless(diff(out, true) < eps)
@@ -4820,8 +4821,8 @@
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0],
                                [0, 0, 0, 1, 0],
-                               [0, 0, 0, 0, 0]], numarray.Bool)
-        out = numarray.zeros(data.shape, numarray.Bool)
+                               [0, 0, 0, 0, 0]], bool)
+        out = numarray.zeros(data.shape, bool)
         ndimage.binary_dilation(data, struct, iterations = 3,
                                           output = out)
         self.failUnless(diff(out, true) < eps)
@@ -4838,7 +4839,7 @@
                                [0, 0, 1, 1, 1, 0, 0, 0],
                                [0, 1, 1, 0, 1, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         mask = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 1, 0],
@@ -4846,7 +4847,7 @@
                                [0, 0, 1, 1, 1, 0, 0, 0],
                                [0, 1, 1, 0, 1, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         data = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
@@ -4854,7 +4855,7 @@
                                [0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 1, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
 
         out = ndimage.binary_dilation(data, struct,
                            iterations = -1, mask = mask, border_value = 0)
@@ -4880,8 +4881,8 @@
                                [0, 0, 0, 1, 1, 0, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
-        data = numarray.zeros(mask.shape, numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
+        data = numarray.zeros(mask.shape, bool)
         out = ndimage.binary_dilation(data, struct,
                           iterations = -1, mask = mask, border_value = 1)
         self.failUnless(diff(out, true) < eps)
@@ -4940,7 +4941,7 @@
                                [0, 0, 1, 1, 1, 0, 0, 0],
                                [0, 1, 1, 0, 1, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         mask = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 1, 0],
@@ -4948,7 +4949,7 @@
                                [0, 0, 1, 1, 1, 0, 0, 0],
                                [0, 1, 1, 0, 1, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         data = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
@@ -4956,7 +4957,7 @@
                                [0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 1, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
 
         out = ndimage.binary_propagation(data, struct,
                                             mask = mask, border_value = 0)
@@ -4982,8 +4983,8 @@
                                [0, 0, 0, 1, 1, 0, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
-        data = numarray.zeros(mask.shape, numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
+        data = numarray.zeros(mask.shape, bool)
         out = ndimage.binary_propagation(data, struct,
                                              mask = mask, border_value = 1)
         self.failUnless(diff(out, true) < eps)
@@ -5086,14 +5087,14 @@
                                [0, 0, 1, 1, 1, 1, 0, 0],
                                [0, 0, 1, 1, 1, 1, 0, 0],
                                [0, 0, 1, 1, 1, 1, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 0, 1, 1, 1, 1, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 1, 1, 1, 1, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_fill_holes(data)
         self.failUnless(diff(out, true) < eps)
 
@@ -5105,14 +5106,14 @@
                                [0, 0, 1, 1, 1, 1, 0, 0],
                                [0, 0, 1, 1, 1, 1, 0, 0],
                                [0, 0, 0, 1, 1, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 0, 0, 1, 1, 0, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 1, 0, 0, 1, 0, 0],
                                [0, 0, 0, 1, 1, 0, 0, 0],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_fill_holes(data)
         self.failUnless(diff(out, true) < eps)
 
@@ -5124,14 +5125,14 @@
                                [0, 1, 1, 1, 0, 1, 1, 1],
                                [0, 1, 1, 1, 0, 1, 1, 1],
                                [0, 0, 1, 0, 0, 1, 1, 1],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
                                [0, 0, 1, 0, 0, 0, 0, 0],
                                [0, 1, 0, 1, 0, 1, 1, 1],
                                [0, 1, 0, 1, 0, 1, 0, 1],
                                [0, 1, 0, 1, 0, 1, 0, 1],
                                [0, 0, 1, 0, 0, 1, 1, 1],
-                               [0, 0, 0, 0, 0, 0, 0, 0]], numarray.Bool)
+                               [0, 0, 0, 0, 0, 0, 0, 0]], bool)
         out = ndimage.binary_fill_holes(data)
         self.failUnless(diff(out, true) < eps)
 
@@ -5412,7 +5413,7 @@
                                    [0, 1, 1, 1, 1],
                                    [0, 1, 1, 1, 1],
                                    [0, 0, 0, 0, 0]], type)
-            out = numarray.zeros(data.shape, numarray.Bool)
+            out = numarray.zeros(data.shape, bool)
             ndimage.binary_hit_or_miss(data, struct,
                                                  output = out)
             self.failUnless(diff(true, out) < eps)

Modified: trunk/Lib/sandbox/xplt/shapetest.py
===================================================================
--- trunk/Lib/sandbox/xplt/shapetest.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/sandbox/xplt/shapetest.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -18,8 +18,8 @@
 # This routine should be able to tell you the size of any object:
 def no_of_dims (x) :
     if x == None : return 0
-    if (isinstance(x, ndarray)) : return len (x.shape)
-    if (isinstance(x, list) or isinstance(x, tuple) : return 1
+    if isinstance(x, ndarray) : return len (x.shape)
+    if isinstance(x, (list, tuple)) : return 1
     # I don't know if there are any other possibilities.
     for i in range (10) :
         if is_scalar (x) : return i

Modified: trunk/Lib/stats/distributions.py
===================================================================
--- trunk/Lib/stats/distributions.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/stats/distributions.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -9,7 +9,7 @@
 import scipy.special as special
 import scipy.optimize as optimize
 import inspect
-from numpy import alltrue, where, arange, put, putmask, nonzero, \
+from numpy import alltrue, where, arange, put, putmask, \
      ravel, take, ones, sum, shape, product, repeat, reshape, \
      zeros, floor, logical_and, log, sqrt, exp, arctanh, tan, sin, arcsin, \
      arctan, tanh, ndarray, cos, cosh, sinh, newaxis
@@ -17,6 +17,7 @@
      any, argsort, argmax, vectorize, r_, asarray, nan, inf, pi, isnan, isinf
 import numpy
 import numpy.random as mtrand
+from numpy.oldnumeric import nonzero
 
 __all__ = [
            'rv_continuous',

Modified: trunk/Lib/stats/tests/test_distributions.py
===================================================================
--- trunk/Lib/stats/tests/test_distributions.py	2006-08-04 10:13:12 UTC (rev 2148)
+++ trunk/Lib/stats/tests/test_distributions.py	2006-08-05 07:27:52 UTC (rev 2149)
@@ -7,6 +7,7 @@
 
 set_package_path()
 import numpy.oldnumeric as numpy
+from numpy import typecodes
 import stats
 restore_path()
 
@@ -77,11 +78,11 @@
         assert(len(vals) == 100)
         vals = stats.randint.rvs(5,30,size=(2,50))
         assert(numpy.shape(vals) == (2,50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.randint.rvs(15,46)
         assert((val >= 15) & (val < 46))
         assert isinstance(val, numpy.ScalarType),`type(val)`
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
     def check_pdf(self):
         k = numpy.r_[0:36]
@@ -101,10 +102,10 @@
         vals = stats.binom.rvs(10, 0.75, size=(2, 50))
         assert(numpy.all(vals >= 0) & numpy.all(vals <= 10))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.binom.rvs(10, 0.75)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 
 class test_bernoulli(ScipyTestCase):
@@ -112,30 +113,30 @@
         vals = stats.bernoulli.rvs(0.75, size=(2, 50))
         assert(numpy.all(vals >= 0) & numpy.all(vals <= 1))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.bernoulli.rvs(0.75)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 class test_nbinom(ScipyTestCase):
     def check_rvs(self):
         vals = stats.nbinom.rvs(10, 0.75, size=(2, 50))
         assert(numpy.all(vals >= 0))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.nbinom.rvs(10, 0.75)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 class test_geom(ScipyTestCase):
     def check_rvs(self):
         vals = stats.geom.rvs(0.75, size=(2, 50))
         assert(numpy.all(vals >= 0))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.geom.rvs(0.75)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 class test_hypergeom(ScipyTestCase):
     def check_rvs(self):
@@ -143,49 +144,49 @@
         assert(numpy.all(vals >= 0) &
                numpy.all(vals <= 3))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.hypergeom.rvs(20, 3, 10)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 class test_logser(ScipyTestCase):
     def check_rvs(self):
         vals = stats.logser.rvs(0.75, size=(2, 50))
         assert(numpy.all(vals >= 1))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.logser.rvs(0.75)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 class test_poisson(ScipyTestCase):
     def check_rvs(self):
         vals = stats.poisson.rvs(0.5, size=(2, 50))
         assert(numpy.all(vals >= 0))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.poisson.rvs(0.5)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 class test_zipf(ScipyTestCase):
     def check_rvs(self):
         vals = stats.zipf.rvs(1.5, size=(2, 50))
         assert(numpy.all(vals >= 1))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.zipf.rvs(1.5)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 class test_dlaplace(ScipyTestCase):
     def check_rvs(self):
         vals = stats.dlaplace.rvs(1.5 , size=(2, 50))
         assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in numpy.typecodes['AllInteger'])
+        assert(vals.dtype.char in typecodes['AllInteger'])
         val = stats.dlaplace.rvs(1.5)
         assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in numpy.typecodes['AllInteger'])
+        assert(val.dtype.char in typecodes['AllInteger'])
 
 if __name__ == "__main__":
     ScipyTest('stats.distributions').run()



More information about the Scipy-svn mailing list