[Scipy-svn] r2232 - in trunk/Lib/ndimage: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Sep 24 05:05:17 EDT 2006
Author: rkern
Date: 2006-09-24 04:05:13 -0500 (Sun, 24 Sep 2006)
New Revision: 2232
Modified:
trunk/Lib/ndimage/_ni_support.py
trunk/Lib/ndimage/filters.py
trunk/Lib/ndimage/fourier.py
trunk/Lib/ndimage/interpolation.py
trunk/Lib/ndimage/measurements.py
trunk/Lib/ndimage/morphology.py
trunk/Lib/ndimage/tests/test_ndimage.py
Log:
Drop use of oldnumeric.
Modified: trunk/Lib/ndimage/_ni_support.py
===================================================================
--- trunk/Lib/ndimage/_ni_support.py 2006-09-24 08:28:59 UTC (rev 2231)
+++ trunk/Lib/ndimage/_ni_support.py 2006-09-24 09:05:13 UTC (rev 2232)
@@ -29,7 +29,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import types
-import numpy.oldnumeric as numarray
+import numpy
def _extend_mode_to_code(mode):
"""Convert an extension mode to the corresponding integer code.
@@ -75,14 +75,14 @@
if shape is None:
shape = input.shape
if output is None:
- output = numarray.zeros(shape, dtype = input.dtype)
+ output = numpy.zeros(shape, dtype = input.dtype)
return_value = output
- elif type(output) in [type(types.TypeType), type(numarray.zeros((4,)).dtype)]:
- output = numarray.zeros(shape, dtype = output)
+ elif type(output) in [type(types.TypeType), type(numpy.zeros((4,)).dtype)]:
+ output = numpy.zeros(shape, dtype = output)
return_value = output
elif type(output) is types.StringType:
- output = numarray.typeDict[output]
- output = numarray.zeros(shape, dtype = output)
+ output = numpy.typeDict[output]
+ output = numpy.zeros(shape, dtype = output)
return_value = output
else:
if output.shape != shape:
Modified: trunk/Lib/ndimage/filters.py
===================================================================
--- trunk/Lib/ndimage/filters.py 2006-09-24 08:28:59 UTC (rev 2231)
+++ trunk/Lib/ndimage/filters.py 2006-09-24 09:05:13 UTC (rev 2232)
@@ -29,7 +29,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import math
-import numpy.oldnumeric as numarray
+import numpy
import _ni_support
import _nd_image
@@ -40,11 +40,11 @@
The lines of the array along the given axis are correlated with the
given weights. The weights parameter must be a one-dimensional sequence
of numbers."""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
output, return_value = _ni_support._get_output(output, input)
- weights = numarray.asarray(weights, dtype = numarray.Float64)
+ weights = numpy.asarray(weights, dtype = numpy.float64)
if weights.ndim != 1 or weights.shape[0] < 1:
raise RuntimeError, 'no filter weights given'
if not weights.flags.contiguous:
@@ -142,7 +142,7 @@
because intermediate results may be stored with insufficient
precision.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _ni_support._get_output(output, input)
orders = _ni_support._normalize_sequence(order, input.ndim)
sigmas = _ni_support._normalize_sequence(sigma, input.ndim)
@@ -161,7 +161,7 @@
def prewitt(input, axis = -1, output = None, mode = "reflect", cval = 0.0):
"""Calculate a Prewitt filter.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
axis = _ni_support._check_axis(axis, input.ndim)
output, return_value = _ni_support._get_output(output, input)
correlate1d(input, [-1, 0, 1], axis, output, mode, cval, 0)
@@ -173,7 +173,7 @@
def sobel(input, axis = -1, output = None, mode = "reflect", cval = 0.0):
"""Calculate a Sobel filter.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
axis = _ni_support._check_axis(axis, input.ndim)
output, return_value = _ni_support._get_output(output, input)
correlate1d(input, [-1, 0, 1], axis, output, mode, cval, 0)
@@ -197,7 +197,7 @@
extra arguments and keywords that are passed to derivative2 at each
call.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _ni_support._get_output(output, input)
axes = range(input.ndim)
if len(axes) > 0:
@@ -228,7 +228,7 @@
axis as a sequence, or as a single number, in which case it is
equal for all axes..
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
def derivative2(input, axis, output, mode, cval, sigma):
order = [0] * input.ndim
order[axis] = 2
@@ -252,19 +252,19 @@
extra arguments and keywords that are passed to derivative2 at each
call.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _ni_support._get_output(output, input)
axes = range(input.ndim)
if len(axes) > 0:
derivative(input, axes[0], output, mode, cval,
*extra_arguments, **extra_keywords)
- numarray.multiply(output, output, output)
+ numpy.multiply(output, output, output)
for ii in range(1, len(axes)):
tmp = derivative(input, axes[ii], output.dtype, mode, cval,
*extra_arguments, **extra_keywords)
- numarray.multiply(tmp, tmp, tmp)
+ numpy.multiply(tmp, tmp, tmp)
output += tmp
- numarray.sqrt(output, output)
+ numpy.sqrt(output, output)
else:
output[...] = input[...]
return return_value
@@ -278,7 +278,7 @@
axis as a sequence, or as a single number, in which case it is
equal for all axes..
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
def derivative(input, axis, output, mode, cval, sigma):
order = [0] * input.ndim
order[axis] = 1
@@ -288,11 +288,11 @@
def _correlate_or_convolve(input, weights, output, mode, cval, origin,
convolution):
- input = numarray.asarray(input)
- if numarray.iscomplexobj(int):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(int):
raise TypeError, 'Complex type not supported'
origins = _ni_support._normalize_sequence(origin, input.ndim)
- weights = numarray.asarray(weights, dtype = numarray.Float64)
+ weights = numpy.asarray(weights, dtype = numpy.float64)
wshape = [ii for ii in weights.shape if ii > 0]
if len(wshape) != input.ndim:
raise RuntimeError, 'filter weights array has incorrect shape.'
@@ -336,8 +336,8 @@
The lines of the array along the given axis are filtered with a
uniform filter of given size."""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
axis = _ni_support._check_axis(axis, input.ndim)
if size < 1:
@@ -364,7 +364,7 @@
with a limited precision, the results may be imprecise because
intermediate results may be stored with insufficient precision.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _ni_support._get_output(output, input)
sizes = _ni_support._normalize_sequence(size, input.ndim)
origins = _ni_support._normalize_sequence(origin, input.ndim)
@@ -386,8 +386,8 @@
The lines of the array along the given axis are filtered with a
minimum filter of given size."""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
axis = _ni_support._check_axis(axis, input.ndim)
if size < 1:
@@ -406,8 +406,8 @@
The lines of the array along the given axis are filtered with a
maximum filter of given size."""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
axis = _ni_support._check_axis(axis, input.ndim)
if size < 1:
@@ -428,24 +428,24 @@
raise RuntimeError, "no footprint provided"
separable= True
else:
- footprint = numarray.asarray(footprint)
+ footprint = numpy.asarray(footprint)
footprint = footprint.astype(bool)
- if numarray.alltrue(numarray.ravel(footprint),axis=0):
+ if numpy.alltrue(numpy.ravel(footprint),axis=0):
size = footprint.shape
footprint = None
separable = True
else:
separable = False
else:
- structure = numarray.asarray(structure, dtype = numarray.Float64)
+ structure = numpy.asarray(structure, dtype = numpy.float64)
separable = False
if footprint is None:
- footprint = numarray.ones(structure.shape, bool)
+ footprint = numpy.ones(structure.shape, bool)
else:
- footprint = numarray.asarray(footprint)
+ footprint = numpy.asarray(footprint)
footprint = footprint.astype(bool)
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
output, return_value = _ni_support._get_output(output, input)
origins = _ni_support._normalize_sequence(origin, input.ndim)
@@ -512,17 +512,17 @@
def _rank_filter(input, rank, size = None, footprint = None, output = None,
mode = "reflect", cval = 0.0, origin = 0, operation = 'rank'):
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
origins = _ni_support._normalize_sequence(origin, input.ndim)
if footprint == None:
if size == None:
raise RuntimeError, "no footprint or filter size provided"
sizes = _ni_support._normalize_sequence(size, input.ndim)
- footprint = numarray.ones(sizes, dtype = bool)
+ footprint = numpy.ones(sizes, dtype = bool)
else:
- footprint = numarray.asarray(footprint, dtype = bool)
+ footprint = numpy.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.'
@@ -531,7 +531,7 @@
raise ValueError, 'invalid origin'
if not footprint.flags.contiguous:
footprint = footprint.copy()
- filter_size = numarray.where(footprint, 1, 0).sum()
+ filter_size = numpy.where(footprint, 1, 0).sum()
if operation == 'median':
rank = filter_size // 2
elif operation == 'percentile':
@@ -617,8 +617,8 @@
the value when mode is equal to 'constant'. The extra_arguments and
extra_keywords arguments can be used to pass extra arguments and
keywords that are passed to the function at each call."""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
output, return_value = _ni_support._get_output(output, input)
if filter_size < 1:
@@ -648,17 +648,17 @@
value when mode is equal to 'constant'. The extra_arguments and
extra_keywords arguments can be used to pass extra arguments and
keywords that are passed to the function at each call."""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
origins = _ni_support._normalize_sequence(origin, input.ndim)
if footprint == None:
if size == None:
raise RuntimeError, "no footprint or filter size provided"
sizes = _ni_support._normalize_sequence(size, input.ndim)
- footprint = numarray.ones(size, dtype = bool)
+ footprint = numpy.ones(size, dtype = bool)
else:
- footprint = numarray.asarray(footprint)
+ footprint = numpy.asarray(footprint)
footprint = footprint.astype(bool)
fshape = [ii for ii in footprint.shape if ii > 0]
if len(fshape) != input.ndim:
Modified: trunk/Lib/ndimage/fourier.py
===================================================================
--- trunk/Lib/ndimage/fourier.py 2006-09-24 08:28:59 UTC (rev 2231)
+++ trunk/Lib/ndimage/fourier.py 2006-09-24 09:05:13 UTC (rev 2232)
@@ -30,23 +30,23 @@
import types
import math
-import numpy.oldnumeric as numarray
+import numpy
import _ni_support
import _nd_image
def _get_output_fourier(output, input):
if output == None:
- if input.dtype.type in [numarray.complex64, numarray.complex128,
- numarray.float32]:
- output = numarray.zeros(input.shape, dtype = input.dtype)
+ if input.dtype.type in [numpy.complex64, numpy.complex128,
+ numpy.float32]:
+ output = numpy.zeros(input.shape, dtype = input.dtype)
else:
- output = numarray.zeros(input.shape, dtype = numarray.Float64)
+ output = numpy.zeros(input.shape, dtype = numpy.float64)
return_value = output
elif type(output) is types.TypeType:
- if output not in [numarray.complex64, numarray.complex128,
- numarray.float32, numarray.float64]:
+ if output not in [numpy.complex64, numpy.complex128,
+ numpy.float32, numpy.float64]:
raise RuntimeError, "output type not supported"
- output = numarray.zeros(input.shape, dtype = output)
+ output = numpy.zeros(input.shape, dtype = output)
return_value = output
else:
if output.shape != input.shape:
@@ -56,15 +56,15 @@
def _get_output_fourier_complex(output, input):
if output == None:
- if input.dtype.type in [numarray.complex64, numarray.complex128]:
- output = numarray.zeros(input.shape, dtype = input.dtype)
+ if input.dtype.type in [numpy.complex64, numpy.complex128]:
+ output = numpy.zeros(input.shape, dtype = input.dtype)
else:
- output = numarray.zeros(input.shape, dtype = numarray.Complex64)
+ output = numpy.zeros(input.shape, dtype = numpy.Complex64)
return_value = output
elif type(output) is types.TypeType:
- if output not in [numarray.complex64, numarray.complex128]:
+ if output not in [numpy.complex64, numpy.complex128]:
raise RuntimeError, "output type not supported"
- output = numarray.zeros(input.shape, dtype = output)
+ output = numpy.zeros(input.shape, dtype = output)
return_value = output
else:
if output.shape != input.shape:
@@ -83,11 +83,11 @@
direction. The axis of the real transform is given by the axis
parameter.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _get_output_fourier(output, input)
axis = _ni_support._check_axis(axis, input.ndim)
sigmas = _ni_support._normalize_sequence(sigma, input.ndim)
- sigmas = numarray.asarray(sigmas, dtype = numarray.Float64)
+ sigmas = numpy.asarray(sigmas, dtype = numpy.float64)
if not sigmas.flags.contiguous:
sigmas = sigmas.copy()
@@ -105,11 +105,11 @@
direction. The axis of the real transform is given by the axis
parameter.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _get_output_fourier(output, input)
axis = _ni_support._check_axis(axis, input.ndim)
sizes = _ni_support._normalize_sequence(size, input.ndim)
- sizes = numarray.asarray(sizes, dtype = numarray.Float64)
+ sizes = numpy.asarray(sizes, dtype = numpy.float64)
if not sizes.flags.contiguous:
sizes = sizes.copy()
_nd_image.fourier_filter(input, sizes, n, axis, output, 1)
@@ -127,11 +127,11 @@
parameter. This function is implemented for arrays of
rank 1, 2, or 3.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _get_output_fourier(output, input)
axis = _ni_support._check_axis(axis, input.ndim)
sizes = _ni_support._normalize_sequence(size, input.ndim)
- sizes = numarray.asarray(sizes, dtype = numarray.Float64)
+ sizes = numpy.asarray(sizes, dtype = numpy.float64)
if not sizes.flags.contiguous:
sizes = sizes.copy()
_nd_image.fourier_filter(input, sizes, n, axis, output, 2)
@@ -148,11 +148,11 @@
direction. The axis of the real transform is given by the axis
parameter.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
output, return_value = _get_output_fourier_complex(output, input)
axis = _ni_support._check_axis(axis, input.ndim)
shifts = _ni_support._normalize_sequence(shift, input.ndim)
- shifts = numarray.asarray(shifts, dtype = numarray.Float64)
+ shifts = numpy.asarray(shifts, dtype = numpy.float64)
if not shifts.flags.contiguous:
shifts = shifts.copy()
_nd_image.fourier_shift(input, shifts, n, axis, output)
Modified: trunk/Lib/ndimage/interpolation.py
===================================================================
--- trunk/Lib/ndimage/interpolation.py 2006-09-24 08:28:59 UTC (rev 2231)
+++ trunk/Lib/ndimage/interpolation.py 2006-09-24 09:05:13 UTC (rev 2232)
@@ -30,12 +30,12 @@
import types
import math
-import numpy.oldnumeric as numarray
+import numpy
import _ni_support
import _nd_image
-def spline_filter1d(input, order = 3, axis = -1, output = numarray.float64,
+def spline_filter1d(input, order = 3, axis = -1, output = numpy.float64,
output_type = None):
"""Calculates a one-dimensional spline filter along the given axis.
@@ -44,20 +44,20 @@
"""
if order < 0 or order > 5:
raise RuntimeError, 'spline order not supported'
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
output, return_value = _ni_support._get_output(output, input,
output_type)
if order in [0, 1]:
- output[...] = numarray.array(input)
+ output[...] = numpy.array(input)
else:
axis = _ni_support._check_axis(axis, input.ndim)
_nd_image.spline_filter1d(input, order, axis, output)
return return_value
-def spline_filter(input, order = 3, output = numarray.float64,
+def spline_filter(input, order = 3, output = numpy.float64,
output_type = None):
"""Multi-dimensional spline filter.
@@ -69,8 +69,8 @@
"""
if order < 2 or order > 5:
raise RuntimeError, 'spline order not supported'
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
output, return_value = _ni_support._get_output(output, input,
output_type)
@@ -119,8 +119,8 @@
"""
if order < 0 or order > 5:
raise RuntimeError, 'spline order not supported'
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if output_shape == None:
output_shape = input.shape
@@ -128,7 +128,7 @@
raise RuntimeError, 'input and output rank must be > 0'
mode = _ni_support._extend_mode_to_code(mode)
if prefilter and order > 1:
- filtered = spline_filter(input, order, output = numarray.float64)
+ filtered = spline_filter(input, order, output = numpy.float64)
else:
filtered = input
output, return_value = _ni_support._get_output(output, input,
@@ -177,11 +177,11 @@
"""
if order < 0 or order > 5:
raise RuntimeError, 'spline order not supported'
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
- coordinates = numarray.asarray(coordinates)
- if numarray.iscomplexobj(coordinates):
+ coordinates = numpy.asarray(coordinates)
+ if numpy.iscomplexobj(coordinates):
raise TypeError, 'Complex type not supported'
output_shape = coordinates.shape[1:]
if input.ndim < 1 or len(output_shape) < 1:
@@ -190,7 +190,7 @@
raise RuntimeError, 'invalid shape for coordinate array'
mode = _ni_support._extend_mode_to_code(mode)
if prefilter and order > 1:
- filtered = spline_filter(input, order, output = numarray.float64)
+ filtered = spline_filter(input, order, output = numpy.float64)
else:
filtered = input
output, return_value = _ni_support._get_output(output, input,
@@ -222,8 +222,8 @@
"""
if order < 0 or order > 5:
raise RuntimeError, 'spline order not supported'
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if output_shape == None:
output_shape = input.shape
@@ -231,12 +231,12 @@
raise RuntimeError, 'input and output rank must be > 0'
mode = _ni_support._extend_mode_to_code(mode)
if prefilter and order > 1:
- filtered = spline_filter(input, order, output = numarray.float64)
+ filtered = spline_filter(input, order, output = numpy.float64)
else:
filtered = input
output, return_value = _ni_support._get_output(output, input,
output_type, shape = output_shape)
- matrix = numarray.asarray(matrix, dtype = numarray.float64)
+ matrix = numpy.asarray(matrix, dtype = numpy.float64)
if matrix.ndim not in [1, 2] or matrix.shape[0] < 1:
raise RuntimeError, 'no proper affine matrix provided'
if matrix.shape[0] != input.ndim:
@@ -246,7 +246,7 @@
if not matrix.flags.contiguous:
matrix = matrix.copy()
offset = _ni_support._normalize_sequence(offset, input.ndim)
- offset = numarray.asarray(offset, dtype = numarray.float64)
+ offset = numpy.asarray(offset, dtype = numpy.float64)
if offset.ndim != 1 or offset.shape[0] < 1:
raise RuntimeError, 'no proper offset provided'
if not offset.flags.contiguous:
@@ -272,21 +272,21 @@
"""
if order < 0 or order > 5:
raise RuntimeError, 'spline order not supported'
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if input.ndim < 1:
raise RuntimeError, 'input and output rank must be > 0'
mode = _ni_support._extend_mode_to_code(mode)
if prefilter and order > 1:
- filtered = spline_filter(input, order, output = numarray.float64)
+ filtered = spline_filter(input, order, output = numpy.float64)
else:
filtered = input
output, return_value = _ni_support._get_output(output, input,
output_type)
shift = _ni_support._normalize_sequence(shift, input.ndim)
shift = [-ii for ii in shift]
- shift = numarray.asarray(shift, dtype = numarray.float64)
+ shift = numpy.asarray(shift, dtype = numpy.float64)
if not shift.flags.contiguous:
shift = shift.copy()
_nd_image.zoom_shift(filtered, None, shift, output, order, mode, cval)
@@ -305,14 +305,14 @@
"""
if order < 0 or order > 5:
raise RuntimeError, 'spline order not supported'
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if input.ndim < 1:
raise RuntimeError, 'input and output rank must be > 0'
mode = _ni_support._extend_mode_to_code(mode)
if prefilter and order > 1:
- filtered = spline_filter(input, order, output = numarray.float64)
+ filtered = spline_filter(input, order, output = numpy.float64)
else:
filtered = input
zoom = _ni_support._normalize_sequence(zoom, input.ndim)
@@ -320,7 +320,7 @@
zoom = [1.0 / ii for ii in zoom]
output, return_value = _ni_support._get_output(output, input,
output_type, shape = output_shape)
- zoom = numarray.asarray(zoom, dtype = numarray.float64)
+ zoom = numpy.asarray(zoom, dtype = numpy.float64)
if not zoom.flags.contiguous:
zoom = shift.copy()
_nd_image.zoom_shift(filtered, zoom, None, output, order, mode, cval)
@@ -351,7 +351,7 @@
filtered before interpolation, if False it is assumed that the input
is already filtered.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
axes = list(axes)
rank = input.ndim
if axes[0] < 0:
@@ -362,36 +362,36 @@
raise RuntimeError, 'invalid rotation plane specified'
if axes[0] > axes[1]:
axes = axes[1], axes[0]
- angle = numarray.pi / 180 * angle
+ angle = numpy.pi / 180 * angle
m11 = math.cos(angle)
m12 = math.sin(angle)
m21 = -math.sin(angle)
m22 = math.cos(angle)
- matrix = numarray.array([[m11, m12],
- [m21, m22]], dtype = numarray.float64)
+ matrix = numpy.array([[m11, m12],
+ [m21, m22]], dtype = numpy.float64)
iy = input.shape[axes[0]]
ix = input.shape[axes[1]]
if reshape:
- mtrx = numarray.array([[ m11, -m21],
- [-m12, m22]], dtype = numarray.float64)
+ mtrx = numpy.array([[ m11, -m21],
+ [-m12, m22]], dtype = numpy.float64)
minc = [0, 0]
maxc = [0, 0]
- coor = numarray.dot(mtrx, [0, ix])
+ coor = numpy.dot(mtrx, [0, ix])
minc, maxc = _minmax(coor, minc, maxc)
- coor = numarray.dot(mtrx, [iy, 0])
+ coor = numpy.dot(mtrx, [iy, 0])
minc, maxc = _minmax(coor, minc, maxc)
- coor = numarray.dot(mtrx, [iy, ix])
+ coor = numpy.dot(mtrx, [iy, ix])
minc, maxc = _minmax(coor, minc, maxc)
oy = int(maxc[0] - minc[0] + 0.5)
ox = int(maxc[1] - minc[1] + 0.5)
else:
oy = input.shape[axes[0]]
ox = input.shape[axes[1]]
- offset = numarray.zeros((2,), dtype = numarray.float64)
+ offset = numpy.zeros((2,), dtype = numpy.float64)
offset[0] = float(oy) / 2.0 - 0.5
offset[1] = float(ox) / 2.0 - 0.5
- offset = numarray.dot(matrix, offset)
- tmp = numarray.zeros((2,), dtype = numarray.float64)
+ offset = numpy.dot(matrix, offset)
+ tmp = numpy.zeros((2,), dtype = numpy.float64)
tmp[0] = float(iy) / 2.0 - 0.5
tmp[1] = float(ix) / 2.0 - 0.5
offset = tmp - offset
@@ -406,7 +406,7 @@
order, mode, cval, prefilter)
else:
coordinates = []
- size = numarray.product(input.shape,axis=0)
+ size = numpy.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/measurements.py
===================================================================
--- trunk/Lib/ndimage/measurements.py 2006-09-24 08:28:59 UTC (rev 2231)
+++ trunk/Lib/ndimage/measurements.py 2006-09-24 09:05:13 UTC (rev 2232)
@@ -30,7 +30,6 @@
import types
import math
-import numpy.oldnumeric as numarray
import numpy
import _ni_support
import _nd_image
@@ -46,12 +45,12 @@
of objects found. If an output array is provided only the number of
objects found is returned.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if structure == None:
structure = morphology.generate_binary_structure(input.ndim, 1)
- structure = numarray.asarray(structure, dtype = bool)
+ structure = numpy.asarray(structure, dtype = bool)
if structure.ndim != input.ndim:
raise RuntimeError, 'structure and input must have equal rank'
for ii in structure.shape:
@@ -60,10 +59,10 @@
if not structure.flags.contiguous:
structure = structure.copy()
if isinstance(output, numpy.ndarray):
- if output.dtype.type != numarray.int32:
- raise RuntimeError, 'output type must be Int32'
+ if output.dtype.type != numpy.int32:
+ raise RuntimeError, 'output type must be int32'
else:
- output = numarray.Int32
+ output = numpy.int32
output, return_value = _ni_support._get_output(output, input)
max_label = _nd_image.label(input, structure, output)
if return_value == None:
@@ -81,8 +80,8 @@
gives the largest object number that is searched for, otherwise
all are returned.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if max_label < 1:
max_label = input.max()
@@ -95,11 +94,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -114,11 +113,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -133,11 +132,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -166,11 +165,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -185,11 +184,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -201,7 +200,7 @@
"""Convert a linear index to a position"""
if len(shape) > 0:
pos = []
- stride = numarray.multiply.reduce(shape)
+ stride = numpy.multiply.reduce(shape)
for size in shape:
stride = stride // size
pos.append(index // stride)
@@ -218,11 +217,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -241,11 +240,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -265,11 +264,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -293,11 +292,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -315,11 +314,11 @@
label numbers of the objects to be measured. If index is None, all
values are used where labels is larger than zero.
"""
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if labels != None:
- labels = numarray.asarray(labels)
+ labels = numpy.asarray(labels)
labels = _broadcast(labels, input.shape)
if labels.shape != input.shape:
@@ -340,12 +339,12 @@
provided an element is generated iwth a squared connecitiviy equal
to one. An output array can optionally be provided.
"""
- input = numarray.asarray(input)
- if input.dtype.type not in [numarray.uint8, numarray.uint16]:
+ input = numpy.asarray(input)
+ if input.dtype.type not in [numpy.uint8, numpy.uint16]:
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 = bool)
+ structure = numpy.asarray(structure, dtype = bool)
if structure.ndim != input.ndim:
raise RuntimeError, 'structure and input must have equal rank'
for ii in structure.shape:
@@ -353,7 +352,7 @@
raise RuntimeError, 'structure dimensions must be equal to 3'
if not structure.flags.contiguous:
structure = structure.copy()
- markers = numarray.asarray(markers)
+ markers = numpy.asarray(markers)
if input.shape != markers.shape:
raise RuntimeError, 'input and markers must have equal shape'
@@ -380,7 +379,7 @@
def _broadcast(arr, sshape):
"""Return broadcast view of arr, else return None."""
ashape = arr.shape
- return_value = numarray.zeros(sshape, arr.dtype)
+ return_value = numpy.zeros(sshape, arr.dtype)
# Just return arr if they have the same shape
if sshape == ashape:
return arr
Modified: trunk/Lib/ndimage/morphology.py
===================================================================
--- trunk/Lib/ndimage/morphology.py 2006-09-24 08:28:59 UTC (rev 2231)
+++ trunk/Lib/ndimage/morphology.py 2006-09-24 09:05:13 UTC (rev 2232)
@@ -28,7 +28,6 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import numpy.oldnumeric as numarray
import numpy
import _ni_support
import _nd_image
@@ -37,7 +36,7 @@
def _center_is_true(structure, origin):
- structure = numarray.array(structure)
+ structure = numpy.array(structure)
coor = tuple([oo + ss // 2 for ss, oo in zip(structure.shape,
origin)])
return bool(structure[coor])
@@ -49,7 +48,7 @@
not, a tuple of the iterated structure and the modified origin is
returned.
"""
- structure = numarray.asarray(structure)
+ structure = numpy.asarray(structure)
if iterations < 2:
return structure.copy()
ni = iterations - 1
@@ -57,7 +56,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, bool)
+ out = numpy.zeros(shape, bool)
out[slc] = structure != 0
out = binary_dilation(out, structure, iterations = ni)
if origin is None:
@@ -77,39 +76,39 @@
connectivity = 1
if rank < 1:
if connectivity < 1:
- return numarray.array(0, dtype = bool)
+ return numpy.array(0, dtype = bool)
else:
- 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 = bool)
+ return numpy.array(1, dtype = bool)
+ output = numpy.zeros([3] * rank, bool)
+ output = numpy.fabs(numpy.indices([3] * rank) - 1)
+ output = numpy.add.reduce(output, 0)
+ return numpy.asarray(output <= connectivity, dtype = bool)
def _binary_erosion(input, structure, iterations, mask, output,
border_value, origin, invert, brute_force):
- input = numarray.asarray(input)
- if numarray.iscomplexobj(input):
+ input = numpy.asarray(input)
+ if numpy.iscomplexobj(input):
raise TypeError, 'Complex type not supported'
if structure is None:
structure = generate_binary_structure(input.ndim, 1)
else:
- structure = numarray.asarray(structure)
+ structure = numpy.asarray(structure)
structure = structure.astype(bool)
if structure.ndim != input.ndim:
raise RuntimeError, 'structure rank must equal input rank'
if not structure.flags.contiguous:
structure = structure.copy()
- if numarray.product(structure.shape,axis=0) < 1:
+ if numpy.product(structure.shape,axis=0) < 1:
raise RuntimeError, 'structure must not be empty'
if mask is not None:
- mask = numarray.asarray(mask)
+ mask = numpy.asarray(mask)
if mask.shape != input.shape:
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, numpy.ndarray):
- if numarray.iscomplexobj(output):
+ if numpy.iscomplexobj(output):
raise TypeError, 'Complex output type not supported'
else:
output = bool
@@ -130,8 +129,8 @@
if not structure.shape[ii] & 1:
origin[ii] -= 1
if mask != None:
- msk = numarray.asarray(mask)
- msk = mask.astype(numarray.Int8)
+ msk = numpy.asarray(mask)
+ msk = mask.astype(numpy.int8)
if msk is mask:
msk = mask.copy()
mask = msk
@@ -141,11 +140,11 @@
origin, invert, coordinate_list)
return return_value
else:
- tmp_in = numarray.zeros(input.shape, bool)
+ tmp_in = numpy.zeros(input.shape, bool)
if return_value == None:
tmp_out = output
else:
- tmp_out = numarray.zeros(input.shape, bool)
+ tmp_out = numpy.zeros(input.shape, bool)
if not iterations & 1:
tmp_in, tmp_out = tmp_out, tmp_in
changed = _nd_image.binary_erosion(input, structure, mask,
@@ -190,11 +189,11 @@
elements with a true value at the corresponding mask element are
modified at each iteration.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
if structure == None:
structure = generate_binary_structure(input.ndim, 1)
origin = _ni_support._normalize_sequence(origin, input.ndim)
- structure = numarray.asarray(structure)
+ structure = numpy.asarray(structure)
structure = structure[tuple([slice(None, None, -1)] *
structure.ndim)]
for ii in range(len(origin)):
@@ -215,7 +214,7 @@
to one. The iterations parameter gives the number of times the
erosions and then the dilations are done.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
if structure is None:
rank = input.ndim
structure = generate_binary_structure(rank, 1)
@@ -235,7 +234,7 @@
to one. The iterations parameter gives the number of times the
dilations and then the erosions are done.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
if structure is None:
rank = input.ndim
structure = generate_binary_structure(rank, 1)
@@ -257,11 +256,11 @@
element. If the origin for the second structure is equal to None
it is set equal to the origin of the first.
"""
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
if structure1 is None:
structure1 = generate_binary_structure(input.ndim, 1)
if structure2 is None:
- structure2 = numarray.logical_not(structure1)
+ structure2 = numpy.logical_not(structure1)
origin1 = _ni_support._normalize_sequence(origin1, input.ndim)
if origin2 is None:
origin2 = origin1
@@ -274,11 +273,11 @@
result = _binary_erosion(input, structure2, 1, None, output, 0,
origin2, 1, False)
if inplace:
- numarray.logical_not(output, output)
- numarray.logical_and(tmp1, output, output)
+ numpy.logical_not(output, output)
+ numpy.logical_and(tmp1, output, output)
else:
- numarray.logical_not(result, result)
- return numarray.logical_and(tmp1, result)
+ numpy.logical_not(result, result)
+ return numpy.logical_and(tmp1, result)
def binary_propagation(input, structure = None, mask = None,
output = None, border_value = 0, origin = 0):
@@ -305,16 +304,16 @@
provided an element is generated with a squared connectivity equal
to one.
"""
- mask = numarray.logical_not(input)
- tmp = numarray.zeros(mask.shape, bool)
+ mask = numpy.logical_not(input)
+ tmp = numpy.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)
+ numpy.logical_not(output, output)
else:
output = binary_dilation(tmp, structure, -1, mask, None, 1,
origin)
- numarray.logical_not(output, output)
+ numpy.logical_not(output, output)
return output
def grey_erosion(input, size = None, footprint = None, structure = None,
@@ -342,14 +341,14 @@
value when mode is equal to 'constant'.
"""
if structure is not None:
- structure = numarray.asarray(structure)
+ structure = numpy.asarray(structure)
structure = structure[tuple([slice(None, None, -1)] *
structure.ndim)]
if footprint is not None:
- footprint = numarray.asarray(footprint)
+ footprint = numpy.asarray(footprint)
footprint = footprint[tuple([slice(None, None, -1)] *
footprint.ndim)]
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
origin = _ni_support._normalize_sequence(origin, input.ndim)
for ii in range(len(origin)):
origin[ii] = -origin[ii]
@@ -411,7 +410,7 @@
if isinstance(output, numpy.ndarray):
grey_erosion(input, size, footprint, structure, output, mode,
cval, origin)
- return numarray.subtract(tmp, output, output)
+ return numpy.subtract(tmp, output, output)
else:
return (tmp - grey_erosion(input, size, footprint, structure,
None, mode, cval, origin))
@@ -433,17 +432,17 @@
if isinstance(output, numpy.ndarray):
grey_erosion(input, size, footprint, structure, output, mode,
cval, origin)
- numarray.add(tmp1, output, output)
+ numpy.add(tmp1, output, output)
del tmp1
- numarray.subtract(output, input, output)
- return numarray.subtract(output, input, output)
+ numpy.subtract(output, input, output)
+ return numpy.subtract(output, input, output)
else:
tmp2 = grey_erosion(input, size, footprint, structure, None, mode,
cval, origin)
- numarray.add(tmp1, tmp2, tmp2)
+ numpy.add(tmp1, tmp2, tmp2)
del tmp1
- numarray.subtract(tmp2, input, tmp2)
- numarray.subtract(tmp2, input, tmp2)
+ numpy.subtract(tmp2, input, tmp2)
+ numpy.subtract(tmp2, input, tmp2)
return tmp2
@@ -463,7 +462,7 @@
grey_dilation(tmp, size, footprint, structure, output, mode, cval,
origin)
del tmp
- return numarray.subtract(input, output, output)
+ return numpy.subtract(input, output, output)
else:
tmp = grey_dilation(tmp, size, footprint, structure, None, mode,
cval, origin)
@@ -487,7 +486,7 @@
grey_erosion(tmp, size, footprint, structure, output, mode, cval,
origin)
del tmp
- return numarray.subtract(output, input, output)
+ return numpy.subtract(output, input, output)
else:
tmp = grey_erosion(tmp, size, footprint, structure, None, mode,
cval, origin)
@@ -524,17 +523,17 @@
chessboard algorithms.
the distances and indices arguments can be used to give optional
- output arrays that must be of the correct size and type (Float64
- and Int32).
+ output arrays that must be of the correct size and type (float64
+ and int32).
"""
if (not return_distances) and (not return_indices):
msg = 'at least one of distances/indices must be specified'
raise RuntimeError, msg
- tmp1 = numarray.asarray(input) != 0
+ tmp1 = numpy.asarray(input) != 0
struct = generate_binary_structure(tmp1.ndim, tmp1.ndim)
tmp2 = binary_dilation(tmp1, struct)
- tmp2 = numarray.logical_xor(tmp1, tmp2)
- tmp1 = tmp1.astype(numarray.Int8) - tmp2.astype(numarray.Int8)
+ tmp2 = numpy.logical_xor(tmp1, tmp2)
+ tmp1 = tmp1.astype(numpy.int8) - tmp2.astype(numpy.int8)
del tmp2
metric = metric.lower()
if metric == 'euclidean':
@@ -547,44 +546,44 @@
raise RuntimeError, 'distance metric not supported'
if sampling != None:
sampling = _ni_support._normalize_sequence(sampling, tmp1.ndim)
- sampling = numarray.asarray(sampling, dtype = numarray.Float64)
+ sampling = numpy.asarray(sampling, dtype = numpy.float64)
if not sampling.flags.contiguous:
sampling = sampling.copy()
if return_indices:
- ft = numarray.zeros(tmp1.shape, dtype = numarray.Int32)
+ ft = numpy.zeros(tmp1.shape, dtype = numpy.int32)
else:
ft = None
if return_distances:
if distances == None:
if metric == 1:
- dt = numarray.zeros(tmp1.shape, dtype = numarray.Float64)
+ dt = numpy.zeros(tmp1.shape, dtype = numpy.float64)
else:
- dt = numarray.zeros(tmp1.shape, dtype = numarray.UInt32)
+ dt = numpy.zeros(tmp1.shape, dtype = numpy.uint32)
else:
if distances.shape != tmp1.shape:
raise RuntimeError, 'distances array has wrong shape'
if metric == 1:
- if distances.dtype.type != numarray.float64:
- raise RuntimeError, 'distances array must be Float64'
+ if distances.dtype.type != numpy.float64:
+ raise RuntimeError, 'distances array must be float64'
else:
- if distances.dtype.type != numarray.uint32:
- raise RuntimeError, 'distances array must be UInt32'
+ if distances.dtype.type != numpy.uint32:
+ raise RuntimeError, 'distances array must be uint32'
dt = distances
else:
dt = None
_nd_image.distance_transform_bf(tmp1, metric, sampling, dt, ft)
if return_indices:
if isinstance(indices, numpy.ndarray):
- if indices.dtype.type != numarray.int32:
- raise RuntimeError, 'indices must of Int32 type'
+ if indices.dtype.type != numpy.int32:
+ raise RuntimeError, 'indices must of int32 type'
if indices.shape != (tmp1.ndim,) + tmp1.shape:
raise RuntimeError, 'indices has wrong shape'
tmp2 = indices
else:
- tmp2 = numarray.indices(tmp1.shape, dtype = numarray.Int32)
- ft = numarray.ravel(ft)
+ tmp2 = numpy.indices(tmp1.shape, dtype = numpy.int32)
+ ft = numpy.ravel(ft)
for ii in range(tmp2.shape[0]):
- rtmp = numarray.ravel(tmp2[ii, ...])[ft]
+ rtmp = numpy.ravel(tmp2[ii, ...])[ft]
rtmp.shape = tmp1.shape
tmp2[ii, ...] = rtmp
ft = tmp2
@@ -624,14 +623,14 @@
must be returned.
The distances and indices arguments can be used to give optional
- output arrays that must be of the correct size and type (both Int32).
+ output arrays that must be of the correct size and type (both int32).
"""
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, numpy.ndarray)
dt_inplace = isinstance(distances, numpy.ndarray)
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
if structure == 'cityblock':
rank = input.ndim
structure = generate_binary_structure(rank, 1)
@@ -640,7 +639,7 @@
structure = generate_binary_structure(rank, rank)
else:
try:
- structure = numarray.asarray(structure)
+ structure = numpy.asarray(structure)
except:
raise RuntimeError, 'invalid structure provided'
for s in structure.shape:
@@ -649,18 +648,18 @@
if not structure.flags.contiguous:
structure = structure.copy()
if dt_inplace:
- if distances.dtype.type != numarray.int32:
- raise RuntimeError, 'distances must be of Int32 type'
+ if distances.dtype.type != numpy.int32:
+ raise RuntimeError, 'distances must be of int32 type'
if distances.shape != input.shape:
raise RuntimeError, 'distances has wrong shape'
dt = distances
- dt[...] = numarray.where(input, -1, 0).astype(numarray.Int32)
+ dt[...] = numpy.where(input, -1, 0).astype(numpy.int32)
else:
- dt = numarray.where(input, -1, 0).astype(numarray.Int32)
+ dt = numpy.where(input, -1, 0).astype(numpy.int32)
rank = dt.ndim
if return_indices:
- sz = numarray.product(dt.shape,axis=0)
- ft = numarray.arange(sz, dtype = numarray.Int32)
+ sz = numpy.product(dt.shape,axis=0)
+ ft = numpy.arange(sz, dtype = numpy.int32)
ft.shape = dt.shape
else:
ft = None
@@ -672,17 +671,17 @@
dt = dt[tuple([slice(None, None, -1)] * rank)]
if return_indices:
ft = ft[tuple([slice(None, None, -1)] * rank)]
- ft = numarray.ravel(ft)
+ ft = numpy.ravel(ft)
if ft_inplace:
- if indices.dtype.type != numarray.int32:
- raise RuntimeError, 'indices must of Int32 type'
+ if indices.dtype.type != numpy.int32:
+ raise RuntimeError, 'indices must of int32 type'
if indices.shape != (dt.ndim,) + dt.shape:
raise RuntimeError, 'indices has wrong shape'
tmp = indices
else:
- tmp = numarray.indices(dt.shape, dtype = numarray.Int32)
+ tmp = numpy.indices(dt.shape, dtype = numpy.int32)
for ii in range(tmp.shape[0]):
- rtmp = numarray.ravel(tmp[ii, ...])[ft]
+ rtmp = numpy.ravel(tmp[ii, ...])[ft]
rtmp.shape = dt.shape
tmp[ii, ...] = rtmp
ft = tmp
@@ -720,8 +719,8 @@
to be equal along all axes.
the distances and indices arguments can be used to give optional
- output arrays that must be of the correct size and type (Float64
- and Int32).
+ output arrays that must be of the correct size and type (float64
+ and int32).
"""
if (not return_distances) and (not return_indices):
msg = 'at least one of distances/indices must be specified'
@@ -729,41 +728,41 @@
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)
+ input = numpy.where(input, 1, 0).astype(numpy.int8)
if sampling is not None:
sampling = _ni_support._normalize_sequence(sampling, input.ndim)
- sampling = numarray.asarray(sampling, dtype = numarray.Float64)
+ sampling = numpy.asarray(sampling, dtype = numpy.float64)
if not sampling.flags.contiguous:
sampling = sampling.copy()
if ft_inplace:
ft = indices
if ft.shape != (input.ndim,) + input.shape:
raise RuntimeError, 'indices has wrong shape'
- if ft.dtype.type != numarray.int32:
- raise RuntimeError, 'indices must be of Int32 type'
+ if ft.dtype.type != numpy.int32:
+ raise RuntimeError, 'indices must be of int32 type'
else:
- ft = numarray.zeros((input.ndim,) + input.shape,
- dtype = numarray.Int32)
+ ft = numpy.zeros((input.ndim,) + input.shape,
+ dtype = numpy.int32)
_nd_image.euclidean_feature_transform(input, sampling, ft)
# if requested, calculate the distance transform
if return_distances:
- dt = ft - numarray.indices(input.shape, dtype = ft.dtype)
- dt = dt.astype(numarray.Float64)
+ dt = ft - numpy.indices(input.shape, dtype = ft.dtype)
+ dt = dt.astype(numpy.float64)
if sampling is not None:
for ii in range(len(sampling)):
dt[ii, ...] *= sampling[ii]
- numarray.multiply(dt, dt, dt)
+ numpy.multiply(dt, dt, dt)
if dt_inplace:
- dt = numarray.add.reduce(dt, axis = 0)
+ dt = numpy.add.reduce(dt, axis = 0)
if distances.shape != dt.shape:
raise RuntimeError, 'indices has wrong shape'
- if distances.dtype.type != numarray.float64:
- raise RuntimeError, 'indices must be of Float64 type'
- numarray.sqrt(dt, distances)
+ if distances.dtype.type != numpy.float64:
+ raise RuntimeError, 'indices must be of float64 type'
+ numpy.sqrt(dt, distances)
del dt
else:
- dt = numarray.add.reduce(dt, axis = 0)
- dt = numarray.sqrt(dt)
+ dt = numpy.add.reduce(dt, axis = 0)
+ dt = numpy.sqrt(dt)
# construct and return the result
result = []
if return_distances and not dt_inplace:
Modified: trunk/Lib/ndimage/tests/test_ndimage.py
===================================================================
--- trunk/Lib/ndimage/tests/test_ndimage.py 2006-09-24 08:28:59 UTC (rev 2231)
+++ trunk/Lib/ndimage/tests/test_ndimage.py 2006-09-24 09:05:13 UTC (rev 2232)
@@ -31,7 +31,6 @@
import sys
import unittest
import math
-import numpy.oldnumeric as numarray
import numpy
from numpy import fft
from numpy.testing import *
@@ -44,21 +43,21 @@
def diff(a, b):
if not isinstance(a, numpy.ndarray):
- a = numarray.asarray(a)
+ a = numpy.asarray(a)
if not isinstance(b, numpy.ndarray):
- b = numarray.asarray(b)
+ b = numpy.asarray(b)
if (0 in a.shape) and (0 in b.shape):
return 0.0
- if (a.dtype in [numarray.complex64, numarray.complex128] or
- b.dtype in [numarray.complex64, numarray.complex128]):
- a = numarray.asarray(a, numarray.complex128)
- b = numarray.asarray(b, numarray.complex128)
+ if (a.dtype in [numpy.complex64, numpy.complex128] or
+ b.dtype in [numpy.complex64, numpy.complex128]):
+ a = numpy.asarray(a, numpy.complex128)
+ b = numpy.asarray(b, numpy.complex128)
t = ((a.real - b.real)**2).sum() + ((a.imag - b.imag)**2).sum()
else:
- a = numarray.asarray(a)
- a = a.astype(numarray.float64)
- b = numarray.asarray(b)
- b = b.astype(numarray.float64)
+ a = numpy.asarray(a)
+ a = a.astype(numpy.float64)
+ b = numpy.asarray(b)
+ b = b.astype(numpy.float64)
t = ((a - b)**2).sum()
return math.sqrt(t)
@@ -67,20 +66,20 @@
def setUp(self):
# list of numarray data types
- self.types = [numarray.int8, numarray.uint8, numarray.int16,
- numarray.uint16, numarray.int32, numarray.uint32,
- numarray.int64, numarray.uint64,
- numarray.float32, numarray.float64]
+ self.types = [numpy.int8, numpy.uint8, numpy.int16,
+ numpy.uint16, numpy.int32, numpy.uint32,
+ numpy.int64, numpy.uint64,
+ numpy.float32, numpy.float64]
## if numinclude.hasUInt64:
-## self.types.append(numarray.UInt64)
+## self.types.append(numpy.UInt64)
# list of boundary modes:
self.modes = ['nearest', 'wrap', 'reflect', 'constant']
def test_correlate01(self):
"correlation 1"
- array = numarray.array([1, 2])
- weights = numarray.array([2])
+ array = numpy.array([1, 2])
+ weights = numpy.array([2])
true = [2, 4]
output = ndimage.correlate(array, weights)
self.failUnless(diff(output, true) < eps)
@@ -93,8 +92,8 @@
def test_correlate02(self):
"correlation 2"
- array = numarray.array([1, 2, 3])
- kernel = numarray.array([1])
+ array = numpy.array([1, 2, 3])
+ kernel = numpy.array([1])
output = ndimage.correlate(array, kernel)
self.failUnless(diff(array, output) < eps)
output = ndimage.convolve(array, kernel)
@@ -106,8 +105,8 @@
def test_correlate03(self):
"correlation 3"
- array = numarray.array([1])
- weights = numarray.array([1, 1])
+ array = numpy.array([1])
+ weights = numpy.array([1, 1])
true = [2]
output = ndimage.correlate(array, weights)
self.failUnless(diff(output, true) < eps)
@@ -120,10 +119,10 @@
def test_correlate04(self):
"correlation 4"
- array = numarray.array([1, 2])
+ array = numpy.array([1, 2])
tcor = [2, 3]
tcov = [3, 4]
- weights = numarray.array([1, 1])
+ weights = numpy.array([1, 1])
output = ndimage.correlate(array, weights)
self.failUnless(diff(output, tcor) < eps)
output = ndimage.convolve(array, weights)
@@ -135,10 +134,10 @@
def test_correlate05(self):
"correlation 5"
- array = numarray.array([1, 2, 3])
+ array = numpy.array([1, 2, 3])
tcor = [2, 3, 5]
tcov = [3, 5, 6]
- kernel = numarray.array([1, 1])
+ kernel = numpy.array([1, 1])
output = ndimage.correlate(array, kernel)
self.failUnless(diff(tcor, output) < eps)
output = ndimage.convolve(array, kernel)
@@ -150,10 +149,10 @@
def test_correlate06(self):
"correlation 6"
- array = numarray.array([1, 2, 3])
+ array = numpy.array([1, 2, 3])
tcor = [9, 14, 17]
tcov = [7, 10, 15]
- weights = numarray.array([1, 2, 3])
+ weights = numpy.array([1, 2, 3])
output = ndimage.correlate(array, weights)
self.failUnless(diff(output, tcor) < eps)
output = ndimage.convolve(array, weights)
@@ -165,9 +164,9 @@
def test_correlate07(self):
"correlation 7"
- array = numarray.array([1, 2, 3])
+ array = numpy.array([1, 2, 3])
true = [5, 8, 11]
- weights = numarray.array([1, 2, 1])
+ weights = numpy.array([1, 2, 1])
output = ndimage.correlate(array, weights)
self.failUnless(diff(output, true) < eps)
output = ndimage.convolve(array, weights)
@@ -179,10 +178,10 @@
def test_correlate08(self):
"correlation 8"
- array = numarray.array([1, 2, 3])
+ array = numpy.array([1, 2, 3])
tcor = [1, 2, 5]
tcov = [3, 6, 7]
- weights = numarray.array([1, 2, -1])
+ weights = numpy.array([1, 2, -1])
output = ndimage.correlate(array, weights)
self.failUnless(diff(output, tcor) < eps)
output = ndimage.convolve(array, weights)
@@ -195,7 +194,7 @@
def test_correlate09(self):
"correlation 9"
array = []
- kernel = numarray.array([1, 1])
+ kernel = numpy.array([1, 1])
output = ndimage.correlate(array, kernel)
self.failUnless(diff(array, output) < eps)
output = ndimage.convolve(array, kernel)
@@ -208,7 +207,7 @@
def test_correlate10(self):
"correlation 10"
array = [[]]
- kernel = numarray.array([[1, 1]])
+ kernel = numpy.array([[1, 1]])
output = ndimage.correlate(array, kernel)
self.failUnless(diff(array, output) < eps)
output = ndimage.convolve(array, kernel)
@@ -216,9 +215,9 @@
def test_correlate11(self):
"correlation 11"
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]])
- kernel = numarray.array([[1, 1],
+ kernel = numpy.array([[1, 1],
[1, 1]])
output = ndimage.correlate(array, kernel)
self.failUnless(diff([[4, 6, 10], [10, 12, 16]], output) < eps)
@@ -227,9 +226,9 @@
def test_correlate12(self):
"correlation 12"
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]])
- kernel = numarray.array([[1, 0],
+ kernel = numpy.array([[1, 0],
[0, 1]])
output = ndimage.correlate(array, kernel)
self.failUnless(diff([[2, 3, 5], [5, 6, 8]], output) < eps)
@@ -238,10 +237,10 @@
def test_correlate13(self):
"correlation 13"
- kernel = numarray.array([[1, 0],
+ kernel = numpy.array([[1, 0],
[0, 1]])
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]], type1)
for type2 in self.types:
output = ndimage.correlate(array, kernel,
@@ -255,13 +254,13 @@
def test_correlate14(self):
"correlation 14"
- kernel = numarray.array([[1, 0],
+ kernel = numpy.array([[1, 0],
[0, 1]])
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]], type1)
for type2 in self.types:
- output = numarray.zeros(array.shape, type2)
+ output = numpy.zeros(array.shape, type2)
ndimage.correlate(array, kernel,
output = output)
error = diff([[2, 3, 5], [5, 6, 8]], output)
@@ -272,46 +271,46 @@
def test_correlate15(self):
"correlation 15"
- kernel = numarray.array([[1, 0],
+ kernel = numpy.array([[1, 0],
[0, 1]])
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]], type1)
output = ndimage.correlate(array, kernel,
- output = numarray.float32)
+ output = numpy.float32)
error = diff([[2, 3, 5], [5, 6, 8]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
output = ndimage.convolve(array, kernel,
- output = numarray.float32)
+ output = numpy.float32)
error = diff([[6, 8, 9], [9, 11, 12]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
def test_correlate16(self):
"correlation 16"
- kernel = numarray.array([[0.5, 0 ],
+ kernel = numpy.array([[0.5, 0 ],
[0, 0.5]])
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]], type1)
output = ndimage.correlate(array, kernel,
- output = numarray.float32)
+ output = numpy.float32)
error = diff([[1, 1.5, 2.5], [2.5, 3, 4]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
output = ndimage.convolve(array, kernel,
- output = numarray.float32)
+ output = numpy.float32)
error = diff([[3, 4, 4.5], [4.5, 5.5, 6]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
def test_correlate17(self):
"correlation 17"
- array = numarray.array([1, 2, 3])
+ array = numpy.array([1, 2, 3])
tcor = [3, 5, 6]
tcov = [2, 3, 5]
- kernel = numarray.array([1, 1])
+ kernel = numpy.array([1, 1])
output = ndimage.correlate(array, kernel, origin = -1)
self.failUnless(diff(tcor, output) < eps)
output = ndimage.convolve(array, kernel, origin = -1)
@@ -323,52 +322,52 @@
def test_correlate18(self):
"correlation 18"
- kernel = numarray.array([[1, 0],
+ kernel = numpy.array([[1, 0],
[0, 1]])
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]], type1)
output = ndimage.correlate(array, kernel,
- output = numarray.float32,
+ output = numpy.float32,
mode = 'nearest', origin = -1)
error = diff([[6, 8, 9], [9, 11, 12]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
output = ndimage.convolve(array, kernel,
- output = numarray.float32, mode = 'nearest', origin = -1)
+ output = numpy.float32, mode = 'nearest', origin = -1)
error = diff([[2, 3, 5], [5, 6, 8]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
def test_correlate19(self):
"correlation 19"
- kernel = numarray.array([[1, 0],
+ kernel = numpy.array([[1, 0],
[0, 1]])
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6]], type1)
output = ndimage.correlate(array, kernel,
- output = numarray.float32,
+ output = numpy.float32,
mode = 'nearest', origin = [-1, 0])
error = diff([[5, 6, 8], [8, 9, 11]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
output = ndimage.convolve(array, kernel,
- output = numarray.float32,
+ output = numpy.float32,
mode = 'nearest', origin = [-1, 0])
error = diff([[3, 5, 6], [6, 8, 9]], output)
self.failUnless(error < eps and
- output.dtype.type == numarray.float32)
+ output.dtype.type == numpy.float32)
def test_correlate20(self):
"correlation 20"
- weights = numarray.array([1, 2, 1])
+ weights = numpy.array([1, 2, 1])
true = [[5, 10, 15], [7, 14, 21]]
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
- output = numarray.zeros((2, 3), type2)
+ output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis = 0,
output = output)
self.failUnless(diff(output, true) < eps)
@@ -378,10 +377,10 @@
def test_correlate21(self):
"correlation 21"
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[2, 4, 6]])
true = [[5, 10, 15], [7, 14, 21]]
- weights = numarray.array([1, 2, 1])
+ weights = numpy.array([1, 2, 1])
output = ndimage.correlate1d(array, weights, axis = 0)
self.failUnless(diff(output, true) < eps)
output = ndimage.convolve1d(array, weights, axis = 0)
@@ -389,13 +388,13 @@
def test_correlate22(self):
"correlation 22"
- weights = numarray.array([1, 2, 1])
+ weights = numpy.array([1, 2, 1])
true = [[6, 12, 18], [6, 12, 18]]
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
- output = numarray.zeros((2, 3), type2)
+ output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis = 0,
mode = 'wrap', output = output)
self.failUnless(diff(output, true) < eps)
@@ -405,13 +404,13 @@
def test_correlate23(self):
"correlation 23"
- weights = numarray.array([1, 2, 1])
+ weights = numpy.array([1, 2, 1])
true = [[5, 10, 15], [7, 14, 21]]
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
- output = numarray.zeros((2, 3), type2)
+ output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis = 0,
mode = 'nearest', output = output)
self.failUnless(diff(output, true) < eps)
@@ -421,14 +420,14 @@
def test_correlate24(self):
"correlation 24"
- weights = numarray.array([1, 2, 1])
+ weights = numpy.array([1, 2, 1])
tcor = [[7, 14, 21], [8, 16, 24]]
tcov = [[4, 8, 12], [5, 10, 15]]
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
- output = numarray.zeros((2, 3), type2)
+ output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis = 0,
mode = 'nearest', output = output, origin = -1)
self.failUnless(diff(output, tcor) < eps)
@@ -438,14 +437,14 @@
def test_correlate25(self):
"correlation 25"
- weights = numarray.array([1, 2, 1])
+ weights = numpy.array([1, 2, 1])
tcor = [[4, 8, 12], [5, 10, 15]]
tcov = [[7, 14, 21], [8, 16, 24]]
for type1 in self.types:
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
- output = numarray.zeros((2, 3), type2)
+ output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis = 0,
mode = 'nearest', output = output, origin = 1)
self.failUnless(diff(output, tcor) < eps)
@@ -455,22 +454,22 @@
def test_gauss01(self):
"gaussian filter 1"
- input = numarray.array([[1, 2, 3],
- [2, 4, 6]], numarray.float32)
+ input = numpy.array([[1, 2, 3],
+ [2, 4, 6]], numpy.float32)
output = ndimage.gaussian_filter(input, 0)
self.failUnless(diff(output, input) < eps)
def test_gauss02(self):
"gaussian filter 2"
- input = numarray.array([[1, 2, 3],
- [2, 4, 6]], numarray.float32)
+ input = numpy.array([[1, 2, 3],
+ [2, 4, 6]], numpy.float32)
output = ndimage.gaussian_filter(input, 1.0)
self.failUnless(input.dtype == output.dtype and
input.shape == output.shape)
def test_gauss03(self):
"gaussian filter 3"
- input = numarray.arange(100 * 100).astype(numarray.float32)
+ input = numpy.arange(100 * 100).astype(numpy.float32)
input.shape = (100, 100)
output = ndimage.gaussian_filter(input, [1.0, 1.0])
@@ -481,31 +480,31 @@
def test_gauss04(self):
"gaussian filter 4"
- input = numarray.arange(100 * 100).astype(numarray.float32)
+ input = numpy.arange(100 * 100).astype(numpy.float32)
input.shape = (100, 100)
- otype = numarray.float64
+ otype = numpy.float64
output = ndimage.gaussian_filter(input, [1.0, 1.0],
output = otype)
- self.failUnless(output.dtype.type == numarray.float64 and
+ self.failUnless(output.dtype.type == numpy.float64 and
input.shape == output.shape and
diff(input, output) > 1.0)
def test_gauss05(self):
"gaussian filter 5"
- input = numarray.arange(100 * 100).astype(numarray.float32)
+ input = numpy.arange(100 * 100).astype(numpy.float32)
input.shape = (100, 100)
- otype = numarray.float64
+ otype = numpy.float64
output = ndimage.gaussian_filter(input, [1.0, 1.0],
order = 1, output = otype)
- self.failUnless(output.dtype.type == numarray.float64 and
+ self.failUnless(output.dtype.type == numpy.float64 and
input.shape == output.shape and
diff(input, output) > 1.0)
def test_gauss06(self):
"gaussian filter 6"
- input = numarray.arange(100 * 100).astype(numarray.float32)
+ input = numpy.arange(100 * 100).astype(numpy.float32)
input.shape = (100, 100)
- otype = numarray.float64
+ otype = numpy.float64
output1 = ndimage.gaussian_filter(input, [1.0, 1.0],
output = otype)
output2 = ndimage.gaussian_filter(input, 1.0,
@@ -515,7 +514,7 @@
def test_prewitt01(self):
"prewitt filter 1"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.correlate1d(array, [-1.0, 0.0, 1.0], 0)
@@ -527,19 +526,19 @@
def test_prewitt02(self):
"prewitt filter 2"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.correlate1d(array, [-1.0, 0.0, 1.0], 0)
t = ndimage.correlate1d(t, [1.0, 1.0, 1.0], 1)
- output = numarray.zeros(array.shape, type)
+ output = numpy.zeros(array.shape, type)
ndimage.prewitt(array, 0, output)
self.failUnless(diff(t, output) < eps)
def test_prewitt03(self):
"prewitt filter 3"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.correlate1d(array, [-1.0, 0.0, 1.0], 1)
@@ -550,7 +549,7 @@
def test_prewitt04(self):
"prewitt filter 4"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.prewitt(array, -1)
@@ -560,7 +559,7 @@
def test_sobel01(self):
"sobel filter 1"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.correlate1d(array, [-1.0, 0.0, 1.0], 0)
@@ -571,31 +570,31 @@
def test_sobel02(self):
"sobel filter 2"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.correlate1d(array, [-1.0, 0.0, 1.0], 0)
t = ndimage.correlate1d(t, [1.0, 2.0, 1.0], 1)
- output = numarray.zeros(array.shape, type)
+ output = numpy.zeros(array.shape, type)
ndimage.sobel(array, 0, output)
self.failUnless(diff(t, output) < eps)
def test_sobel03(self):
"sobel filter 3"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.correlate1d(array, [-1.0, 0.0, 1.0], 1)
t = ndimage.correlate1d(t, [1.0, 2.0, 1.0], 0)
- output = numarray.zeros(array.shape, type)
+ output = numpy.zeros(array.shape, type)
output = ndimage.sobel(array, 1)
self.failUnless(diff(t, output) < eps)
def test_sobel04(self):
"sobel filter 4"
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
t = ndimage.sobel(array, -1)
@@ -604,8 +603,8 @@
def test_laplace01(self):
"laplace filter 1"
- for type in [numarray.int32, numarray.float32, numarray.float64]:
- array = numarray.array([[3, 2, 5, 1, 4],
+ for type in [numpy.int32, numpy.float32, numpy.float64]:
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type) * 100
tmp1 = ndimage.correlate1d(array, [1, -2, 1], 0)
@@ -615,20 +614,20 @@
def test_laplace02(self):
"laplace filter 2"
- for type in [numarray.int32, numarray.float32, numarray.float64]:
- array = numarray.array([[3, 2, 5, 1, 4],
+ for type in [numpy.int32, numpy.float32, numpy.float64]:
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type) * 100
tmp1 = ndimage.correlate1d(array, [1, -2, 1], 0)
tmp2 = ndimage.correlate1d(array, [1, -2, 1], 1)
- output = numarray.zeros(array.shape, type)
+ output = numpy.zeros(array.shape, type)
ndimage.laplace(array, output = output)
self.failUnless(diff(tmp1 + tmp2, output) < eps)
def test_gaussian_laplace01(self):
"gaussian laplace filter 1"
- for type in [numarray.int32, numarray.float32, numarray.float64]:
- array = numarray.array([[3, 2, 5, 1, 4],
+ for type in [numpy.int32, numpy.float32, numpy.float64]:
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type) * 100
tmp1 = ndimage.gaussian_filter(array, 1.0, [2, 0])
@@ -638,13 +637,13 @@
def test_gaussian_laplace02(self):
"gaussian laplace filter 2"
- for type in [numarray.int32, numarray.float32, numarray.float64]:
- array = numarray.array([[3, 2, 5, 1, 4],
+ for type in [numpy.int32, numpy.float32, numpy.float64]:
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type) * 100
tmp1 = ndimage.gaussian_filter(array, 1.0, [2, 0])
tmp2 = ndimage.gaussian_filter(array, 1.0, [0, 2])
- output = numarray.zeros(array.shape, type)
+ output = numpy.zeros(array.shape, type)
ndimage.gaussian_laplace(array, 1.0, output)
self.failUnless(diff(tmp1 + tmp2, output) < eps)
@@ -652,16 +651,16 @@
"generic laplace filter 1"
def derivative2(input, axis, output, mode, cval, a, b):
sigma = [a, b / 2.0]
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
order = [0] * input.ndim
order[axis] = 2
return ndimage.gaussian_filter(input, sigma, order,
output, mode, cval)
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
- output = numarray.zeros(array.shape, type)
+ output = numpy.zeros(array.shape, type)
tmp = ndimage.generic_laplace(array, derivative2,
extra_arguments = (1.0,), extra_keywords = {'b': 2.0})
ndimage.gaussian_laplace(array, 1.0, output)
@@ -669,8 +668,8 @@
def test_gaussian_gradient_magnitude01(self):
"gaussian gradient magnitude filter 1"
- for type in [numarray.int32, numarray.float32, numarray.float64]:
- array = numarray.array([[3, 2, 5, 1, 4],
+ for type in [numpy.int32, numpy.float32, numpy.float64]:
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type) * 100
tmp1 = ndimage.gaussian_filter(array, 1.0, [1, 0])
@@ -678,32 +677,32 @@
output = ndimage.gaussian_gradient_magnitude(array,
1.0)
true = tmp1 * tmp1 + tmp2 * tmp2
- numarray.sqrt(true, true)
+ numpy.sqrt(true, true)
self.failUnless(diff(true, output) < eps)
def test_gaussian_gradient_magnitude02(self):
"gaussian gradient magnitude filter 2"
- for type in [numarray.int32, numarray.float32, numarray.float64]:
- array = numarray.array([[3, 2, 5, 1, 4],
+ for type in [numpy.int32, numpy.float32, numpy.float64]:
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type) * 100
tmp1 = ndimage.gaussian_filter(array, 1.0, [1, 0])
tmp2 = ndimage.gaussian_filter(array, 1.0, [0, 1])
- output = numarray.zeros(array.shape, type)
+ output = numpy.zeros(array.shape, type)
ndimage.gaussian_gradient_magnitude(array, 1.0,
output)
true = tmp1 * tmp1 + tmp2 * tmp2
- numarray.sqrt(true, true)
+ numpy.sqrt(true, true)
self.failUnless(diff(true, output) < eps)
def test_generic_gradient_magnitude01(self):
"generic gradient magnitude 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
- [5, 6, 9, 3, 5]], numarray.float64)
+ [5, 6, 9, 3, 5]], numpy.float64)
def derivative(input, axis, output, mode, cval, a, b):
sigma = [a, b / 2.0]
- input = numarray.asarray(input)
+ input = numpy.asarray(input)
order = [0] * input.ndim
order[axis] = 1
return ndimage.gaussian_filter(input, sigma, order,
@@ -716,7 +715,7 @@
def test_uniform01(self):
"uniform filter 1"
- array = numarray.array([2, 4, 6])
+ array = numpy.array([2, 4, 6])
size = 2
output = ndimage.uniform_filter1d(array, size,
origin = -1)
@@ -724,21 +723,21 @@
def test_uniform02(self):
"uniform filter 2"
- array = numarray.array([1, 2, 3])
+ array = numpy.array([1, 2, 3])
filter_shape = [0]
output = ndimage.uniform_filter(array, filter_shape)
self.failUnless(diff(array, output) < eps)
def test_uniform03(self):
"uniform filter 3"
- array = numarray.array([1, 2, 3])
+ array = numpy.array([1, 2, 3])
filter_shape = [1]
output = ndimage.uniform_filter(array, filter_shape)
self.failUnless(diff(array, output) < eps)
def test_uniform04(self):
"uniform filter 4"
- array = numarray.array([2, 4, 6])
+ array = numpy.array([2, 4, 6])
filter_shape = [2]
output = ndimage.uniform_filter(array, filter_shape)
self.failUnless(diff([2, 3, 5], output) < eps)
@@ -754,7 +753,7 @@
"uniform filter 6"
filter_shape = [2, 2]
for type1 in self.types:
- array = numarray.array([[4, 8, 12],
+ array = numpy.array([[4, 8, 12],
[16, 20, 24]], type1)
for type2 in self.types:
output = ndimage.uniform_filter(array,
@@ -764,38 +763,38 @@
def test_minimum_filter01(self):
"minimum filter 1"
- array = numarray.array([1, 2, 3, 4, 5])
- filter_shape = numarray.array([2])
+ array = numpy.array([1, 2, 3, 4, 5])
+ filter_shape = numpy.array([2])
output = ndimage.minimum_filter(array, filter_shape)
self.failUnless(diff([1, 1, 2, 3, 4], output) < eps)
def test_minimum_filter02(self):
"minimum filter 2"
- array = numarray.array([1, 2, 3, 4, 5])
- filter_shape = numarray.array([3])
+ array = numpy.array([1, 2, 3, 4, 5])
+ filter_shape = numpy.array([3])
output = ndimage.minimum_filter(array, filter_shape)
self.failUnless(diff([1, 1, 2, 3, 4], output) < eps)
def test_minimum_filter03(self):
"minimum filter 3"
- array = numarray.array([3, 2, 5, 1, 4])
- filter_shape = numarray.array([2])
+ array = numpy.array([3, 2, 5, 1, 4])
+ filter_shape = numpy.array([2])
output = ndimage.minimum_filter(array, filter_shape)
self.failUnless(diff([3, 2, 2, 1, 1], output) < eps)
def test_minimum_filter04(self):
"minimum filter 4"
- array = numarray.array([3, 2, 5, 1, 4])
- filter_shape = numarray.array([3])
+ array = numpy.array([3, 2, 5, 1, 4])
+ filter_shape = numpy.array([3])
output = ndimage.minimum_filter(array, filter_shape)
self.failUnless(diff([2, 2, 1, 1, 1], output) < eps)
def test_minimum_filter05(self):
"minimum filter 5"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
- filter_shape = numarray.array([2, 3])
+ filter_shape = numpy.array([2, 3])
output = ndimage.minimum_filter(array, filter_shape)
self.failUnless(diff([[2, 2, 1, 1, 1],
[2, 2, 1, 1, 1],
@@ -803,7 +802,7 @@
def test_minimum_filter06(self):
"minimum filter 6"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 1, 1], [1, 1, 1]]
@@ -815,7 +814,7 @@
def test_minimum_filter07(self):
"minimum filter 7"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -827,7 +826,7 @@
def test_minimum_filter08(self):
"minimum filter 8"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -839,7 +838,7 @@
def test_minimum_filter09(self):
"minimum filter 9"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -851,38 +850,38 @@
def test_maximum_filter01(self):
"maximum filter 1"
- array = numarray.array([1, 2, 3, 4, 5])
- filter_shape = numarray.array([2])
+ array = numpy.array([1, 2, 3, 4, 5])
+ filter_shape = numpy.array([2])
output = ndimage.maximum_filter(array, filter_shape)
self.failUnless(diff([1, 2, 3, 4, 5], output) < eps)
def test_maximum_filter02(self):
"maximum filter 2"
- array = numarray.array([1, 2, 3, 4, 5])
- filter_shape = numarray.array([3])
+ array = numpy.array([1, 2, 3, 4, 5])
+ filter_shape = numpy.array([3])
output = ndimage.maximum_filter(array, filter_shape)
self.failUnless(diff([2, 3, 4, 5, 5], output) < eps)
def test_maximum_filter03(self):
"maximum filter 3"
- array = numarray.array([3, 2, 5, 1, 4])
- filter_shape = numarray.array([2])
+ array = numpy.array([3, 2, 5, 1, 4])
+ filter_shape = numpy.array([2])
output = ndimage.maximum_filter(array, filter_shape)
self.failUnless(diff([3, 3, 5, 5, 4], output) < eps)
def test_maximum_filter04(self):
"maximum filter 4"
- array = numarray.array([3, 2, 5, 1, 4])
- filter_shape = numarray.array([3])
+ array = numpy.array([3, 2, 5, 1, 4])
+ filter_shape = numpy.array([3])
output = ndimage.maximum_filter(array, filter_shape)
self.failUnless(diff([3, 5, 5, 5, 4], output) < eps)
def test_maximum_filter05(self):
"maximum filter 5"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
- filter_shape = numarray.array([2, 3])
+ filter_shape = numpy.array([2, 3])
output = ndimage.maximum_filter(array, filter_shape)
self.failUnless(diff([[3, 5, 5, 5, 4],
[7, 9, 9, 9, 5],
@@ -890,7 +889,7 @@
def test_maximum_filter06(self):
"maximum filter 6"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 1, 1], [1, 1, 1]]
@@ -902,7 +901,7 @@
def test_maximum_filter07(self):
"maximum filter 7"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -914,7 +913,7 @@
def test_maximum_filter08(self):
"maximum filter 8"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -926,7 +925,7 @@
def test_maximum_filter09(self):
"maximum filter 9"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -938,7 +937,7 @@
def test_rank01(self):
"rank filter 1"
- array = numarray.array([1, 2, 3, 4, 5])
+ array = numpy.array([1, 2, 3, 4, 5])
output = ndimage.rank_filter(array, 1, size = 2)
self.failUnless(diff(array, output) < eps)
output = ndimage.percentile_filter(array, 100, size = 2)
@@ -948,7 +947,7 @@
def test_rank02(self):
"rank filter 2"
- array = numarray.array([1, 2, 3, 4, 5])
+ array = numpy.array([1, 2, 3, 4, 5])
output = ndimage.rank_filter(array, 1, size = [3])
self.failUnless(diff(array, output) < eps)
output = ndimage.percentile_filter(array, 50, size = 3)
@@ -958,7 +957,7 @@
def test_rank03(self):
"rank filter 3"
- array = numarray.array([3, 2, 5, 1, 4])
+ array = numpy.array([3, 2, 5, 1, 4])
output = ndimage.rank_filter(array, 1, size = [2])
self.failUnless(diff([3, 3, 5, 5, 4], output) < eps)
output = ndimage.percentile_filter(array, 100, size = 2)
@@ -966,7 +965,7 @@
def test_rank04(self):
"rank filter 4"
- array = numarray.array([3, 2, 5, 1, 4])
+ array = numpy.array([3, 2, 5, 1, 4])
true = [3, 3, 2, 4, 4]
output = ndimage.rank_filter(array, 1, size = 3)
self.failUnless(diff(true, output) < eps)
@@ -977,14 +976,14 @@
def test_rank05(self):
"rank filter 5"
- array = numarray.array([3, 2, 5, 1, 4])
+ array = numpy.array([3, 2, 5, 1, 4])
true = [3, 3, 2, 4, 4]
output = ndimage.rank_filter(array, -2, size = 3)
self.failUnless(diff(true, output) < eps)
def test_rank06(self):
"rank filter 6"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]])
true = [[2, 2, 1, 1, 1],
@@ -998,7 +997,7 @@
def test_rank07(self):
"rank filter 7"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]])
true = [[3, 5, 5, 5, 4],
@@ -1009,13 +1008,13 @@
def test_rank08(self):
"median filter 8"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]])
true = [[3, 3, 2, 4, 4],
[5, 5, 5, 4, 4],
[5, 6, 7, 5, 5]]
- kernel = numarray.array([2, 3])
+ kernel = numpy.array([2, 3])
output = ndimage.percentile_filter(array, 50.0,
size = (2, 3))
self.failUnless(diff(true, output) < eps)
@@ -1031,7 +1030,7 @@
[5, 5, 8, 3, 5]]
footprint = [[1, 0, 1], [0, 1, 0]]
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
output = ndimage.rank_filter(array, 1,
@@ -1043,7 +1042,7 @@
def test_rank10(self):
"rank filter 10"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
true = [[2, 2, 1, 1, 1],
@@ -1059,7 +1058,7 @@
def test_rank11(self):
"rank filter 11"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
true = [[3, 5, 5, 5, 4],
@@ -1081,7 +1080,7 @@
[5, 5, 8, 3, 5]]
footprint = [[1, 0, 1], [0, 1, 0]]
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
output = ndimage.rank_filter(array, 1,
@@ -1101,7 +1100,7 @@
[6, 6, 5, 5, 5]]
footprint = [[1, 0, 1], [0, 1, 0]]
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
output = ndimage.rank_filter(array, 1,
@@ -1115,7 +1114,7 @@
[5, 6, 6, 5, 5]]
footprint = [[1, 0, 1], [0, 1, 0]]
for type in self.types:
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[5, 8, 3, 7, 1],
[5, 6, 9, 3, 5]], type)
output = ndimage.rank_filter(array, 1,
@@ -1124,7 +1123,7 @@
def test_generic_filter1d01(self):
"generic 1d filter 1"
- weights = numarray.array([1.1, 2.2, 3.3])
+ weights = numpy.array([1.1, 2.2, 3.3])
def _filter_func(input, output, fltr, total):
fltr = fltr / total
for ii in range(input.shape[0] - 2):
@@ -1132,7 +1131,7 @@
output[ii] += input[ii + 1] * fltr[1]
output[ii] += input[ii + 2] * fltr[2]
for type in self.types:
- a = numarray.arange(12, dtype = type)
+ a = numpy.arange(12, dtype = type)
a.shape = (3,4)
r1 = ndimage.correlate1d(a, weights / weights.sum(), 0,
origin = -1)
@@ -1143,14 +1142,14 @@
def test_generic_filter01(self):
"generic filter 1"
- filter = numarray.array([[1.0, 2.0], [3.0, 4.0]])
- footprint = numarray.array([[1, 0], [0, 1]])
- cf = numarray.array([1., 4.])
+ filter = numpy.array([[1.0, 2.0], [3.0, 4.0]])
+ footprint = numpy.array([[1, 0], [0, 1]])
+ cf = numpy.array([1., 4.])
def _filter_func(buffer, weights, total = 1.0):
weights = cf / total
return (buffer * weights).sum()
for type in self.types:
- a = numarray.arange(12, dtype = type)
+ a = numpy.arange(12, dtype = type)
a.shape = (3,4)
r1 = ndimage.correlate(a, filter * footprint) / 5
r2 = ndimage.generic_filter(a, _filter_func,
@@ -1160,8 +1159,8 @@
def test_extend01(self):
"line extension 1"
- array = numarray.array([1, 2, 3])
- weights = numarray.array([1, 0])
+ array = numpy.array([1, 2, 3])
+ weights = numpy.array([1, 0])
true_values = [[1, 1, 2],
[3, 1, 2],
[1, 1, 2],
@@ -1173,8 +1172,8 @@
def test_extend02(self):
"line extension 2"
- array = numarray.array([1, 2, 3])
- weights = numarray.array([1, 0, 0, 0, 0, 0, 0, 0])
+ array = numpy.array([1, 2, 3])
+ weights = numpy.array([1, 0, 0, 0, 0, 0, 0, 0])
true_values = [[1, 1, 1],
[3, 1, 2],
[3, 3, 2],
@@ -1186,8 +1185,8 @@
def test_extend03(self):
"line extension 3"
- array = numarray.array([1, 2, 3])
- weights = numarray.array([0, 0, 1])
+ array = numpy.array([1, 2, 3])
+ weights = numpy.array([0, 0, 1])
true_values = [[2, 3, 3],
[2, 3, 1],
[2, 3, 3],
@@ -1199,8 +1198,8 @@
def test_extend04(self):
"line extension 4"
- array = numarray.array([1, 2, 3])
- weights = numarray.array([0, 0, 0, 0, 0, 0, 0, 0, 1])
+ array = numpy.array([1, 2, 3])
+ weights = numpy.array([0, 0, 0, 0, 0, 0, 0, 0, 1])
true_values = [[3, 3, 3],
[2, 3, 1],
[2, 1, 1],
@@ -1213,10 +1212,10 @@
def test_extend05(self):
"line extension 5"
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
- weights = numarray.array([[1, 0], [0, 0]])
+ weights = numpy.array([[1, 0], [0, 0]])
true_values = [[[1, 1, 2], [1, 1, 2], [4, 4, 5]],
[[9, 7, 8], [3, 1, 2], [6, 4, 5]],
[[1, 1, 2], [1, 1, 2], [4, 4, 5]],
@@ -1229,10 +1228,10 @@
def test_extend06(self):
"line extension 6"
- array = numarray.array([[1, 2, 3],
+ array = numpy.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
- weights = numarray.array([[0, 0, 0], [0, 0, 0], [0, 0, 1]])
+ weights = numpy.array([[0, 0, 0], [0, 0, 0], [0, 0, 1]])
true_values = [[[5, 6, 6], [8, 9, 9], [8, 9, 9]],
[[5, 6, 4], [8, 9, 7], [2, 3, 1]],
[[5, 6, 6], [8, 9, 9], [8, 9, 9]],
@@ -1245,8 +1244,8 @@
def test_extend07(self):
"line extension 7"
- array = numarray.array([1, 2, 3])
- weights = numarray.array([0, 0, 0, 0, 0, 0, 0, 0, 1])
+ array = numpy.array([1, 2, 3])
+ weights = numpy.array([0, 0, 0, 0, 0, 0, 0, 0, 1])
true_values = [[3, 3, 3],
[2, 3, 1],
[2, 1, 1],
@@ -1258,8 +1257,8 @@
def test_extend08(self):
"line extension 8"
- array = numarray.array([[1], [2], [3]])
- weights = numarray.array([[0], [0], [0], [0], [0], [0], [0],
+ array = numpy.array([[1], [2], [3]])
+ weights = numpy.array([[0], [0], [0], [0], [0], [0], [0],
[0], [1]])
true_values = [[[3], [3], [3]],
[[2], [3], [1]],
@@ -1272,8 +1271,8 @@
def test_extend09(self):
"line extension 9"
- array = numarray.array([1, 2, 3])
- weights = numarray.array([0, 0, 0, 0, 0, 0, 0, 0, 1])
+ array = numpy.array([1, 2, 3])
+ weights = numpy.array([0, 0, 0, 0, 0, 0, 0, 0, 1])
true_values = [[3, 3, 3],
[2, 3, 1],
[2, 1, 1],
@@ -1285,8 +1284,8 @@
def test_extend10(self):
"line extension 10"
- array = numarray.array([[1], [2], [3]])
- weights = numarray.array([[0], [0], [0], [0], [0], [0], [0],
+ array = numpy.array([[1], [2], [3]])
+ weights = numpy.array([[0], [0], [0], [0], [0], [0], [0],
[0], [1]])
true_values = [[[3], [3], [3]],
[[2], [3], [1]],
@@ -1300,8 +1299,8 @@
def test_fourier_gaussian_real01(self):
"gaussian fourier filter for real transforms 1"
for shape in [(32, 16), (31, 15)]:
- for type in [numarray.float32, numarray.float64]:
- a = numarray.zeros(shape, type)
+ for type in [numpy.float32, numpy.float64]:
+ a = numpy.zeros(shape, type)
a[0, 0] = 1.0
a = fft.rfft(a, shape[0], 0)
a = fft.fft(a, shape[1], 1)
@@ -1314,8 +1313,8 @@
def test_fourier_gaussian_complex01(self):
"gaussian fourier filter for complex transforms 1"
for shape in [(32, 16), (31, 15)]:
- for type in [numarray.complex64, numarray.complex128]:
- a = numarray.zeros(shape, type)
+ for type in [numpy.complex64, numpy.complex128]:
+ a = numpy.zeros(shape, type)
a[0, 0] = 1.0
a = fft.fft(a, shape[0], 0)
a = fft.fft(a, shape[1], 1)
@@ -1329,8 +1328,8 @@
def test_fourier_uniform_real01(self):
"uniform fourier filter for real transforms 1"
for shape in [(32, 16), (31, 15)]:
- for type in [numarray.float32, numarray.float64]:
- a = numarray.zeros(shape, type)
+ for type in [numpy.float32, numpy.float64]:
+ a = numpy.zeros(shape, type)
a[0, 0] = 1.0
a = fft.rfft(a, shape[0], 0)
a = fft.fft(a, shape[1], 1)
@@ -1343,8 +1342,8 @@
def test_fourier_uniform_complex01(self):
"uniform fourier filter for complex transforms 1"
for shape in [(32, 16), (31, 15)]:
- for type in [numarray.complex64, numarray.complex128]:
- a = numarray.zeros(shape, type)
+ for type in [numpy.complex64, numpy.complex128]:
+ a = numpy.zeros(shape, type)
a[0, 0] = 1.0
a = fft.fft(a, shape[0], 0)
a = fft.fft(a, shape[1], 1)
@@ -1357,8 +1356,8 @@
def test_fourier_shift_real01(self):
"shift filter for real transforms 1"
for shape in [(32, 16), (31, 15)]:
- for dtype in [numarray.float32, numarray.float64]:
- true = numarray.arange(shape[0] * shape[1], dtype = dtype)
+ for dtype in [numpy.float32, numpy.float64]:
+ true = numpy.arange(shape[0] * shape[1], dtype = dtype)
true.shape = shape
a = fft.rfft(true, shape[0], 0)
a = fft.fft(a, shape[1], 1)
@@ -1366,14 +1365,14 @@
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))
+ error2 = diff(a.imag, numpy.zeros(shape))
self.failUnless(error1 < 1e-10 and error2 < 1e-10)
def test_fourier_shift_complex01(self):
"shift filter for complex transforms 1"
for shape in [(32, 16), (31, 15)]:
- for type in [numarray.complex64, numarray.complex128]:
- true = numarray.arange(shape[0] * shape[1],
+ for type in [numpy.complex64, numpy.complex128]:
+ true = numpy.arange(shape[0] * shape[1],
dtype = type)
true.shape = shape
a = fft.fft(true, shape[0], 0)
@@ -1382,14 +1381,14 @@
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))
+ error2 = diff(a.imag, numpy.zeros(shape))
self.failUnless(error1 < 1e-10 and error2 < 1e-10)
def test_fourier_ellipsoid_real01(self):
"ellipsoid fourier filter for real transforms 1"
for shape in [(32, 16), (31, 15)]:
- for type in [numarray.float32, numarray.float64]:
- a = numarray.zeros(shape, type)
+ for type in [numpy.float32, numpy.float64]:
+ a = numpy.zeros(shape, type)
a[0, 0] = 1.0
a = fft.rfft(a, shape[0], 0)
a = fft.fft(a, shape[1], 1)
@@ -1402,8 +1401,8 @@
def test_fourier_ellipsoid_complex01(self):
"ellipsoid fourier filter for complex transforms 1"
for shape in [(32, 16), (31, 15)]:
- for type in [numarray.complex64, numarray.complex128]:
- a = numarray.zeros(shape, type)
+ for type in [numpy.complex64, numpy.complex128]:
+ a = numpy.zeros(shape, type)
a[0, 0] = 1.0
a = fft.fft(a, shape[0], 0)
a = fft.fft(a, shape[1], 1)
@@ -1417,25 +1416,25 @@
def test_spline01(self):
"spline filter 1"
for type in self.types:
- data = numarray.ones([], type)
+ data = numpy.ones([], type)
for order in range(2, 6):
out = ndimage.spline_filter(data, order = order)
self.failUnless(diff(out, 1)< eps and
- out.dtype.type == numarray.float64)
+ out.dtype.type == numpy.float64)
def test_spline02(self):
"spline filter 2"
for type in self.types:
- data = numarray.array([1])
+ data = numpy.array([1])
for order in range(2, 6):
out = ndimage.spline_filter(data, order = order)
self.failUnless(diff(out, [1]) < eps and
- out.dtype.type == numarray.float64)
+ out.dtype.type == numpy.float64)
def test_spline03(self):
"spline filter 3"
for type in self.types:
- data = numarray.ones([], type)
+ data = numpy.ones([], type)
for order in range(2, 6):
out = ndimage.spline_filter(data, order,
output = type)
@@ -1445,7 +1444,7 @@
def test_spline04(self):
"spline filter 4"
for type in self.types:
- data = numarray.ones([4], type)
+ data = numpy.ones([4], type)
for order in range(2, 6):
out = ndimage.spline_filter(data, order)
self.failUnless(diff(out, [1, 1, 1, 1]) < eps)
@@ -1453,7 +1452,7 @@
def test_spline05(self):
"spline filter 5"
for type in self.types:
- data = numarray.ones([4, 4], type)
+ data = numpy.ones([4, 4], type)
for order in range(2, 6):
out = ndimage.spline_filter(data, order = order)
self.failUnless(diff(out, [[1, 1, 1, 1],
@@ -1463,7 +1462,7 @@
def test_geometric_transform01(self):
"geometric transform 1"
- data = numarray.array([1])
+ data = numpy.array([1])
def mapping(x):
return x
for order in range(0, 6):
@@ -1474,7 +1473,7 @@
def test_geometric_transform02(self):
"geometric transform 2"
- data = numarray.ones([4])
+ data = numpy.ones([4])
def mapping(x):
return x
for order in range(0, 6):
@@ -1484,7 +1483,7 @@
def test_geometric_transform03(self):
"geometric transform 3"
- data = numarray.ones([4])
+ data = numpy.ones([4])
def mapping(x):
return (x[0] - 1,)
for order in range(0, 6):
@@ -1494,7 +1493,7 @@
def test_geometric_transform04(self):
"geometric transform 4"
- data = numarray.array([4, 1, 3, 2])
+ data = numpy.array([4, 1, 3, 2])
def mapping(x):
return (x[0] - 1,)
for order in range(0, 6):
@@ -1504,7 +1503,7 @@
def test_geometric_transform05(self):
"geometric transform 5"
- data = numarray.array([[1, 1, 1, 1],
+ data = numpy.array([[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]])
def mapping(x):
@@ -1518,7 +1517,7 @@
def test_geometric_transform06(self):
"geometric transform 6"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
def mapping(x):
@@ -1532,7 +1531,7 @@
def test_geometric_transform07(self):
"geometric transform 7"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
def mapping(x):
@@ -1546,7 +1545,7 @@
def test_geometric_transform08(self):
"geometric transform 8"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
def mapping(x):
@@ -1560,7 +1559,7 @@
def test_geometric_transform10(self):
"geometric transform 10"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
def mapping(x):
@@ -1579,7 +1578,7 @@
def test_geometric_transform13(self):
"geometric transform 13"
- data = numarray.ones([2], numarray.float64)
+ data = numpy.ones([2], numpy.float64)
def mapping(x):
return (x[0] / 2,)
for order in range(0, 6):
@@ -1682,9 +1681,9 @@
def test_geometric_transform22(self):
"geometric transform 22"
- data = numarray.array([[1, 2, 3, 4],
+ data = numpy.array([[1, 2, 3, 4],
[5, 6, 7, 8],
- [9, 10, 11, 12]], numarray.float64)
+ [9, 10, 11, 12]], numpy.float64)
def mapping1(x):
return (x[0] / 2, x[1] / 2)
def mapping2(x):
@@ -1707,7 +1706,7 @@
for order in range(0, 6):
out = ndimage.geometric_transform(data, mapping,
(2,), order=order)
- out = out.astype(numarray.int32)
+ out = out.astype(numpy.int32)
self.failUnless(diff(out, [5, 7]) < eps)
def test_geometric_transform24(self):
@@ -1725,10 +1724,10 @@
def test_map_coordinates01(self):
"map coordinates 1"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
- idx = numarray.indices(data.shape)
+ idx = numpy.indices(data.shape)
idx -= 1
for order in range(0, 6):
out = ndimage.map_coordinates(data, idx, order=order)
@@ -1738,10 +1737,10 @@
def test_map_coordinates02(self):
"map coordinates 2"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
- idx = numarray.indices(data.shape, numarray.float64)
+ idx = numpy.indices(data.shape, numpy.float64)
idx -= 0.5
for order in range(0, 6):
out1 = ndimage.shift(data, 0.5, order=order)
@@ -1751,7 +1750,7 @@
def test_affine_transform01(self):
"affine_transform 1"
- data = numarray.array([1])
+ data = numpy.array([1])
for order in range(0, 6):
out = ndimage.affine_transform(data, [[1]],
order=order)
@@ -1759,7 +1758,7 @@
def test_affine_transform02(self):
"affine transform 2"
- data = numarray.ones([4])
+ data = numpy.ones([4])
for order in range(0, 6):
out = ndimage.affine_transform(data, [[1]],
order=order)
@@ -1767,7 +1766,7 @@
def test_affine_transform03(self):
"affine transform 3"
- data = numarray.ones([4])
+ data = numpy.ones([4])
for order in range(0, 6):
out = ndimage.affine_transform(data, [[1]], -1,
order=order)
@@ -1775,7 +1774,7 @@
def test_affine_transform04(self):
"affine transform 4"
- data = numarray.array([4, 1, 3, 2])
+ data = numpy.array([4, 1, 3, 2])
for order in range(0, 6):
out = ndimage.affine_transform(data, [[1]], -1,
order=order)
@@ -1783,7 +1782,7 @@
def test_affine_transform05(self):
"affine transform 5"
- data = numarray.array([[1, 1, 1, 1],
+ data = numpy.array([[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]])
for order in range(0, 6):
@@ -1796,7 +1795,7 @@
def test_affine_transform06(self):
"affine transform 6"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -1809,7 +1808,7 @@
def test_affine_transform07(self):
"affine transform 7"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -1822,7 +1821,7 @@
def test_affine_transform08(self):
"affine transform 8"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -1835,7 +1834,7 @@
def test_affine_transform09(self):
"affine transform 9"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -1853,7 +1852,7 @@
def test_affine_transform10(self):
"affine transform 10"
- data = numarray.ones([2], numarray.float64)
+ data = numpy.ones([2], numpy.float64)
for order in range(0, 6):
out = ndimage.affine_transform(data, [[0.5]],
output_shape = (4,), order=order)
@@ -1944,9 +1943,9 @@
def test_affine_transform19(self):
"affine transform 19"
- data = numarray.array([[1, 2, 3, 4],
+ data = numpy.array([[1, 2, 3, 4],
[5, 6, 7, 8],
- [9, 10, 11, 12]], numarray.float64)
+ [9, 10, 11, 12]], numpy.float64)
for order in range(0, 6):
out = ndimage.affine_transform(data,
[[0.5, 0],
@@ -1980,35 +1979,35 @@
def test_shift01(self):
"shift 1"
- data = numarray.array([1])
+ data = numpy.array([1])
for order in range(0, 6):
out = ndimage.shift(data, [1], order=order)
self.failUnless(diff(out, [0]) < eps)
def test_shift02(self):
"shift 2"
- data = numarray.ones([4])
+ data = numpy.ones([4])
for order in range(0, 6):
out = ndimage.shift(data, [1], order=order)
self.failUnless(diff(out, [0, 1, 1, 1]) < eps)
def test_shift03(self):
"shift 3"
- data = numarray.ones([4])
+ data = numpy.ones([4])
for order in range(0, 6):
out = ndimage.shift(data, -1, order=order)
self.failUnless(diff(out, [1, 1, 1, 0]) < eps)
def test_shift04(self):
"shift 4"
- data = numarray.array([4, 1, 3, 2])
+ data = numpy.array([4, 1, 3, 2])
for order in range(0, 6):
out = ndimage.shift(data, 1, order=order)
self.failUnless(diff(out, [0, 4, 1, 3]) < eps)
def test_shift05(self):
"shift 5"
- data = numarray.array([[1, 1, 1, 1],
+ data = numpy.array([[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]])
for order in range(0, 6):
@@ -2019,7 +2018,7 @@
def test_shift06(self):
"shift 6"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -2030,7 +2029,7 @@
def test_shift07(self):
"shift 7"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -2042,7 +2041,7 @@
def test_shift08(self):
"shift 8"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -2053,7 +2052,7 @@
def test_shift09(self):
"shift 9"
- data = numarray.array([[4, 1, 3, 2],
+ data = numpy.array([[4, 1, 3, 2],
[7, 6, 8, 5],
[3, 5, 3, 6]])
for order in range(0, 6):
@@ -2070,7 +2069,7 @@
def test_zoom01(self):
"zoom 1"
- data = numarray.ones([2], numarray.float64)
+ data = numpy.ones([2], numpy.float64)
for order in range(0, 6):
out = ndimage.zoom(data, 2.0, order=order)
self.failUnless(diff(out, [1, 1, 1, 1]) < eps)
@@ -2145,9 +2144,9 @@
def test_zoom10(self):
"zoom 10"
- data = numarray.array([[1, 2, 3, 4],
+ data = numpy.array([[1, 2, 3, 4],
[5, 6, 7, 8],
- [9, 10, 11, 12]], numarray.float64)
+ [9, 10, 11, 12]], numpy.float64)
for order in range(0, 6):
out = ndimage.zoom(data, [2, 2], order=order)
out = ndimage.zoom(out, [0.5, 0.5], order=order)
@@ -2165,93 +2164,93 @@
def test_rotate01(self):
"rotate 1"
- data = numarray.array([[0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0],
[0, 1, 1, 0],
- [0, 0, 0, 0]], dtype = numarray.float64)
+ [0, 0, 0, 0]], dtype = numpy.float64)
for order in range(0, 6):
out = ndimage.rotate(data, 0)
self.failUnless(diff(out, data) < eps)
def test_rotate02(self):
"rotate 2"
- data = numarray.array([[0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0],
[0, 1, 0, 0],
- [0, 0, 0, 0]], dtype = numarray.float64)
- true = numarray.array([[0, 0, 0],
+ [0, 0, 0, 0]], dtype = numpy.float64)
+ true = numpy.array([[0, 0, 0],
[0, 0, 0],
[0, 1, 0],
- [0, 0, 0]], dtype = numarray.float64)
+ [0, 0, 0]], dtype = numpy.float64)
for order in range(0, 6):
out = ndimage.rotate(data, 90)
self.failUnless(diff(out, true) < eps)
def test_rotate03(self):
"rotate 3"
- data = numarray.array([[0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0],
[0, 1, 1, 0, 0],
- [0, 0, 0, 0, 0]], dtype = numarray.float64)
- true = numarray.array([[0, 0, 0],
+ [0, 0, 0, 0, 0]], dtype = numpy.float64)
+ true = numpy.array([[0, 0, 0],
[0, 0, 0],
[0, 1, 0],
[0, 1, 0],
- [0, 0, 0]], dtype = numarray.float64)
+ [0, 0, 0]], dtype = numpy.float64)
for order in range(0, 6):
out = ndimage.rotate(data, 90)
self.failUnless(diff(out, true) < eps)
def test_rotate04(self):
"rotate 4"
- data = numarray.array([[0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0],
[0, 1, 1, 0, 0],
- [0, 0, 0, 0, 0]], dtype = numarray.float64)
- true = numarray.array([[0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0]], dtype = numpy.float64)
+ true = numpy.array([[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
- [0, 0, 1, 0, 0]], dtype = numarray.float64)
+ [0, 0, 1, 0, 0]], dtype = numpy.float64)
for order in range(0, 6):
out = ndimage.rotate(data, 90, reshape = False)
self.failUnless(diff(out, true) < eps)
def test_rotate05(self):
"rotate 5"
- data = numarray.array([[[0, 0, 0, 0, 0],
+ data = numpy.array([[[0, 0, 0, 0, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]]] * 3,
- dtype = numarray.float64)
- true = numarray.array([[[0, 0, 0],
+ dtype = numpy.float64)
+ true = numpy.array([[[0, 0, 0],
[0, 0, 0],
[0, 1, 0],
[0, 1, 0],
- [0, 0, 0]]] * 3, dtype = numarray.float64)
+ [0, 0, 0]]] * 3, dtype = numpy.float64)
for order in range(0, 6):
out = ndimage.rotate(data, 90)
self.failUnless(diff(out, true) < eps)
def test_rotate06(self):
"rotate 6"
- data = numarray.array([[[0, 0, 0, 0, 0],
+ data = numpy.array([[[0, 0, 0, 0, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]]] * 3,
- dtype = numarray.float64)
- true = numarray.array([[[0, 0, 0, 0, 0],
+ dtype = numpy.float64)
+ true = numpy.array([[[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0]]] * 3,
- dtype = numarray.float64)
+ dtype = numpy.float64)
for order in range(0, 6):
out = ndimage.rotate(data, 90, reshape = False)
self.failUnless(diff(out, true) < eps)
def test_rotate07(self):
"rotate 7"
- data = numarray.array([[[0, 0, 0, 0, 0],
+ data = numpy.array([[[0, 0, 0, 0, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]]] * 2,
- dtype = numarray.float64)
+ dtype = numpy.float64)
data = data.transpose()
- true = numarray.array([[[0, 0, 0],
+ true = numpy.array([[[0, 0, 0],
[0, 1, 0],
[0, 1, 0],
[0, 0, 0],
- [0, 0, 0]]] * 2, dtype = numarray.float64)
+ [0, 0, 0]]] * 2, dtype = numpy.float64)
true = true.transpose([2,1,0])
for order in range(0, 6):
@@ -2260,15 +2259,15 @@
def test_rotate08(self):
"rotate 8"
- data = numarray.array([[[0, 0, 0, 0, 0],
+ data = numpy.array([[[0, 0, 0, 0, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]]] * 2,
- dtype = numarray.float64)
+ dtype = numpy.float64)
data = data.transpose()
- true = numarray.array([[[0, 0, 1, 0, 0],
+ true = numpy.array([[[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0]]] * 2,
- dtype = numarray.float64)
+ dtype = numpy.float64)
true = true.transpose()
for order in range(0, 6):
out = ndimage.rotate(data, 90, axes = (0, 1),
@@ -2277,15 +2276,15 @@
def test_watershed_ift01(self):
"watershed_ift 1"
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0]], numarray.uint8)
- markers = numarray.array([[ -1, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0]], numpy.uint8)
+ markers = numpy.array([[ -1, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 1, 0, 0, 0],
@@ -2293,7 +2292,7 @@
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0]],
- numarray.int8)
+ numpy.int8)
out = ndimage.watershed_ift(data, markers,
structure = [[1,1,1],
[1,1,1],
@@ -2310,15 +2309,15 @@
def test_watershed_ift02(self):
"watershed_ift 2"
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0]], numarray.uint8)
- markers = numarray.array([[ -1, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0]], numpy.uint8)
+ markers = numpy.array([[ -1, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 1, 0, 0, 0],
@@ -2326,7 +2325,7 @@
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0]],
- numarray.int8)
+ numpy.int8)
out = ndimage.watershed_ift(data, markers)
error = diff([[-1, -1, -1, -1, -1, -1, -1],
[-1, -1, 1, 1, 1, -1, -1],
@@ -2340,21 +2339,21 @@
def test_watershed_ift03(self):
"watershed_ift 3"
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 0],
- [0, 0, 0, 0, 0, 0, 0]], numarray.uint8)
- markers = numarray.array([[ 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0]], numpy.uint8)
+ markers = numpy.array([[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 2, 0, 3, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, -1]],
- numarray.int8)
+ numpy.int8)
out = ndimage.watershed_ift(data, markers)
error = diff([[-1, -1, -1, -1, -1, -1, -1],
[-1, -1, 2, -1, 3, -1, -1],
@@ -2367,21 +2366,21 @@
def test_watershed_ift04(self):
"watershed_ift 4"
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 0],
- [0, 0, 0, 0, 0, 0, 0]], numarray.uint8)
- markers = numarray.array([[ 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0]], numpy.uint8)
+ markers = numpy.array([[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 2, 0, 3, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, -1]],
- numarray.int8)
+ numpy.int8)
out = ndimage.watershed_ift(data, markers,
structure = [[1,1,1],
[1,1,1],
@@ -2397,21 +2396,21 @@
def test_watershed_ift05(self):
"watershed_ift 5"
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 0],
- [0, 0, 0, 0, 0, 0, 0]], numarray.uint8)
- markers = numarray.array([[ 0, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0]], numpy.uint8)
+ markers = numpy.array([[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 3, 0, 2, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, -1]],
- numarray.int8)
+ numpy.int8)
out = ndimage.watershed_ift(data, markers,
structure = [[1,1,1],
[1,1,1],
@@ -2427,19 +2426,19 @@
def test_watershed_ift06(self):
"watershed_ift 6"
- data = numarray.array([[0, 1, 0, 0, 0, 1, 0],
+ data = numpy.array([[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0]], numarray.uint8)
- markers = numarray.array([[ -1, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0]], numpy.uint8)
+ markers = numpy.array([[ -1, 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, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0]],
- numarray.int8)
+ numpy.int8)
out = ndimage.watershed_ift(data, markers,
structure = [[1,1,1],
[1,1,1],
@@ -2455,22 +2454,22 @@
def test_watershed_ift07(self):
"watershed_ift 7"
shape = (7, 6)
- data = numarray.zeros(shape, dtype = numarray.uint8)
+ data = numpy.zeros(shape, dtype = numpy.uint8)
data = data.transpose()
- data[...] = numarray.array([[0, 1, 0, 0, 0, 1, 0],
+ data[...] = numpy.array([[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0]], numarray.uint8)
- markers = numarray.array([[-1, 0, 0, 0, 0, 0, 0],
+ [0, 0, 0, 0, 0, 0, 0]], numpy.uint8)
+ markers = numpy.array([[-1, 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, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0]],
- numarray.int8)
- out = numarray.zeros(shape, dtype = numarray.int16)
+ numpy.int8)
+ out = numpy.zeros(shape, dtype = numpy.int16)
out = out.transpose()
ndimage.watershed_ift(data, markers,
structure = [[1,1,1],
@@ -2487,43 +2486,43 @@
def test_label01(self):
"label 1"
- data = numarray.ones([])
+ data = numpy.ones([])
out, n = ndimage.label(data)
self.failUnless(diff(out, 1) < eps and n == 1)
def test_label02(self):
"label 2"
- data = numarray.zeros([])
+ data = numpy.zeros([])
out, n = ndimage.label(data)
self.failUnless(diff(out, 0) < eps and n == 0)
def test_label03(self):
"label 3"
- data = numarray.ones([1])
+ data = numpy.ones([1])
out, n = ndimage.label(data)
self.failUnless(diff(out, [1]) < eps and n == 1)
def test_label04(self):
"label 4"
- data = numarray.zeros([1])
+ data = numpy.zeros([1])
out, n = ndimage.label(data)
self.failUnless(diff(out, [0]) < eps and n == 0)
def test_label05(self):
"label 5"
- data = numarray.ones([5])
+ data = numpy.ones([5])
out, n = ndimage.label(data)
self.failUnless(diff(out, [1, 1, 1, 1, 1]) < eps and n == 1)
def test_label06(self):
"label 6"
- data = numarray.array([1, 0, 1, 1, 0, 1])
+ data = numpy.array([1, 0, 1, 1, 0, 1])
out, n = ndimage.label(data)
self.failUnless(diff(out, [1, 0, 2, 2, 0, 3]) < eps and n == 3)
def test_label07(self):
"label 7"
- data = numarray.array([[0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
@@ -2539,7 +2538,7 @@
def test_label08(self):
"label 8"
- data = numarray.array([[1, 0, 0, 0, 0, 0],
+ data = numpy.array([[1, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 0],
[1, 1, 0, 0, 0, 0],
@@ -2555,7 +2554,7 @@
def test_label09(self):
"label 9"
- data = numarray.array([[1, 0, 0, 0, 0, 0],
+ data = numpy.array([[1, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 0],
[1, 1, 0, 0, 0, 0],
@@ -2572,7 +2571,7 @@
def test_label10(self):
"label 10"
- data = numarray.array([[0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 1, 0],
[0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0]])
@@ -2586,7 +2585,7 @@
def test_label11(self):
"label 11"
for type in self.types:
- data = numarray.array([[1, 0, 0, 0, 0, 0],
+ data = numpy.array([[1, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 0],
[1, 1, 0, 0, 0, 0],
@@ -2604,7 +2603,7 @@
def test_label12(self):
"label 12"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 1, 1],
+ data = numpy.array([[0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 1],
[0, 0, 1, 0, 1, 1],
[0, 0, 1, 1, 1, 1],
@@ -2620,7 +2619,7 @@
def test_label13(self):
"label 13"
for type in self.types:
- data = numarray.array([[1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1],
+ data = numpy.array([[1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1],
[1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],
@@ -2634,37 +2633,37 @@
def test_find_objects01(self):
"find_objects 1"
- data = numarray.ones([])
+ data = numpy.ones([], dtype=int)
out = ndimage.find_objects(data)
self.failUnless(out == [()])
def test_find_objects02(self):
"find_objects 2"
- data = numarray.zeros([])
+ data = numpy.zeros([], dtype=int)
out = ndimage.find_objects(data)
self.failUnless(out == [])
def test_find_objects03(self):
"find_objects 3"
- data = numarray.ones([1])
+ data = numpy.ones([1], dtype=int)
out = ndimage.find_objects(data)
self.failUnless(out == [(slice(0, 1, None),)])
def test_find_objects04(self):
"find_objects 4"
- data = numarray.zeros([1])
+ data = numpy.zeros([1], dtype=int)
out = ndimage.find_objects(data)
self.failUnless(out == [])
def test_find_objects05(self):
"find_objects 5"
- data = numarray.ones([5])
+ data = numpy.ones([5], dtype=int)
out = ndimage.find_objects(data)
self.failUnless(out == [(slice(0, 5, None),)])
def test_find_objects06(self):
"find_objects 6"
- data = numarray.array([1, 0, 2, 2, 0, 3])
+ data = numpy.array([1, 0, 2, 2, 0, 3])
out = ndimage.find_objects(data)
self.failUnless(out == [(slice(0, 1, None),),
(slice(2, 4, None),),
@@ -2672,7 +2671,7 @@
def test_find_objects07(self):
"find_objects 7"
- data = numarray.array([[0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
@@ -2683,7 +2682,7 @@
def test_find_objects08(self):
"find_objects 8"
- data = numarray.array([[1, 0, 0, 0, 0, 0],
+ data = numpy.array([[1, 0, 0, 0, 0, 0],
[0, 0, 2, 2, 0, 0],
[0, 0, 2, 2, 2, 0],
[3, 3, 0, 0, 0, 0],
@@ -2697,7 +2696,7 @@
def test_find_objects09(self):
"find_objects 9"
- data = numarray.array([[1, 0, 0, 0, 0, 0],
+ data = numpy.array([[1, 0, 0, 0, 0, 0],
[0, 0, 2, 2, 0, 0],
[0, 0, 2, 2, 2, 0],
[0, 0, 0, 0, 0, 0],
@@ -2712,190 +2711,190 @@
def test_sum01(self):
"sum 1"
for type in self.types:
- input = numarray.array([], type)
+ input = numpy.array([], type)
output = ndimage.sum(input)
self.failUnless(output == 0.0)
def test_sum02(self):
"sum 2"
for type in self.types:
- input = numarray.zeros([0, 4], type)
+ input = numpy.zeros([0, 4], type)
output = ndimage.sum(input)
self.failUnless(output == 0.0)
def test_sum03(self):
"sum 3"
for type in self.types:
- input = numarray.ones([], type)
+ input = numpy.ones([], type)
output = ndimage.sum(input)
self.failUnless(output == 1.0)
def test_sum04(self):
"sum 4"
for type in self.types:
- input = numarray.array([1, 2], type)
+ input = numpy.array([1, 2], type)
output = ndimage.sum(input)
self.failUnless(output == 3.0)
def test_sum05(self):
"sum 5"
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.sum(input)
self.failUnless(output == 10.0)
def test_sum06(self):
"sum 6"
- labels = numarray.array([], bool)
+ labels = numpy.array([], bool)
for type in self.types:
- input = numarray.array([], type)
+ input = numpy.array([], type)
output = ndimage.sum(input, labels = labels)
self.failUnless(output == 0.0)
def test_sum07(self):
"sum 7"
- labels = numarray.ones([0, 4], bool)
+ labels = numpy.ones([0, 4], bool)
for type in self.types:
- input = numarray.zeros([0, 4], type)
+ input = numpy.zeros([0, 4], type)
output = ndimage.sum(input, labels = labels)
self.failUnless(output == 0.0)
def test_sum08(self):
"sum 8"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([1, 2], type)
+ input = numpy.array([1, 2], type)
output = ndimage.sum(input, labels = labels)
self.failUnless(output == 1.0)
def test_sum09(self):
"sum 9"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.sum(input, labels = labels)
self.failUnless(output == 4.0)
def test_sum10(self):
"sum 10"
- labels = numarray.array([1, 0], bool)
- input = numarray.array([[1, 2], [3, 4]], bool)
+ labels = numpy.array([1, 0], bool)
+ input = numpy.array([[1, 2], [3, 4]], bool)
output = ndimage.sum(input, labels = labels)
self.failUnless(output == 2.0)
def test_sum11(self):
"sum 11"
- labels = numarray.array([1, 2], numarray.int8)
+ labels = numpy.array([1, 2], numpy.int8)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.sum(input, labels = labels,
index = 2)
self.failUnless(output == 6.0)
def test_sum12(self):
"sum 12"
- labels = numarray.array([[1, 2], [2, 4]], numarray.int8)
+ labels = numpy.array([[1, 2], [2, 4]], numpy.int8)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.sum(input, labels = labels,
index = [4, 8, 2])
self.failUnless(output == [4.0, 0.0, 5.0])
def test_mean01(self):
"mean 1"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.mean(input, labels = labels)
self.failUnless(output == 2.0)
def test_mean02(self):
"mean 2"
- labels = numarray.array([1, 0], bool)
- input = numarray.array([[1, 2], [3, 4]], bool)
+ labels = numpy.array([1, 0], bool)
+ input = numpy.array([[1, 2], [3, 4]], bool)
output = ndimage.mean(input, labels = labels)
self.failUnless(output == 1.0)
def test_mean03(self):
"mean 3"
- labels = numarray.array([1, 2])
+ labels = numpy.array([1, 2])
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.mean(input, labels = labels,
index = 2)
self.failUnless(output == 3.0)
def test_mean04(self):
"mean 4"
- labels = numarray.array([[1, 2], [2, 4]], numarray.int8)
+ labels = numpy.array([[1, 2], [2, 4]], numpy.int8)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.mean(input, labels = labels,
index = [4, 8, 2])
self.failUnless(output == [4.0, 0.0, 2.5])
def test_minimum01(self):
"minimum 1"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.minimum(input, labels = labels)
self.failUnless(output == 1.0)
def test_minimum02(self):
"minimum 2"
- labels = numarray.array([1, 0], bool)
- input = numarray.array([[2, 2], [2, 4]], bool)
+ labels = numpy.array([1, 0], bool)
+ input = numpy.array([[2, 2], [2, 4]], bool)
output = ndimage.minimum(input, labels = labels)
self.failUnless(output == 1.0)
def test_minimum03(self):
"minimum 3"
- labels = numarray.array([1, 2])
+ labels = numpy.array([1, 2])
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.minimum(input, labels = labels,
index = 2)
self.failUnless(output == 2.0)
def test_minimum04(self):
"minimum 4"
- labels = numarray.array([[1, 2], [2, 3]])
+ labels = numpy.array([[1, 2], [2, 3]])
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.minimum(input, labels = labels,
index = [2, 3, 8])
self.failUnless(output == [2.0, 4.0, 0.0])
def test_maximum01(self):
"maximum 1"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.maximum(input, labels = labels)
self.failUnless(output == 3.0)
def test_maximum02(self):
"maximum 2"
- labels = numarray.array([1, 0], bool)
- input = numarray.array([[2, 2], [2, 4]], bool)
+ labels = numpy.array([1, 0], bool)
+ input = numpy.array([[2, 2], [2, 4]], bool)
output = ndimage.maximum(input, labels = labels)
self.failUnless(output == 1.0)
def test_maximum03(self):
"maximum 3"
- labels = numarray.array([1, 2])
+ labels = numpy.array([1, 2])
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.maximum(input, labels = labels,
index = 2)
self.failUnless(output == 4.0)
def test_maximum04(self):
"maximum 4"
- labels = numarray.array([[1, 2], [2, 3]])
+ labels = numpy.array([[1, 2], [2, 3]])
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.maximum(input, labels = labels,
index = [2, 3, 8])
self.failUnless(output == [3.0, 4.0, 0.0])
@@ -2903,27 +2902,27 @@
def test_variance01(self):
"variance 1"
for type in self.types:
- input = numarray.array([], type)
+ input = numpy.array([], type)
output = ndimage.variance(input)
self.failUnless(float(output) == 0.0)
def test_variance02(self):
"variance 2"
for type in self.types:
- input = numarray.array([1], type)
+ input = numpy.array([1], type)
output = ndimage.variance(input)
self.failUnless(float(output) == 0.0)
def test_variance03(self):
"variance 3"
for type in self.types:
- input = numarray.array([1, 3], type)
+ input = numpy.array([1, 3], type)
output = ndimage.variance(input)
self.failUnless(output == 2.0)
def test_variance04(self):
"variance 4"
- input = numarray.array([1, 0], bool)
+ input = numpy.array([1, 0], bool)
output = ndimage.variance(input)
self.failUnless(output == 0.5)
@@ -2931,7 +2930,7 @@
"variance 5"
labels = [2, 2, 3]
for type in self.types:
- input = numarray.array([1, 3, 8], type)
+ input = numpy.array([1, 3, 8], type)
output = ndimage.variance(input, labels, 2)
self.failUnless(output == 2.0)
@@ -2939,34 +2938,34 @@
"variance 6"
labels = [2, 2, 3, 3, 4]
for type in self.types:
- input = numarray.array([1, 3, 8, 10, 8], type)
+ input = numpy.array([1, 3, 8, 10, 8], type)
output = ndimage.variance(input, labels, [2, 3, 4])
self.failUnless(output == [2.0, 2.0, 0.0])
def test_standard_deviation01(self):
"standard deviation 1"
for type in self.types:
- input = numarray.array([], type)
+ input = numpy.array([], type)
output = ndimage.standard_deviation(input)
self.failUnless(float(output) == 0.0)
def test_standard_deviation02(self):
"standard deviation 2"
for type in self.types:
- input = numarray.array([1], type)
+ input = numpy.array([1], type)
output = ndimage.standard_deviation(input)
self.failUnless(float(output) == 0.0)
def test_standard_deviation03(self):
"standard deviation 3"
for type in self.types:
- input = numarray.array([1, 3], type)
+ input = numpy.array([1, 3], type)
output = ndimage.standard_deviation(input)
self.failUnless(output == math.sqrt(2.0))
def test_standard_deviation04(self):
"standard deviation 4"
- input = numarray.array([1, 0], bool)
+ input = numpy.array([1, 0], bool)
output = ndimage.standard_deviation(input)
self.failUnless(output == math.sqrt(0.5))
@@ -2974,7 +2973,7 @@
"standard deviation 5"
labels = [2, 2, 3]
for type in self.types:
- input = numarray.array([1, 3, 8], type)
+ input = numpy.array([1, 3, 8], type)
output = ndimage.standard_deviation(input, labels, 2)
self.failUnless(output == math.sqrt(2.0))
@@ -2982,7 +2981,7 @@
"standard deviation 6"
labels = [2, 2, 3, 3, 4]
for type in self.types:
- input = numarray.array([1, 3, 8, 10, 8], type)
+ input = numpy.array([1, 3, 8, 10, 8], type)
output = ndimage.standard_deviation(input, labels,
[2, 3, 4])
self.failUnless(output == [math.sqrt(2.0), math.sqrt(2.0),
@@ -2990,9 +2989,9 @@
def test_minimum_position01(self):
"minimum position 1"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.minimum_position(input,
labels = labels)
self.failUnless(output == (0, 0))
@@ -3000,7 +2999,7 @@
def test_minimum_position02(self):
"minimum position 2"
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 0, 2],
[1, 5, 1, 1]], type)
output = ndimage.minimum_position(input)
@@ -3008,7 +3007,7 @@
def test_minimum_position03(self):
"minimum position 3"
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 0, 2],
[1, 5, 1, 1]], bool)
output = ndimage.minimum_position(input)
@@ -3016,7 +3015,7 @@
def test_minimum_position04(self):
"minimum position 4"
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 1, 2],
[1, 5, 1, 1]], bool)
output = ndimage.minimum_position(input)
@@ -3026,7 +3025,7 @@
"minimum position 5"
labels = [1, 2, 0, 4]
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 0, 2],
[1, 5, 2, 3]], type)
output = ndimage.minimum_position(input, labels)
@@ -3036,7 +3035,7 @@
"minimum position 6"
labels = [1, 2, 3, 4]
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 0, 2],
[1, 5, 1, 1]], type)
output = ndimage.minimum_position(input, labels, 2)
@@ -3046,7 +3045,7 @@
"minimum position 7"
labels = [1, 2, 3, 4]
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 0, 2],
[1, 5, 1, 1]], type)
output = ndimage.minimum_position(input, labels,
@@ -3055,9 +3054,9 @@
def test_maximum_position01(self):
"maximum position 1"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output = ndimage.maximum_position(input,
labels = labels)
self.failUnless(output == (1, 0))
@@ -3065,7 +3064,7 @@
def test_maximum_position02(self):
"maximum position 2"
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 8, 2],
[1, 5, 1, 1]], type)
output = ndimage.maximum_position(input)
@@ -3073,7 +3072,7 @@
def test_maximum_position03(self):
"maximum position 3"
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 8, 2],
[1, 5, 1, 1]], bool)
output = ndimage.maximum_position(input)
@@ -3083,7 +3082,7 @@
"maximum position 4"
labels = [1, 2, 0, 4]
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 8, 2],
[1, 5, 1, 1]], type)
output = ndimage.maximum_position(input, labels)
@@ -3093,7 +3092,7 @@
"maximum position 5"
labels = [1, 2, 0, 4]
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 8, 2],
[1, 5, 1, 1]], type)
output = ndimage.maximum_position(input, labels, 1)
@@ -3103,7 +3102,7 @@
"maximum position 6"
labels = [1, 2, 0, 4]
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 8, 2],
[1, 5, 1, 1]], type)
output = ndimage.maximum_position(input, labels,
@@ -3112,9 +3111,9 @@
def test_extrema01(self):
"extrema 1"
- labels = numarray.array([1, 0], bool)
+ labels = numpy.array([1, 0], bool)
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output1 = ndimage.extrema(input, labels = labels)
output2 = ndimage.minimum(input, labels = labels)
output3 = ndimage.maximum(input, labels = labels)
@@ -3127,9 +3126,9 @@
def test_extrema02(self):
"extrema 2"
- labels = numarray.array([1, 2])
+ labels = numpy.array([1, 2])
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output1 = ndimage.extrema(input, labels = labels,
index = 2)
output2 = ndimage.minimum(input, labels = labels,
@@ -3145,9 +3144,9 @@
def test_extrema03(self):
"extrema 3"
- labels = numarray.array([[1, 2], [2, 3]])
+ labels = numpy.array([[1, 2], [2, 3]])
for type in self.types:
- input = numarray.array([[1, 2], [3, 4]], type)
+ input = numpy.array([[1, 2], [3, 4]], type)
output1 = ndimage.extrema(input, labels = labels,
index = [2, 3, 8])
output2 = ndimage.minimum(input, labels = labels,
@@ -3165,7 +3164,7 @@
"extrema 4"
labels = [1, 2, 0, 4]
for type in self.types:
- input = numarray.array([[5, 4, 2, 5],
+ input = numpy.array([[5, 4, 2, 5],
[3, 7, 8, 2],
[1, 5, 1, 1]], type)
output1 = ndimage.extrema(input, labels, [1, 2])
@@ -3182,7 +3181,7 @@
"center of mass 1"
true = [0.0, 0.0]
for type in self.types:
- input = numarray.array([[1, 0], [0, 0]], type)
+ input = numpy.array([[1, 0], [0, 0]], type)
output = ndimage.center_of_mass(input)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3191,7 +3190,7 @@
"center of mass 2"
true = [1, 0]
for type in self.types:
- input = numarray.array([[0, 0], [1, 0]], type)
+ input = numpy.array([[0, 0], [1, 0]], type)
output = ndimage.center_of_mass(input)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3200,7 +3199,7 @@
"center of mass 3"
true = [0, 1]
for type in self.types:
- input = numarray.array([[0, 1], [0, 0]], type)
+ input = numpy.array([[0, 1], [0, 0]], type)
output = ndimage.center_of_mass(input)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3209,7 +3208,7 @@
"center of mass 4"
true = [1, 1]
for type in self.types:
- input = numarray.array([[0, 0], [0, 1]], type)
+ input = numpy.array([[0, 0], [0, 1]], type)
output = ndimage.center_of_mass(input)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3218,7 +3217,7 @@
"center of mass 5"
true = [0.5, 0.5]
for type in self.types:
- input = numarray.array([[1, 1], [1, 1]], type)
+ input = numpy.array([[1, 1], [1, 1]], type)
output = ndimage.center_of_mass(input)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3226,7 +3225,7 @@
def test_center_of_mass06(self):
"center of mass 6"
true = [0.5, 0.5]
- input = numarray.array([[1, 2], [3, 1]], bool)
+ input = numpy.array([[1, 2], [3, 1]], bool)
output = ndimage.center_of_mass(input)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3235,7 +3234,7 @@
"center of mass 7"
labels = [1, 0]
true = [0.5, 0.0]
- input = numarray.array([[1, 2], [3, 1]], bool)
+ input = numpy.array([[1, 2], [3, 1]], bool)
output = ndimage.center_of_mass(input, labels)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3244,7 +3243,7 @@
"center of mass 8"
labels = [1, 2]
true = [0.5, 1.0]
- input = numarray.array([[5, 2], [3, 1]], bool)
+ input = numpy.array([[5, 2], [3, 1]], bool)
output = ndimage.center_of_mass(input, labels, 2)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3254,15 +3253,15 @@
"center of mass 9"
labels = [1, 2]
true = [(0.5, 0.0), (0.5, 1.0)]
- input = numarray.array([[1, 2], [1, 1]], bool)
+ input = numpy.array([[1, 2], [1, 1]], bool)
output = ndimage.center_of_mass(input, labels, [1, 2])
e = diff(true, output)
self.failUnless(e < eps)
def test_histogram01(self):
"histogram 1"
- true = numarray.ones(10)
- input = numarray.arange(10)
+ true = numpy.ones(10)
+ input = numpy.arange(10)
output = ndimage.histogram(input, 0, 10, 10)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3271,7 +3270,7 @@
"histogram 2"
labels = [1, 1, 1, 1, 2, 2, 2, 2]
true = [0, 2, 0, 1, 0]
- input = numarray.array([1, 1, 3, 4, 3, 3, 3, 3])
+ input = numpy.array([1, 1, 3, 4, 3, 3, 3, 3])
output = ndimage.histogram(input, 0, 4, 5, labels, 1)
e = diff(true, output)
self.failUnless(e < eps)
@@ -3281,7 +3280,7 @@
labels = [1, 0, 1, 1, 2, 2, 2, 2]
true1 = [0, 1, 0, 1, 0]
true2 = [0, 0, 0, 3, 0]
- input = numarray.array([1, 1, 3, 4, 3, 5, 3, 3])
+ input = numpy.array([1, 1, 3, 4, 3, 5, 3, 3])
output = ndimage.histogram(input, 0, 4, 5, labels, (1,2))
e1 = diff(true1, output[0])
e2 = diff(true2, output[1])
@@ -3290,7 +3289,7 @@
def test_distance_transform_bf01(self):
"brute force distance transform 1"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3334,7 +3333,7 @@
def test_distance_transform_bf02(self):
"brute force distance transform 2"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3377,7 +3376,7 @@
def test_distance_transform_bf03(self):
"brute force distance transform 3"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3420,7 +3419,7 @@
def test_distance_transform_bf04(self):
"brute force distance transform 4"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3433,13 +3432,13 @@
return_indices = 1)
dts = []
fts = []
- dt = numarray.zeros(data.shape, dtype = numarray.float64)
+ dt = numpy.zeros(data.shape, dtype = numpy.float64)
ndimage.distance_transform_bf(data, distances = dt)
dts.append(dt)
ft = ndimage.distance_transform_bf(data,
return_distances = False, return_indices = 1)
fts.append(ft)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
ndimage.distance_transform_bf(data,
return_distances = False, return_indices = True, indices = ft)
fts.append(ft)
@@ -3447,18 +3446,18 @@
return_indices = 1)
dts.append(dt)
fts.append(ft)
- dt = numarray.zeros(data.shape, dtype = numarray.float64)
+ dt = numpy.zeros(data.shape, dtype = numpy.float64)
ft = ndimage.distance_transform_bf(data, distances = dt,
return_indices = True)
dts.append(dt)
fts.append(ft)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
dt = ndimage.distance_transform_bf(data,
return_indices = True, indices = ft)
dts.append(dt)
fts.append(ft)
- dt = numarray.zeros(data.shape, dtype = numarray.float64)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ dt = numpy.zeros(data.shape, dtype = numpy.float64)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
ndimage.distance_transform_bf(data, distances = dt,
return_indices = True, indices = ft)
dts.append(dt)
@@ -3471,7 +3470,7 @@
def test_distance_transform_bf05(self):
"brute force distance transform 5"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3514,7 +3513,7 @@
def test_distance_transform_bf06(self):
"brute force distance transform 6"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3558,7 +3557,7 @@
def test_distance_transform_cdt01(self):
"chamfer type distance transform 1"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3594,7 +3593,7 @@
def test_distance_transform_cdt02(self):
"chamfer type distance transform 2"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3630,7 +3629,7 @@
def test_distance_transform_cdt03(self):
"chamfer type distance transform 3"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3643,13 +3642,13 @@
return_indices = True)
dts = []
fts = []
- dt = numarray.zeros(data.shape, dtype = numarray.int32)
+ dt = numpy.zeros(data.shape, dtype = numpy.int32)
ndimage.distance_transform_cdt(data, distances = dt)
dts.append(dt)
ft = ndimage.distance_transform_cdt(data,
return_distances = False, return_indices = True)
fts.append(ft)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
ndimage.distance_transform_cdt(data,
return_distances = False, return_indices = True, indices = ft)
fts.append(ft)
@@ -3657,18 +3656,18 @@
return_indices = True)
dts.append(dt)
fts.append(ft)
- dt = numarray.zeros(data.shape, dtype = numarray.int32)
+ dt = numpy.zeros(data.shape, dtype = numpy.int32)
ft = ndimage.distance_transform_cdt(data, distances = dt,
return_indices = True)
dts.append(dt)
fts.append(ft)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
dt = ndimage.distance_transform_cdt(data,
return_indices = True, indices = ft)
dts.append(dt)
fts.append(ft)
- dt = numarray.zeros(data.shape, dtype = numarray.int32)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ dt = numpy.zeros(data.shape, dtype = numpy.int32)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
ndimage.distance_transform_cdt(data, distances = dt,
return_indices = True, indices = ft)
dts.append(dt)
@@ -3681,7 +3680,7 @@
def test_distance_transform_edt01(self):
"euclidean distance transform 1"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3695,18 +3694,18 @@
bf = ndimage.distance_transform_bf(data, 'euclidean')
error1 = diff(bf, out)
- dt = ft - numarray.indices(ft.shape[1:], dtype = ft.dtype)
- dt = dt.astype(numarray.float64)
- numarray.multiply(dt, dt, dt)
- dt = numarray.add.reduce(dt, axis = 0)
- numarray.sqrt(dt, dt)
+ dt = ft - numpy.indices(ft.shape[1:], dtype = ft.dtype)
+ dt = dt.astype(numpy.float64)
+ numpy.multiply(dt, dt, dt)
+ dt = numpy.add.reduce(dt, axis = 0)
+ numpy.sqrt(dt, dt)
error2 = diff(bf, dt)
self.failUnless(error1 < eps and error2 < eps)
def test_distance_transform_edt02(self):
"euclidean distance transform 2"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3719,13 +3718,13 @@
return_indices = True)
dts = []
fts = []
- dt = numarray.zeros(data.shape, dtype = numarray.float64)
+ dt = numpy.zeros(data.shape, dtype = numpy.float64)
ndimage.distance_transform_edt(data, distances = dt)
dts.append(dt)
ft = ndimage.distance_transform_edt(data,
return_distances = 0, return_indices = True)
fts.append(ft)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
ndimage.distance_transform_edt(data,
return_distances = False,return_indices = True, indices = ft)
fts.append(ft)
@@ -3733,18 +3732,18 @@
return_indices = True)
dts.append(dt)
fts.append(ft)
- dt = numarray.zeros(data.shape, dtype = numarray.float64)
+ dt = numpy.zeros(data.shape, dtype = numpy.float64)
ft = ndimage.distance_transform_edt(data, distances = dt,
return_indices = True)
dts.append(dt)
fts.append(ft)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
dt = ndimage.distance_transform_edt(data,
return_indices = True, indices = ft)
dts.append(dt)
fts.append(ft)
- dt = numarray.zeros(data.shape, dtype = numarray.float64)
- ft = numarray.indices(data.shape, dtype = numarray.int32)
+ dt = numpy.zeros(data.shape, dtype = numpy.float64)
+ ft = numpy.indices(data.shape, dtype = numpy.int32)
ndimage.distance_transform_edt(data, distances = dt,
return_indices = True, indices = ft)
dts.append(dt)
@@ -3757,7 +3756,7 @@
def test_distance_transform_edt03(self):
"euclidean distance transform 3"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3776,7 +3775,7 @@
def test_distance_transform_edt4(self):
"euclidean distance transform 4"
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
@@ -3855,63 +3854,63 @@
def test_binary_erosion01(self):
"binary erosion 1"
for type in self.types:
- data = numarray.ones([], type)
+ data = numpy.ones([], type)
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, 1) < eps)
def test_binary_erosion02(self):
"binary erosion 2"
for type in self.types:
- data = numarray.ones([], type)
+ data = numpy.ones([], type)
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, 1) < eps)
def test_binary_erosion03(self):
"binary erosion 3"
for type in self.types:
- data = numarray.ones([1], type)
+ data = numpy.ones([1], type)
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, [0]) < eps)
def test_binary_erosion04(self):
"binary erosion 4"
for type in self.types:
- data = numarray.ones([1], type)
+ data = numpy.ones([1], type)
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, [1]) < eps)
def test_binary_erosion05(self):
"binary erosion 5"
for type in self.types:
- data = numarray.ones([3], type)
+ data = numpy.ones([3], type)
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, [0, 1, 0]) < eps)
def test_binary_erosion06(self):
"binary erosion 6"
for type in self.types:
- data = numarray.ones([3], type)
+ data = numpy.ones([3], type)
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, [1, 1, 1]) < eps)
def test_binary_erosion07(self):
"binary erosion 7"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, [0, 1, 1, 1, 0]) < eps)
def test_binary_erosion08(self):
"binary erosion 8"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, [1, 1, 1, 1, 1]) < eps)
def test_binary_erosion09(self):
"binary erosion 9"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
data[2] = 0
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, [0, 0, 0, 0, 0]) < eps)
@@ -3919,7 +3918,7 @@
def test_binary_erosion10(self):
"binary erosion 10"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
data[2] = 0
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, [1, 0, 0, 0, 1]) < eps)
@@ -3927,7 +3926,7 @@
def test_binary_erosion11(self):
"binary erosion 11"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
data[2] = 0
struct = [1, 0, 1]
out = ndimage.binary_erosion(data, struct,
@@ -3937,7 +3936,7 @@
def test_binary_erosion12(self):
"binary erosion 12"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
data[2] = 0
struct = [1, 0, 1]
out = ndimage.binary_erosion(data, struct,
@@ -3948,7 +3947,7 @@
def test_binary_erosion13(self):
"binary erosion 13"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
data[2] = 0
struct = [1, 0, 1]
out = ndimage.binary_erosion(data, struct,
@@ -3959,7 +3958,7 @@
def test_binary_erosion14(self):
"binary erosion 14"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
data[2] = 0
struct = [1, 1]
out = ndimage.binary_erosion(data, struct,
@@ -3969,7 +3968,7 @@
def test_binary_erosion15(self):
"binary erosion 15"
for type in self.types:
- data = numarray.ones([5], type)
+ data = numpy.ones([5], type)
data[2] = 0
struct = [1, 1]
out = ndimage.binary_erosion(data, struct,
@@ -3980,35 +3979,35 @@
def test_binary_erosion16(self):
"binary erosion 16"
for type in self.types:
- data = numarray.ones([1, 1], type)
+ data = numpy.ones([1, 1], type)
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, [[1]]) < eps)
def test_binary_erosion17(self):
"binary erosion 17"
for type in self.types:
- data = numarray.ones([1, 1], type)
+ data = numpy.ones([1, 1], type)
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, [[0]]) < eps)
def test_binary_erosion18(self):
"binary erosion 18"
for type in self.types:
- data = numarray.ones([1, 3], type)
+ data = numpy.ones([1, 3], type)
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, [[0, 0, 0]]) < eps)
def test_binary_erosion19(self):
"binary erosion 19"
for type in self.types:
- data = numarray.ones([1, 3], type)
+ data = numpy.ones([1, 3], type)
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, [[1, 1, 1]]) < eps)
def test_binary_erosion20(self):
"binary erosion 20"
for type in self.types:
- data = numarray.ones([3, 3], type)
+ data = numpy.ones([3, 3], type)
out = ndimage.binary_erosion(data)
self.failUnless(diff(out, [[0, 0, 0],
[0, 1, 0],
@@ -4017,7 +4016,7 @@
def test_binary_erosion21(self):
"binary erosion 21"
for type in self.types:
- data = numarray.ones([3, 3], type)
+ data = numpy.ones([3, 3], type)
out = ndimage.binary_erosion(data, border_value = 1)
self.failUnless(diff(out, [[1, 1, 1],
[1, 1, 1],
@@ -4034,7 +4033,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 1, 1, 1],
@@ -4057,7 +4056,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 1, 1, 1],
@@ -4082,7 +4081,7 @@
[0, 0, 1, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 1, 1, 1],
@@ -4108,7 +4107,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 0, 1, 1],
@@ -4134,7 +4133,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 0, 1, 1],
@@ -4158,7 +4157,7 @@
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
@@ -4181,14 +4180,14 @@
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[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]], bool)
- out = numarray.zeros(data.shape, bool)
+ out = numpy.zeros(data.shape, bool)
ndimage.binary_erosion(data, struct, border_value = 1,
iterations = 2, output = out)
self.failUnless(diff(out, true) < eps)
@@ -4205,7 +4204,7 @@
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 1, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1],
@@ -4228,14 +4227,14 @@
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 1, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[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]], bool)
- out = numarray.zeros(data.shape, bool)
+ out = numpy.zeros(data.shape, bool)
ndimage.binary_erosion(data, struct, border_value = 1,
iterations = 3, output = out)
self.failUnless(diff(out, true) < eps)
@@ -4252,14 +4251,14 @@
[0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 1]]
- data = numarray.array([[0, 0, 0, 1, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[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]], bool)
- out = numarray.zeros(data.shape, bool)
+ out = numpy.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)
@@ -4276,7 +4275,7 @@
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
@@ -4306,7 +4305,7 @@
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1]]
- data = numarray.array([[0, 0, 0, 0, 0, 1, 1],
+ data = numpy.array([[0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 1, 0, 0, 1],
[0, 0, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
@@ -4336,7 +4335,7 @@
[0, 0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
@@ -4359,7 +4358,7 @@
[0, 0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 1, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1],
@@ -4373,10 +4372,10 @@
[0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 1]]
- 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, bool)
+ true = numpy.logical_and(tmp, mask)
+ tmp = numpy.logical_and(data, numpy.logical_not(mask))
+ true = numpy.logical_or(true, tmp)
+ out = numpy.zeros(data.shape, bool)
ndimage.binary_erosion(data, struct, border_value = 1,
iterations = 1, output = out,
origin = (-1, -1), mask = mask)
@@ -4403,7 +4402,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1]]
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 0, 1, 1],
@@ -4411,9 +4410,9 @@
[0, 1, 0, 1, 1, 1, 1, 0],
[0, 1, 1, 0, 0, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0]])
- true = numarray.logical_and(tmp, mask)
- tmp = numarray.logical_and(data, numarray.logical_not(mask))
- true = numarray.logical_or(true, tmp)
+ true = numpy.logical_and(tmp, mask)
+ tmp = numpy.logical_and(data, numpy.logical_not(mask))
+ true = numpy.logical_or(true, tmp)
out = ndimage.binary_erosion(data, struct, mask = mask,
border_value = 1, origin = (-1, -1))
self.failUnless(diff(out, true) < eps)
@@ -4421,42 +4420,42 @@
def test_binary_dilation01(self):
"binary dilation 1"
for type in self.types:
- data = numarray.ones([], type)
+ data = numpy.ones([], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, 1) < eps)
def test_binary_dilation02(self):
"binary dilation 2"
for type in self.types:
- data = numarray.zeros([], type)
+ data = numpy.zeros([], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, 0) < eps)
def test_binary_dilation03(self):
"binary dilation 3"
for type in self.types:
- data = numarray.ones([1], type)
+ data = numpy.ones([1], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [1]) < eps)
def test_binary_dilation04(self):
"binary dilation 4"
for type in self.types:
- data = numarray.zeros([1], type)
+ data = numpy.zeros([1], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [0]) < eps)
def test_binary_dilation05(self):
"binary dilation 5"
for type in self.types:
- data = numarray.ones([3], type)
+ data = numpy.ones([3], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [1, 1, 1]) < eps)
def test_binary_dilation06(self):
"binary dilation 6"
for type in self.types:
- data = numarray.zeros([3], type)
+ data = numpy.zeros([3], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [0, 0, 0]) < eps)
@@ -4464,7 +4463,7 @@
"binary dilation 7"
struct = ndimage.generate_binary_structure(1, 1)
for type in self.types:
- data = numarray.zeros([3], type)
+ data = numpy.zeros([3], type)
data[1] = 1
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [1, 1, 1]) < eps)
@@ -4472,7 +4471,7 @@
def test_binary_dilation08(self):
"binary dilation 8"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
data[3] = 1
out = ndimage.binary_dilation(data)
@@ -4481,7 +4480,7 @@
def test_binary_dilation09(self):
"binary dilation 9"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [1, 1, 1, 0, 0]) < eps)
@@ -4489,7 +4488,7 @@
def test_binary_dilation10(self):
"binary dilation 10"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
out = ndimage.binary_dilation(data, origin = -1)
self.failUnless(diff(out, [0, 1, 1, 1, 0]) < eps)
@@ -4497,7 +4496,7 @@
def test_binary_dilation11(self):
"binary dilation 11"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
out = ndimage.binary_dilation(data, origin = 1)
self.failUnless(diff(out, [1, 1, 0, 0, 0]) < eps)
@@ -4505,7 +4504,7 @@
def test_binary_dilation12(self):
"binary dilation 12"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
struct = [1, 0, 1]
out = ndimage.binary_dilation(data, struct)
@@ -4514,7 +4513,7 @@
def test_binary_dilation13(self):
"binary dilation 13"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
struct = [1, 0, 1]
out = ndimage.binary_dilation(data, struct,
@@ -4524,7 +4523,7 @@
def test_binary_dilation14(self):
"binary dilation 14"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
struct = [1, 0, 1]
out = ndimage.binary_dilation(data, struct,
@@ -4534,7 +4533,7 @@
def test_binary_dilation15(self):
"binary dilation 15"
for type in self.types:
- data = numarray.zeros([5], type)
+ data = numpy.zeros([5], type)
data[1] = 1
struct = [1, 0, 1]
out = ndimage.binary_dilation(data, struct,
@@ -4544,28 +4543,28 @@
def test_binary_dilation16(self):
"binary dilation 16"
for type in self.types:
- data = numarray.ones([1, 1], type)
+ data = numpy.ones([1, 1], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [[1]]) < eps)
def test_binary_dilation17(self):
"binary dilation 17"
for type in self.types:
- data = numarray.zeros([1, 1], type)
+ data = numpy.zeros([1, 1], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [[0]]) < eps)
def test_binary_dilation18(self):
"binary dilation 18"
for type in self.types:
- data = numarray.ones([1, 3], type)
+ data = numpy.ones([1, 3], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [[1, 1, 1]]) < eps)
def test_binary_dilation19(self):
"binary dilation 19"
for type in self.types:
- data = numarray.ones([3, 3], type)
+ data = numpy.ones([3, 3], type)
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [[1, 1, 1],
[1, 1, 1],
@@ -4574,7 +4573,7 @@
def test_binary_dilation20(self):
"binary dilation 20"
for type in self.types:
- data = numarray.zeros([3, 3], type)
+ data = numpy.zeros([3, 3], type)
data[1, 1] = 1
out = ndimage.binary_dilation(data)
self.failUnless(diff(out, [[0, 1, 0],
@@ -4585,7 +4584,7 @@
"binary dilation 21"
struct = ndimage.generate_binary_structure(2, 2)
for type in self.types:
- data = numarray.zeros([3, 3], type)
+ data = numpy.zeros([3, 3], type)
data[1, 1] = 1
out = ndimage.binary_dilation(data, struct)
self.failUnless(diff(out, [[1, 1, 1],
@@ -4604,7 +4603,7 @@
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4627,7 +4626,7 @@
[1, 1, 1, 1, 1, 1, 1, 1]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4650,7 +4649,7 @@
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4673,7 +4672,7 @@
[1, 1, 1, 1, 1, 1, 1, 1]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4698,7 +4697,7 @@
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4723,7 +4722,7 @@
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4742,7 +4741,7 @@
[1, 1, 1, 1]]
for type in self.types:
- data = numarray.array([[0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], type)
@@ -4759,7 +4758,7 @@
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 1, 0],
@@ -4778,12 +4777,12 @@
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 0]], bool)
- out = numarray.zeros(data.shape, bool)
+ out = numpy.zeros(data.shape, bool)
ndimage.binary_dilation(data, struct, iterations = 2,
output = out)
self.failUnless(diff(out, true) < eps)
@@ -4798,7 +4797,7 @@
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 1, 0],
@@ -4817,12 +4816,12 @@
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0]]
- data = numarray.array([[0, 0, 0, 0, 0],
+ data = numpy.array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 0]], bool)
- out = numarray.zeros(data.shape, bool)
+ out = numpy.zeros(data.shape, bool)
ndimage.binary_dilation(data, struct, iterations = 3,
output = out)
self.failUnless(diff(out, true) < eps)
@@ -4832,7 +4831,7 @@
struct = [[0, 1, 0],
[1, 1, 1],
[0, 1, 0]]
- true = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ true = numpy.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],
[0, 0, 0, 0, 1, 1, 0, 0],
@@ -4840,7 +4839,7 @@
[0, 1, 1, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- mask = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ mask = numpy.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],
[0, 0, 0, 0, 1, 1, 0, 0],
@@ -4848,7 +4847,7 @@
[0, 1, 1, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- data = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ data = numpy.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],
[0, 0, 0, 0, 0, 0, 0, 0],
@@ -4874,7 +4873,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
- mask = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ mask = numpy.array([[0, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0],
@@ -4882,7 +4881,7 @@
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- data = numarray.zeros(mask.shape, bool)
+ data = numpy.zeros(mask.shape, bool)
out = ndimage.binary_dilation(data, struct,
iterations = -1, mask = mask, border_value = 1)
self.failUnless(diff(out, true) < eps)
@@ -4897,7 +4896,7 @@
[0, 1, 0, 0, 1, 0, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1]]
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4913,11 +4912,11 @@
[0, 0, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
- true = numarray.logical_and(tmp, mask)
- tmp = numarray.logical_and(data, numarray.logical_not(mask))
- true = numarray.logical_or(true, tmp)
+ true = numpy.logical_and(tmp, mask)
+ tmp = numpy.logical_and(data, numpy.logical_not(mask))
+ true = numpy.logical_or(true, tmp)
for type in self.types:
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[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, 1, 0, 0],
@@ -4934,7 +4933,7 @@
struct = [[0, 1, 0],
[1, 1, 1],
[0, 1, 0]]
- true = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ true = numpy.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],
[0, 0, 0, 0, 1, 1, 0, 0],
@@ -4942,7 +4941,7 @@
[0, 1, 1, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- mask = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ mask = numpy.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],
[0, 0, 0, 0, 1, 1, 0, 0],
@@ -4950,7 +4949,7 @@
[0, 1, 1, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- data = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ data = numpy.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],
[0, 0, 0, 0, 0, 0, 0, 0],
@@ -4976,7 +4975,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
- mask = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ mask = numpy.array([[0, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0],
@@ -4984,7 +4983,7 @@
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- data = numarray.zeros(mask.shape, bool)
+ data = numpy.zeros(mask.shape, bool)
out = ndimage.binary_propagation(data, struct,
mask = mask, border_value = 1)
self.failUnless(diff(out, true) < eps)
@@ -5000,7 +4999,7 @@
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 1, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 0],
@@ -5023,7 +5022,7 @@
[0, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[1, 1, 1, 0, 0, 0, 0, 0],
+ data = numpy.array([[1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 1, 1, 0],
@@ -5045,7 +5044,7 @@
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 1, 0, 0, 0, 0, 0, 0],
+ data = numpy.array([[0, 1, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 0],
@@ -5068,7 +5067,7 @@
[0, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[1, 1, 1, 0, 0, 0, 0, 0],
+ data = numpy.array([[1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 1, 1, 0],
@@ -5081,14 +5080,14 @@
def test_binary_fill_holes01(self):
"binary fill holes 1"
- true = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ true = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[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, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.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],
@@ -5100,14 +5099,14 @@
def test_binary_fill_holes02(self):
"binary fill holes 2"
- true = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ true = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0],
[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, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], bool)
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.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],
@@ -5119,14 +5118,14 @@
def test_binary_fill_holes03(self):
"binary fill holes 3"
- true = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ true = numpy.array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 1, 1, 1],
[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]], bool)
- data = numarray.array([[0, 0, 0, 0, 0, 0, 0, 0],
+ data = numpy.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],
@@ -5138,7 +5137,7 @@
def test_grey_erosion01(self):
"grey erosion 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5150,7 +5149,7 @@
def test_grey_erosion02(self):
"grey erosion 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5163,7 +5162,7 @@
def test_grey_erosion03(self):
"grey erosion 3"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5176,7 +5175,7 @@
def test_grey_dilation01(self):
"grey dilation 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[0, 1, 1], [1, 0, 1]]
@@ -5188,7 +5187,7 @@
def test_grey_dilation02(self):
"grey dilation 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[0, 1, 1], [1, 0, 1]]
@@ -5201,7 +5200,7 @@
def test_grey_dilation03(self):
"grey dilation 3"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[0, 1, 1], [1, 0, 1]]
@@ -5214,7 +5213,7 @@
def test_grey_opening01(self):
"grey opening 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5227,7 +5226,7 @@
def test_grey_opening02(self):
"grey opening 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5242,7 +5241,7 @@
def test_grey_closing01(self):
"grey closing 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5254,7 +5253,7 @@
def test_grey_closing02(self):
"grey closing 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5269,7 +5268,7 @@
def test_morphological_gradient01(self):
"morphological gradient 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5279,14 +5278,14 @@
tmp2 = ndimage.grey_erosion(array, footprint = footprint,
structure = structure)
true = tmp1 - tmp2
- output = numarray.zeros(array.shape, array.dtype)
+ output = numpy.zeros(array.shape, array.dtype)
ndimage.morphological_gradient(array,
footprint=footprint, structure=structure, output = output)
self.failUnless(diff(true, output) < eps)
def test_morphological_gradient02(self):
"morphological gradient 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5302,7 +5301,7 @@
def test_morphological_laplace01(self):
"morphological laplace 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5312,14 +5311,14 @@
tmp2 = ndimage.grey_erosion(array, footprint = footprint,
structure = structure)
true = tmp1 + tmp2 - 2 * array
- output = numarray.zeros(array.shape, array.dtype)
+ output = numpy.zeros(array.shape, array.dtype)
ndimage.morphological_laplace(array, footprint=footprint,
structure=structure, output = output)
self.failUnless(diff(true, output) < eps)
def test_morphological_laplace02(self):
"morphological laplace 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5335,7 +5334,7 @@
def test_white_tophat01(self):
"white tophat 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5343,14 +5342,14 @@
tmp = ndimage.grey_opening(array, footprint = footprint,
structure = structure)
true = array - tmp
- output = numarray.zeros(array.shape, array.dtype)
+ output = numpy.zeros(array.shape, array.dtype)
ndimage.white_tophat(array, footprint=footprint,
structure=structure, output = output)
self.failUnless(diff(true, output) < eps)
def test_white_tophat02(self):
"white tophat 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5364,7 +5363,7 @@
def test_black_tophat01(self):
"black tophat 1"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5372,14 +5371,14 @@
tmp = ndimage.grey_closing(array, footprint = footprint,
structure = structure)
true = tmp - array
- output = numarray.zeros(array.shape, array.dtype)
+ output = numpy.zeros(array.shape, array.dtype)
ndimage.black_tophat(array, footprint=footprint,
structure=structure, output = output)
self.failUnless(diff(true, output) < eps)
def test_black_tophat02(self):
"black tophat 2"
- array = numarray.array([[3, 2, 5, 1, 4],
+ array = numpy.array([[3, 2, 5, 1, 4],
[7, 6, 9, 3, 5],
[5, 8, 3, 7, 1]])
footprint = [[1, 0, 1], [1, 1, 0]]
@@ -5405,7 +5404,7 @@
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 1, 0, 0, 0],
+ data = numpy.array([[0, 1, 0, 0, 0],
[1, 1, 1, 0, 0],
[0, 1, 0, 1, 1],
[0, 0, 1, 1, 1],
@@ -5413,7 +5412,7 @@
[0, 1, 1, 1, 1],
[0, 1, 1, 1, 1],
[0, 0, 0, 0, 0]], type)
- out = numarray.zeros(data.shape, bool)
+ out = numpy.zeros(data.shape, bool)
ndimage.binary_hit_or_miss(data, struct,
output = out)
self.failUnless(diff(true, out) < eps)
@@ -5428,7 +5427,7 @@
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 1, 0, 0, 1, 1, 1, 0],
+ data = numpy.array([[0, 1, 0, 0, 1, 1, 1, 0],
[1, 1, 1, 0, 0, 1, 0, 0],
[0, 1, 0, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], type)
@@ -5452,7 +5451,7 @@
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]
for type in self.types:
- data = numarray.array([[0, 1, 0, 0, 1, 1, 1, 0],
+ data = numpy.array([[0, 1, 0, 0, 1, 1, 1, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 1, 1, 0],
More information about the Scipy-svn
mailing list