Fix im_class access in Python 3.

This commit is contained in:
Stefan van der Walt
2013-06-29 10:17:42 -05:00
parent 81519b7863
commit 9d1907a211
2 changed files with 11 additions and 2 deletions
+8
View File
@@ -1,5 +1,6 @@
import warnings
import functools
import sys
from . import six
@@ -54,3 +55,10 @@ class deprecated(object):
wrapped.__doc__ = doc + '\n\n ' + wrapped.__doc__
return wrapped
def get_bound_method_class(m):
"""Return the class for a bound method.
"""
return m.im_class if sys.version < '3' else m.__self__.__class__
+3 -2
View File
@@ -4,6 +4,7 @@ from scipy import ndimage, spatial
from skimage.util import img_as_float
from ._warps_cy import _warp_fast
from skimage._shared.utils import get_bound_method_class
class GeometricTransform(object):
"""Perform geometric transformations on a set of coordinates.
@@ -1009,8 +1010,8 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
if inverse_map in HOMOGRAPHY_TRANSFORMS:
matrix = inverse_map._matrix
elif hasattr(inverse_map, '__name__') \
and inverse_map.__name__ == 'inverse' \
and inverse_map.im_class in HOMOGRAPHY_TRANSFORMS:
and inverse_map.__name__ == 'inverse' \
and get_bound_method_class(inverse_map) in HOMOGRAPHY_TRANSFORMS:
matrix = np.linalg.inv(inverse_map.im_self._matrix)
if matrix is not None:
# transform all bands