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