From fcf2a9bc970a96d698c8ada44c98de81520dc411 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Tue, 11 Sep 2012 23:38:00 -0400 Subject: [PATCH] DOC: Fix doctests in viewer subpackage The doctests in the viewer subpackage weren't originally written as proper doctests. --- skimage/viewer/plugins/base.py | 26 +++++++++++++------------- skimage/viewer/viewers/core.py | 5 +++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/skimage/viewer/plugins/base.py b/skimage/viewer/plugins/base.py index 074e18d4..198bac6a 100644 --- a/skimage/viewer/plugins/base.py +++ b/skimage/viewer/plugins/base.py @@ -54,17 +54,17 @@ class Plugin(QDialog): Examples -------- - >>> def my_func(image, arg1, arg2, optional_arg=0): - >>> ... + >>> from skimage.viewer import ImageViewer + >>> from skimage.viewer.widgets import Slider + >>> from skimage import data >>> + >>> plugin = Plugin(image_filter=lambda img, threshold: img > threshold) + >>> plugin += Slider('threshold', 0, 255) + >>> + >>> image = data.coins() >>> viewer = ImageViewer(image) - >>> - >>> plugin = Plugin(image_filter=my_func) - >>> plugin += Widget('arg1', ..., ptype='arg') - >>> plugin += Widget('arg2', ..., ptype='arg') - >>> plugin += Widget('optional_arg', ..., ptype='kwarg') - >>> - >>> viewer.show() + >>> viewer += plugin + >>> # viewer.show() The plugin will automatically delegate parameters to `image_filter` based on its parameter type, i.e., `ptype` (widgets for required arguments must @@ -108,9 +108,9 @@ class Plugin(QDialog): """Attach the plugin to an ImageViewer. Note that the ImageViewer will automatically call this method when the - plugin is added to the ImageViewer. For example: + plugin is added to the ImageViewer. For example:: - >>> viewer += Plugin(...) + viewer += Plugin(...) Also note that `attach` automatically calls the filter function so that the image matches the filtered value specified by attached widgets. @@ -131,9 +131,9 @@ class Plugin(QDialog): def add_widget(self, widget): """Add widget to plugin. - Alternatively, Plugin's `__add__` method is overloaded to add widgets: + Alternatively, Plugin's `__add__` method is overloaded to add widgets:: - >>> plugin += Widget(...) + plugin += Widget(...) Widgets can adjust required or optional arguments of filter function or parameters for the plugin. This is specified by the Widget's `ptype'. diff --git a/skimage/viewer/viewers/core.py b/skimage/viewer/viewers/core.py index 490ff92c..7aadb571 100644 --- a/skimage/viewer/viewers/core.py +++ b/skimage/viewer/viewers/core.py @@ -49,9 +49,10 @@ class ImageViewer(QMainWindow): Examples -------- + >>> from skimage import data + >>> image = data.coins() >>> viewer = ImageViewer(image) - >>> viewer += SomePlugin() - >>> viewer.show() + >>> # viewer.show() """ def __init__(self, image):