Permalink
Browse files

ENH: ndimage: specify unsafe casting so the default in NumPy can be t…

…ightened
  • Loading branch information...
1 parent 04fb79d commit dffed568d8584beb68f09c72375c89db38454cc7 Mark Wiebe committed Jun 15, 2011
Showing with 7 additions and 3 deletions.
  1. +5 −1 scipy/ndimage/filters.py
  2. +2 −2 scipy/ndimage/tests/test_ndimage.py
View
@@ -447,7 +447,11 @@ def generic_gradient_magnitude(input, derivative, output = None,
*extra_arguments, **extra_keywords)
numpy.multiply(tmp, tmp, tmp)
output += tmp
- numpy.sqrt(output, output)
+ # This allows the sqrt to work with a different default casting
+ if numpy.version.short_version > '1.6.1':
+ numpy.sqrt(output, output, casting='unsafe')
+ else:
+ numpy.sqrt(output, output)
else:
output[...] = input[...]
return return_value
@@ -669,7 +669,7 @@ def test_gaussian_gradient_magnitude01(self):
output = ndimage.gaussian_gradient_magnitude(array,
1.0)
expected = tmp1 * tmp1 + tmp2 * tmp2
- numpy.sqrt(expected, expected)
+ expected = numpy.sqrt(expected).astype(type)
assert_array_almost_equal(expected, output)
def test_gaussian_gradient_magnitude02(self):
@@ -684,7 +684,7 @@ def test_gaussian_gradient_magnitude02(self):
ndimage.gaussian_gradient_magnitude(array, 1.0,
output)
expected = tmp1 * tmp1 + tmp2 * tmp2
- numpy.sqrt(expected, expected)
+ expected = numpy.sqrt(expected).astype(type)
assert_array_almost_equal(expected, output)
def test_generic_gradient_magnitude01(self):

0 comments on commit dffed56

Please sign in to comment.