Add a function to set up a skimage test
Switch to new test helper function
Import local packages that raise warnings in test setup function
More fixes to doctests
Fix regionprops doc test
Try and fix the test_rank failure.
Remove no longer needed RectangleSelector shim
Skip more doctests in _regionprops
Try importing another scipy subpackage
Reset plugins prior to running collections test
Handle warnings in morphology pkg
Add __init__ for morpohology tests
Handle warnings for novice pkg
Handle warnings for restoration pkg
Handle warnings for segmentation pkg
Handle warnings for _shared pkg
Handle warnings for transform pkg
Handle warnings for util pkg
Handle warnings in viewer module
Also:
* New tests to cover these new checks
* Improvements to docstrings and user warnings
* Generalize handling of `sampling` in accordance with docstring
* Some extra whitespace to improve readability
Previously, having a different `sigma` for different dimensions
required an array input. This allows the user to use a simple list,
which gets converted to an array internally.
Importantly, it removes a very unhelpful error:
```python
>>> im = np.random.rand(10, 20)
>>> from skimage import segmentation as seg
Exception AttributeError: "'UmfpackContext' object has no attribute '_symbolic'" in <bound method UmfpackContext.__del__ of <scipy.sparse.linalg.dsolve.umfpack.umfpack.UmfpackContext object at 0x1045ff5d0>> ignored
>>> s = seg.slic(im, 2, sigma=[2, 1])
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-689b36a2f0ef> in <module>()
----> 1 s = seg.slic(im, 2, sigma=[2, 1])
/Users/nuneziglesiasj/venv/skimdev2/lib/python2.7/site-packages/scikit_image-0.9dev-py2.7-macosx-10.5-x86_64.egg/skimage/segmentation/slic_superpixels.pyc in slic(image, n_segments, compactness, max_iter, sigma, multichannel, convert2lab, ratio)
106 if not isinstance(sigma, coll.Iterable):
107 sigma = np.array([sigma, sigma, sigma])
--> 108 if (sigma > 0).any():
109 sigma = list(sigma) + [0]
110 image = ndimage.gaussian_filter(image, sigma)
AttributeError: 'bool' object has no attribute 'any'
```
`np.atleast_3d` will add a singleton dimension at the end of an array
if needed. This is not the correct thing to do if `multichannel=False`
based on the subsequent lines. If the input image was 2D with shape
`(40, 50)` and `multichannel=False`, then `np.atleast_3d` gives it
shape `(40, 50, 1)`, and then, because `multichannel=False`, the rest
of the code gives it shape `(40, 50, 1, 1)`. This results in the final
returned array having shape `(40, 50, 1)` instead of the desired
`(40, 50)`.
This commit fixes that and updates the test to detect this failure.
This commit represents all recommended changes since the last
commit, notably:
* PEP8 compliance (in new sections; a few old ones still
noncompliant w/indentations)
* Moved `depth` kwarg to end of list and in docstring.
Clarified `depth` docstring, and added section in Notes
further explaining this parameter.
* Added section in Notes warning that for multichannel inputs,
all channels are combined during scaling. The user must
separately normalize each channel prior to calling
random_walker()
* New method for parsing data, allowing more elegant gradient
calculation code. Probably also more extensible. The 2D
multispectral case forced this change.
* New test: `test_multispectral_2d()`
In this new version, all instances of 'spectrum' have been replaced with 'channel'. The documentation also reflects this change, and the new multichannel kwarg used to indicate multichannel input is named appropriately.
New boolean multichannel kwarg added, which controls if the input has multiple channels or not. Input 'data' is now array_like for both gray-level and multichannel. This kwarg is needed mainly because a 3-D array could be either 3 spatial dimensions or a set of different 2-D channels.
New scaling kwarg added (may be removed in future), controlling if data scaling is applied to ALL channels or each channel individually, if multichannel=True. No effect for gray-level data.
Removed np.sqrt(gradients) in _compute_weights_3d(), which was a bug. Tests now pass consistently.
New method for maintaining shape from input to output, where dims = data.shape prior to np.atleast_3d(). A theoretical (70,100,1) array passed should now result in a (70,100,1) shaped output, for example.
Updated and fixed multispectral test script to work with new version. TODO: Additional test(s) likely needed to cover code branches from new kwargs.
Since the multispectral path is equivalent except for gradient calcs,
only one test case is needed. This test is modeled on the 3-D
non-multispectral version. If deemed necessary, adding a 2-D case
would be simple.