From fe684b845d6b193d76f8ff3641bcca9407c22fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Orieux?= Date: Wed, 20 Nov 2013 14:40:35 +0100 Subject: [PATCH] Fix circshift. Rename wiener.py to deconvolution (no API change). --- skimage/restoration/__init__.py | 2 +- .../restoration/{wiener.py => deconvolution.py} | 2 +- skimage/restoration/uft.py | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) rename skimage/restoration/{wiener.py => deconvolution.py} (99%) diff --git a/skimage/restoration/__init__.py b/skimage/restoration/__init__.py index a6edb1b1..324b0932 100644 --- a/skimage/restoration/__init__.py +++ b/skimage/restoration/__init__.py @@ -18,7 +18,7 @@ References Electroacoustics, vol. au-19, no. 4, pp. 285-288, dec. 1971 """ -from .wiener import wiener, unsupervised_wiener, richardson_lucy +from .deconvolution import wiener, unsupervised_wiener, richardson_lucy __all__ = ['wiener', "unsupervised_wiener", diff --git a/skimage/restoration/wiener.py b/skimage/restoration/deconvolution.py similarity index 99% rename from skimage/restoration/wiener.py rename to skimage/restoration/deconvolution.py index 85b26afd..c684dcf3 100644 --- a/skimage/restoration/wiener.py +++ b/skimage/restoration/deconvolution.py @@ -113,7 +113,7 @@ def wiener(data, psf, reg_val, reg=None, real=True): bayesian approaches. The use of Fourier space implies a circulant property of - :math:`H`, see [2]. + :math:`H`, see [2]. References ---------- diff --git a/skimage/restoration/uft.py b/skimage/restoration/uft.py index cc57ae34..a4117d15 100644 --- a/skimage/restoration/uft.py +++ b/skimage/restoration/uft.py @@ -85,26 +85,26 @@ def _circshift(inarray, shifts): Examples -------- - >>> _circshift(np.arange(10), 2) + >>> _circshift(np.arange(10), (2, )) array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7]) """ # Initialize array of indices idx = [] - # Loop through each dimension of the input matrix to calculate + # Loop through each dimension of the input matrix to compute # shifted indices for dim in range(inarray.ndim): length = inarray.shape[dim] try: shift = shifts[dim] except IndexError: - shift = 0 # no shift if not specify + shift = 0 # no shift if not specified # Lets start for fancy indexing. First we build the shifted # index for dim k. It will be broadcasted to other dim so # ndmin is specified - index = np.mod(np.array(range(length), + index = np.mod(np.array(np.arange(length), ndmin=inarray.ndim) - shift, length) # Shape adaptation @@ -114,7 +114,7 @@ def _circshift(inarray, shifts): idx.append(index.astype(int)) - # Perform the actual conversion by indexing into the input matrix + # Conversion by indexing the input matrix return inarray[idx] @@ -427,3 +427,8 @@ def laplacian(ndim, shape): impr[([slice(1, 2)] * ndim)] = 2.0 * ndim return ir2tf(impr, shape), impr + + +if __name__ == "__main__": + import doctest + doctest.testmod(optionflags=doctest.ELLIPSIS)