[Scipy-svn] r6386 - in trunk/scipy: io/matlab/tests io/tests ndimage ndimage/tests signal signal/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sat May 8 11:05:47 EDT 2010
Author: ptvirtan
Date: 2010-05-08 10:05:47 -0500 (Sat, 08 May 2010)
New Revision: 6386
Modified:
trunk/scipy/io/matlab/tests/test_mio5_utils.py
trunk/scipy/io/tests/test_netcdf.py
trunk/scipy/ndimage/measurements.py
trunk/scipy/ndimage/tests/test_ndimage.py
trunk/scipy/signal/signaltools.py
trunk/scipy/signal/tests/test_filter_design.py
Log:
BUG: ndimage/signal: replace python2.5/2.6-isms with backward compatible constructs
Modified: trunk/scipy/io/matlab/tests/test_mio5_utils.py
===================================================================
--- trunk/scipy/io/matlab/tests/test_mio5_utils.py 2010-05-08 14:16:06 UTC (rev 6385)
+++ trunk/scipy/io/matlab/tests/test_mio5_utils.py 2010-05-08 15:05:47 UTC (rev 6386)
@@ -72,7 +72,8 @@
def _make_readerlike():
- class R(): pass
+ class R(object):
+ pass
r = R()
r.byte_order = boc.native_code
r.dtypes = {}
Modified: trunk/scipy/io/tests/test_netcdf.py
===================================================================
--- trunk/scipy/io/tests/test_netcdf.py 2010-05-08 14:16:06 UTC (rev 6385)
+++ trunk/scipy/io/tests/test_netcdf.py 2010-05-08 15:05:47 UTC (rev 6386)
@@ -74,9 +74,12 @@
for testargs in gen_for_simple(f):
yield testargs
f.close()
- finally:
+ except:
os.chdir(cwd)
shutil.rmtree(tmpdir)
+ raise
+ os.chdir(cwd)
+ shutil.rmtree(tmpdir)
def test_read_write_sio():
Modified: trunk/scipy/ndimage/measurements.py
===================================================================
--- trunk/scipy/ndimage/measurements.py 2010-05-08 14:16:06 UTC (rev 6385)
+++ trunk/scipy/ndimage/measurements.py 2010-05-08 15:05:47 UTC (rev 6386)
@@ -31,6 +31,7 @@
import types
import math
import numpy
+import numpy as np
import _ni_support
import _nd_image
import morphology
@@ -218,7 +219,7 @@
return func(input[labels > 0], positions[labels > 0])
index = numpy.atleast_1d(index)
- if any(index.astype(labels.dtype).astype(index.dtype) != index):
+ if np.any(index.astype(labels.dtype).astype(index.dtype) != index):
raise ValueError, "Cannot convert index values from <%s> to <%s> (labels' type) without loss of precision"%(index.dtype, labels.dtype)
index = index.astype(labels.dtype)
@@ -426,11 +427,17 @@
if index is None:
mask = (labels > 0)
- return single_group(input[mask], positions[mask] if find_positions else None)
+ masked_positions = None
+ if find_positions:
+ masked_positions = positions[mask]
+ return single_group(input[mask], masked_positions)
if numpy.isscalar(index):
mask = (labels == index)
- return single_group(input[mask], positions[mask] if find_positions else None)
+ masked_positions = None
+ if find_positions:
+ masked_positions = positions[mask]
+ return single_group(input[mask], masked_positions)
order = input.ravel().argsort()
input = input.ravel()[order]
Modified: trunk/scipy/ndimage/tests/test_ndimage.py
===================================================================
--- trunk/scipy/ndimage/tests/test_ndimage.py 2010-05-08 14:16:06 UTC (rev 6385)
+++ trunk/scipy/ndimage/tests/test_ndimage.py 2010-05-08 15:05:47 UTC (rev 6386)
@@ -30,6 +30,7 @@
import math
import numpy
+import numpy as np
from numpy import fft
from numpy.testing import *
import scipy.ndimage as ndimage
@@ -2971,7 +2972,7 @@
input = numpy.array([1, 3, 8, 10, 8], type)
output = ndimage.standard_deviation(input, labels,
[2, 3, 4])
- self.failUnless(all(output == [1.0, 1.0, 0.0]))
+ self.failUnless(np.all(output == [1.0, 1.0, 0.0]))
def test_minimum_position01(self):
"minimum position 1"
Modified: trunk/scipy/signal/signaltools.py
===================================================================
--- trunk/scipy/signal/signaltools.py 2010-05-08 14:16:06 UTC (rev 6385)
+++ trunk/scipy/signal/signaltools.py 2010-05-08 15:05:47 UTC (rev 6386)
@@ -15,7 +15,7 @@
transpose, dot, any, mean, flipud, ndarray
import numpy as np
from scipy.misc import factorial
-from .windows import get_window
+from windows import get_window
_modedict = {'valid':0, 'same':1, 'full':2}
Modified: trunk/scipy/signal/tests/test_filter_design.py
===================================================================
--- trunk/scipy/signal/tests/test_filter_design.py 2010-05-08 14:16:06 UTC (rev 6385)
+++ trunk/scipy/signal/tests/test_filter_design.py 2010-05-08 15:05:47 UTC (rev 6386)
@@ -28,12 +28,13 @@
filter coefficients."""
warnings.simplefilter("error", BadCoefficients)
try:
- b, a = bessel(20, 0.1)
- z, p, k = tf2zpk(b, a)
- raise AssertionError("tf2zpk did not warn about bad "\
- "coefficients")
- except BadCoefficients:
- pass
+ try:
+ b, a = bessel(20, 0.1)
+ z, p, k = tf2zpk(b, a)
+ raise AssertionError("tf2zpk did not warn about bad "\
+ "coefficients")
+ except BadCoefficients:
+ pass
finally:
warnings.simplefilter("always", BadCoefficients)
More information about the Scipy-svn
mailing list