mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 02:45:22 +08:00
Fix python 2.6 restoration/unwrap error
This commit is contained in:
+1
-6
@@ -90,18 +90,13 @@ script:
|
||||
|
||||
# Run all doc examples
|
||||
- export PYTHONPATH=$(pwd):$PYTHONPATH
|
||||
- if [[ $ENV != python=2.6* ]]; then
|
||||
for f in doc/examples/*.py; do python "$f"; if [ $? -ne 0 ]; then exit 1; fi done
|
||||
fi
|
||||
- for f in doc/examples/*.py; do python "$f"; if [ $? -ne 0 ]; then exit 1; fi done
|
||||
- for f in doc/examples/applications/*.py; do python "$f"; if [ $? -ne 0 ]; then exit 1; fi done
|
||||
|
||||
# run tests again with optional dependencies to get more coverage
|
||||
# measure coverage on py3.3
|
||||
# doctests fail on python 2.6 for restoration/unwrap
|
||||
- if [[ $ENV == python=3.3* ]]; then
|
||||
nosetests --exe -v --with-doctest --with-cov --cover-package skimage;
|
||||
elif [[ $ENV == python=2.6* ]]; then
|
||||
nosetests --exe -v skimage;
|
||||
else
|
||||
nosetests --exe -v --with-doctest skimage;
|
||||
fi
|
||||
|
||||
@@ -7,7 +7,6 @@ from numpy.testing import (run_module_suite, assert_array_almost_equal,
|
||||
import warnings
|
||||
|
||||
from skimage.restoration import unwrap_phase
|
||||
from skimage.util.version_requirements import require
|
||||
|
||||
|
||||
def assert_phase_almost_equal(a, b, *args, **kwargs):
|
||||
@@ -42,7 +41,6 @@ def check_unwrap(image, mask=None):
|
||||
assert_phase_almost_equal(image_unwrapped, image)
|
||||
|
||||
|
||||
@require('python', '>=2.7')
|
||||
def test_unwrap_1d():
|
||||
image = np.linspace(0, 10 * np.pi, 100)
|
||||
check_unwrap(image)
|
||||
@@ -52,7 +50,6 @@ def test_unwrap_1d():
|
||||
assert_raises(ValueError, unwrap_phase, image, True)
|
||||
|
||||
|
||||
@require('python', '>=2.7')
|
||||
def test_unwrap_2d():
|
||||
x, y = np.ogrid[:8, :16]
|
||||
image = 2 * np.pi * (x * 0.2 + y * 0.1)
|
||||
@@ -62,7 +59,6 @@ def test_unwrap_2d():
|
||||
yield check_unwrap, image, mask
|
||||
|
||||
|
||||
@require('python', '>=2.7')
|
||||
def test_unwrap_3d():
|
||||
x, y, z = np.ogrid[:8, :12, :16]
|
||||
image = 2 * np.pi * (x * 0.2 + y * 0.1 + z * 0.05)
|
||||
@@ -108,14 +104,12 @@ def check_wrap_around(ndim, axis):
|
||||
image_unwrap_wrap_around[index_last])
|
||||
|
||||
|
||||
@require('python', '>=2.7')
|
||||
def test_wrap_around():
|
||||
for ndim in (2, 3):
|
||||
for axis in range(ndim):
|
||||
yield check_wrap_around, ndim, axis
|
||||
|
||||
|
||||
@require('python', '>=2.7')
|
||||
def test_mask():
|
||||
length = 100
|
||||
ramps = [np.linspace(0, 4 * np.pi, length),
|
||||
@@ -143,7 +137,6 @@ def test_mask():
|
||||
assert_array_almost_equal(image_unwrapped_3d[:, :, -1], image[i, -1])
|
||||
|
||||
|
||||
@require('python', '>=2.7')
|
||||
def test_invalid_input():
|
||||
assert_raises(ValueError, unwrap_phase, np.zeros([]))
|
||||
assert_raises(ValueError, unwrap_phase, np.zeros((1, 1, 1, 1)))
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import numpy as np
|
||||
import warnings
|
||||
from six import string_types
|
||||
from skimage.util.version_requirements import require
|
||||
|
||||
from ._unwrap_1d import unwrap_1d
|
||||
from ._unwrap_2d import unwrap_2d
|
||||
from ._unwrap_3d import unwrap_3d
|
||||
|
||||
|
||||
@require('python', '>=2.7')
|
||||
def unwrap_phase(image, wrap_around=False):
|
||||
'''From ``image``, wrapped to lie in the interval [-pi, pi), recover the
|
||||
original, unwrapped image.
|
||||
@@ -86,6 +84,7 @@ def unwrap_phase(image, wrap_around=False):
|
||||
|
||||
if np.ma.isMaskedArray(image):
|
||||
mask = np.require(image.mask, np.uint8, ['C'])
|
||||
image = image.data
|
||||
else:
|
||||
mask = np.zeros_like(image, dtype=np.uint8, order='C')
|
||||
image_not_masked = np.asarray(image, dtype=np.float64, order='C')
|
||||
|
||||
Reference in New Issue
Block a user