diff --git a/.gitignore b/.gitignore index 307523aa..e0463700 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pyc *~ *# +.#* *egg-info *.so *.pyd diff --git a/CONTRIBUTING.txt b/CONTRIBUTING.txt index 79b691e4..93f307d4 100644 --- a/CONTRIBUTING.txt +++ b/CONTRIBUTING.txt @@ -79,15 +79,17 @@ For a more detailed discussion, read these :doc:`detailed documents 5. Document changes - Before merging your commits, you must add a description of your changes - to the release notes of the upcoming version in - ``doc/release/release_dev.txt``. + If your change introduces any API modifications, please update + ``doc/source/api_changes.txt``. + + If your change introduces a deprecation, add a reminder to ``TODO.txt`` + for the team to remove the deprecated functionality in the future. .. note:: - To reviewers: if it is not obvious, add a short explanation of what a branch - did to the merge message and, if closing a bug, also add "Closes #123" - where 123 is the issue number. + To reviewers: if it is not obvious from the PR description, add a short + explanation of what a branch did to the merge message and, if closing a + bug, also add "Closes #123" where 123 is the issue number. Divergence between ``upstream master`` and your feature branch @@ -124,8 +126,7 @@ Guidelines * All code should have tests (see `test coverage`_ below for more details). * All code should be documented, to the same `standard <://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt#docstring-standard>`_ as NumPy and SciPy. -* For new functionality, always add an example to the - gallery. +* For new functionality, always add an example to the gallery. * No changes are ever committed without review. Ask on the `mailing list `_ if you get no response to your pull request. @@ -147,7 +148,7 @@ Stylistic Guidelines import matplotlib.pyplot as plt from scipy import ndimage as ndi - cimport numpy as cnp # in Cython code + cimport numpy as cnp # in Cython code * When documenting array parameters, use ``image : (M, N) ndarray`` and then refer to ``M`` and ``N`` in the docstring, if necessary. @@ -166,10 +167,17 @@ Stylistic Guidelines * Use ``Py_ssize_t`` as data type for all indexing, shape and size variables in C/C++ and Cython code. +* Use relative module imports, i.e. ``from .._shared import xyz`` rather than + ``from skimage._shared import xyz``. + * Wrap Cython code in a pure Python function, which defines the API. This improves compatibility with code introspection tools, which are often not aware of Cython code. +* For Cython functions, release the GIL whenever possible, using + ``with nogil:``. + + Test coverage ------------- diff --git a/skimage/_shared/testing.py b/skimage/_shared/testing.py index 5069e19e..301d25ec 100644 --- a/skimage/_shared/testing.py +++ b/skimage/_shared/testing.py @@ -9,7 +9,7 @@ from tempfile import NamedTemporaryFile from numpy import testing import numpy as np -from skimage._shared._warnings import expected_warnings +from ._warnings import expected_warnings import warnings from .. import data, io, img_as_uint, img_as_float, img_as_int, img_as_ubyte @@ -183,15 +183,19 @@ def mono_check(plugin, fmt='png'): def setup_test(): """Default package level setup routine for skimage tests. - Import packages known to raise errors, and then + Import packages known to raise warnings, and then force warnings to raise errors. - Set a random seed + + Also set the random seed to zero. """ warnings.simplefilter('default') + from scipy import signal, ndimage, special, optimize, linalg from scipy.io import loadmat from skimage import viewer, filter + np.random.seed(0) + warnings.simplefilter('error') diff --git a/skimage/_shared/tests/__init__.py b/skimage/_shared/tests/__init__.py index 3df53221..f326b5ee 100644 --- a/skimage/_shared/tests/__init__.py +++ b/skimage/_shared/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..testing import setup_test, teardown_test def setup(): diff --git a/skimage/color/tests/__init__.py b/skimage/color/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/color/tests/__init__.py +++ b/skimage/color/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/data/__init__.py b/skimage/data/__init__.py index a5f5068d..0bf2ff91 100644 --- a/skimage/data/__init__.py +++ b/skimage/data/__init__.py @@ -41,7 +41,7 @@ def load(f): Returns ------- img : ndarray - Image loaded from skimage.data_dir. + Image loaded from ``skimage.data_dir``. """ use_plugin('pil') return imread(_os.path.join(data_dir, f)) diff --git a/skimage/data/tests/__init__.py b/skimage/data/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/data/tests/__init__.py +++ b/skimage/data/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/draw/tests/__init__.py b/skimage/draw/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/draw/tests/__init__.py +++ b/skimage/draw/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/exposure/tests/__init__.py b/skimage/exposure/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/exposure/tests/__init__.py +++ b/skimage/exposure/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/feature/tests/__init__.py b/skimage/feature/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/feature/tests/__init__.py +++ b/skimage/feature/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/filter/__init__.py b/skimage/filter/__init__.py index 8b81c254..b5981329 100644 --- a/skimage/filter/__init__.py +++ b/skimage/filter/__init__.py @@ -26,8 +26,8 @@ from ..filters.thresholding import (threshold_adaptive, threshold_otsu, threshol from ..filters import rank from ..filters.rank import median -from skimage._shared.utils import deprecated -from skimage import restoration +from .._shared.utils import deprecated +from .. import restoration denoise_bilateral = deprecated('skimage.restoration.denoise_bilateral')\ (restoration.denoise_bilateral) denoise_tv_bregman = deprecated('skimage.restoration.denoise_tv_bregman')\ diff --git a/skimage/filters/rank/tests/__init__.py b/skimage/filters/rank/tests/__init__.py index 3df53221..86f6e059 100644 --- a/skimage/filters/rank/tests/__init__.py +++ b/skimage/filters/rank/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ...._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/filters/tests/__init__.py b/skimage/filters/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/filters/tests/__init__.py +++ b/skimage/filters/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/graph/tests/__init__.py b/skimage/graph/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/graph/tests/__init__.py +++ b/skimage/graph/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/io/tests/__init__.py b/skimage/io/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/io/tests/__init__.py +++ b/skimage/io/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/measure/tests/__init__.py b/skimage/measure/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/measure/tests/__init__.py +++ b/skimage/measure/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/morphology/tests/__init__.py b/skimage/morphology/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/morphology/tests/__init__.py +++ b/skimage/morphology/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/novice/tests/__init__.py b/skimage/novice/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/novice/tests/__init__.py +++ b/skimage/novice/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/restoration/non_local_means.py b/skimage/restoration/non_local_means.py index 2ba98a11..0f36c83c 100644 --- a/skimage/restoration/non_local_means.py +++ b/skimage/restoration/non_local_means.py @@ -1,7 +1,10 @@ import numpy as np -from skimage.restoration._nl_means_denoising import _nl_means_denoising_2d, \ - _nl_means_denoising_3d, \ - _fast_nl_means_denoising_2d, _fast_nl_means_denoising_3d +from ._nl_means_denoising import ( + _nl_means_denoising_2d, + _nl_means_denoising_3d, + _fast_nl_means_denoising_2d, + _fast_nl_means_denoising_3d) + def nl_means_denoising(image, patch_size=7, patch_distance=11, h=0.1, multichannel=True, fast_mode=True): @@ -113,8 +116,7 @@ def nl_means_denoising(image, patch_size=7, patch_distance=11, h=0.1, else: # 3-D grayscale if fast_mode: return np.array(_fast_nl_means_denoising_3d(image, s=patch_size, - d=patch_distance, h=h)) + d=patch_distance, h=h)) else: return np.array(_nl_means_denoising_3d(image, patch_size, - patch_distance, h)) - + patch_distance, h)) diff --git a/skimage/restoration/tests/__init__.py b/skimage/restoration/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/restoration/tests/__init__.py +++ b/skimage/restoration/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/segmentation/tests/__init__.py b/skimage/segmentation/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/segmentation/tests/__init__.py +++ b/skimage/segmentation/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/transform/tests/__init__.py b/skimage/transform/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/transform/tests/__init__.py +++ b/skimage/transform/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/util/tests/__init__.py b/skimage/util/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/util/tests/__init__.py +++ b/skimage/util/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/viewer/tests/__init__.py b/skimage/viewer/tests/__init__.py index 3df53221..7f53749e 100644 --- a/skimage/viewer/tests/__init__.py +++ b/skimage/viewer/tests/__init__.py @@ -1,4 +1,4 @@ -from skimage._shared.testing import setup_test, teardown_test +from ..._shared.testing import setup_test, teardown_test def setup(): diff --git a/skimage/viewer/utils/core.py b/skimage/viewer/utils/core.py index 524e9b61..7f632d43 100644 --- a/skimage/viewer/utils/core.py +++ b/skimage/viewer/utils/core.py @@ -1,7 +1,7 @@ import warnings import numpy as np -from skimage.viewer.qt import QtWidgets, has_qt, FigureManagerQT, FigureCanvasQTAgg +from ..qt import QtWidgets, has_qt, FigureManagerQT, FigureCanvasQTAgg import matplotlib as mpl from matplotlib.figure import Figure from matplotlib import _pylab_helpers diff --git a/skimage/viewer/utils/dialogs.py b/skimage/viewer/utils/dialogs.py index 20dd0e16..f160531d 100644 --- a/skimage/viewer/utils/dialogs.py +++ b/skimage/viewer/utils/dialogs.py @@ -1,6 +1,6 @@ import os -from skimage.viewer.qt import QtGui +from ..qt import QtGui __all__ = ['open_file_dialog', 'save_file_dialog']