internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: scikit-image/scikit-image

Issue:
Invalid deprecation of canny, perhaps others
```
$ python -c "from skimage import filters as F; F.canny(0)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/stefan/src/scikit-image/skimage/_shared/utils.py", line 46, in __call__
    msg = 'Call to deprecated function ``%s``.' % func.__name__
AttributeError: 'int' object has no attribute '__name__'
```



Discussion:

Resolving patch:
diff --git a/skimage/filter/__init__.py b/skimage/filter/__init__.py
--- a/skimage/filter/__init__.py
+++ b/skimage/filter/__init__.py
@@ -36,7 +36,7 @@
                         (restoration.denoise_tv_chambolle)
 
 # Backward compatibility v<0.11
-@deprecated
+@deprecated('skimage.feature.canny')
 def canny(*args, **kwargs):
     # Hack to avoid circular import
     from skimage.feature._canny import canny as canny_
diff --git a/skimage/filters/__init__.py b/skimage/filters/__init__.py
--- a/skimage/filters/__init__.py
+++ b/skimage/filters/__init__.py
@@ -23,7 +23,7 @@
                         (restoration.denoise_tv_chambolle)
 
 # Backward compatibility v<0.11
-@deprecated
+@deprecated('skimage.feature.canny')
 def canny(*args, **kwargs):
     # Hack to avoid circular import
     from ..feature._canny import canny as canny_


Test patch:
diff --git a/skimage/filters/tests/test_deprecated_imports.py b/skimage/filters/tests/test_deprecated_imports.py
new file mode 100644
--- /dev/null
+++ b/skimage/filters/tests/test_deprecated_imports.py
@@ -0,0 +1,19 @@
+from warnings import catch_warnings, simplefilter
+from ..._shared._warnings import expected_warnings
+from ...data import moon
+
+
+def test_filter_import():
+    with catch_warnings():
+        simplefilter('ignore')
+        from skimage import filter as F
+
+    assert('sobel' in dir(F))
+    assert F._import_warned
+
+
+def test_canny_import():
+    data = moon()
+    with expected_warnings(['skimage.feature.canny']):
+        from skimage.filters import canny
+        canny(data)
diff --git a/skimage/filters/tests/test_filter_import.py b/skimage/filters/tests/test_filter_import.py
deleted file mode 100644
--- a/skimage/filters/tests/test_filter_import.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from warnings import catch_warnings, simplefilter
-
-
-def test_filter_import():
-    with catch_warnings():
-        simplefilter('ignore')
-        from skimage import filter as F
-
-    assert('sobel' in dir(F))
-    assert F._import_warned
Repository: scikit-image/scikit-image

Issue:
viewer_examples/plugins/watershed_demo.py: AttributeError 'BlitManager' object has no attribute 'artist'
The demo seems to work, but upon pressing `OK`, this error is printet to console:

```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/scikit_image-0.11dev-py3.4-macosx-10.9-x86_64.egg/skimage/viewer/plugins/base.py in closeEvent(self, event)
    227         Note that artists must be appended to `self.artists`.
    228         """
--> 229         self.clean_up()
    230         self.close()
    231 

/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/scikit_image-0.11dev-py3.4-macosx-10.9-x86_64.egg/skimage/viewer/plugins/base.py in clean_up(self)
    231 
    232     def clean_up(self):
--> 233         self.remove_image_artists()
    234         if self in self.image_viewer.plugins:
    235             self.image_viewer.plugins.remove(self)

/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/scikit_image-0.11dev-py3.4-macosx-10.9-x86_64.egg/skimage/viewer/plugins/base.py in remove_image_artists(self)
    240         """Remove artists that are connected to the image viewer."""
    241         for a in self.artists:
--> 242             a.remove()
    243 
    244     def output(self):

/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/scikit_image-0.11dev-py3.4-macosx-10.9-x86_64.egg/skimage/viewer/canvastools/base.py in remove(self)
     74 
     75     def remove(self):
---> 76         self.viewer.remove_tool(self)
     77 
     78     @property

/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/scikit_image-0.11dev-py3.4-macosx-10.9-x86_64.egg/skimage/viewer/viewers/core.py in remove_tool(self, tool)
    396     def remove_tool(self, tool):
    397         if self.useblit:
--> 398             self._blit_manager.remove_artists(tool.artists)
    399         self._tools.remove(tool)
    400         self._event_manager.detach(tool)

/Users/arve/.virtualenvs/3.4/lib/python3.4/site-packages/scikit_image-0.11dev-py3.4-macosx-10.9-x86_64.egg/skimage/viewer/viewers/core.py in remove_artists(self, artists)
     61     def remove_artists(self, artists):
     62         for artist in artists:
---> 63             self.artist.remove(artist)
     64 
     65     def on_draw_event(self, event=None):

AttributeError: 'BlitManager' object has no attribute 'artist'
```

Might be related to #1143?



Discussion:

Resolving patch:
diff --git a/skimage/viewer/viewers/core.py b/skimage/viewer/viewers/core.py
--- a/skimage/viewer/viewers/core.py
+++ b/skimage/viewer/viewers/core.py
@@ -60,7 +60,7 @@ def add_artists(self, artists):
 
     def remove_artists(self, artists):
         for artist in artists:
-            self.artist.remove(artist)
+            self.artists.remove(artist)
 
     def on_draw_event(self, event=None):
         self.background = self.canvas.copy_from_bbox(self.ax.bbox)


Test patch:
Repository: scikit-image/scikit-image

Issue:
measure.label is documented under morphology.label
In the [measure API reference](http://scikit-image.org/docs/stable/api/skimage.measure.html) label is not documented, but it is [documented under morphology module](http://scikit-image.org/docs/stable/api/skimage.morphology.html#label) (which is depreciated).



Discussion:

Resolving patch:
diff --git a/skimage/measure/__init__.py b/skimage/measure/__init__.py
--- a/skimage/measure/__init__.py
+++ b/skimage/measure/__init__.py
@@ -9,7 +9,7 @@
 from .profile import profile_line
 from .fit import LineModel, CircleModel, EllipseModel, ransac
 from .block import block_reduce
-from ._ccomp import label
+from ._label import label
 
 
 __all__ = ['find_contours',


Test patch:
Repository: scikit-image/scikit-image

Issue:
skimage.io.imread returns incorrect dimensions (according to docs)
See here: http://stackoverflow.com/questions/30088841

Importing a TIFF image using skimage.io.imread returns an array with shape (3,M,N) instead of (M,N,3). This breaks the flatten and as_grey features. The results are the same calling `imread` with `plugin='tifffile'`.

```
In [1]: im = skimage.io.imread('image.tif')

In [2]: im.shape
Out[2]: (3, 768, 1024)

In [3]: im = skimage.io.imread('image.tif', as_grey = True)

In [4]: im.shape
Out[4]: (3, 768)

In [5]: im = skimage.io.imread('image.tif', flatten = True)

In [6]: im.shape
Out[6]: (3, 768)
```



Discussion:

Resolving patch:
diff --git a/skimage/io/_io.py b/skimage/io/_io.py
--- a/skimage/io/_io.py
+++ b/skimage/io/_io.py
@@ -53,8 +53,16 @@ def imread(fname, as_grey=False, plugin=None, flatten=None,
     with file_or_url_context(fname) as fname:
         img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
 
-    if as_grey and getattr(img, 'ndim', 0) >= 3:
-        img = rgb2grey(img)
+    if not hasattr(img, 'ndim'):
+        return img
+
+    if img.ndim > 2:
+        if img.shape[-1] not in (3, 4) and img.shape[-3] in (3, 4):
+            img = np.swapaxes(img, -1, -3)
+            img = np.swapaxes(img, -2, -3)
+
+        if as_grey:
+            img = rgb2grey(img)
 
     return img
 


Test patch:
diff --git a/skimage/io/tests/test_imread.py b/skimage/io/tests/test_imread.py
--- a/skimage/io/tests/test_imread.py
+++ b/skimage/io/tests/test_imread.py
@@ -1,3 +1,4 @@
+import os
 import os.path
 import numpy as np
 from numpy.testing import *
@@ -60,6 +61,20 @@ def test_bilevel():
     assert_array_equal(img.astype(bool), expected)
 
 
+@skipif(not imread_available)
+def test_imread_separate_channels():
+    # Test that imread returns RGBA values contiguously even when they are
+    # stored in separate planes.
+    x = np.random.rand(3, 16, 8)
+    f = NamedTemporaryFile(suffix='.tif')
+    fname = f.name
+    f.close()
+    imsave(fname, x, plugin='tifffile')
+    img = imread(fname, plugin='tifffile')
+    os.remove(fname)
+    assert img.shape == (16, 8, 3), img.shape
+
+
 class TestSave:
     def roundtrip(self, x, scaling=1):
         f = NamedTemporaryFile(suffix='.png')
Repository: scikit-image/scikit-image

Issue:
threshold_li Modifies Passed data
When calling `skimage.features.threshold_li(image)` the image is modified. The code most likely at fault is line 342:

``` python
image -= offset
```

An easy workaround is to simply call `skimage.features.threshold_li(image.copy())` so that only a copy of the image is passed to the function. And the original data is left unmodified.



Discussion:
@david-hoffman You're correct, thanks for the report! While your workaround is usable this is a bug and we will fix it (as well as add a test against regression).


Resolving patch:
diff --git a/skimage/filters/thresholding.py b/skimage/filters/thresholding.py
--- a/skimage/filters/thresholding.py
+++ b/skimage/filters/thresholding.py
@@ -245,7 +245,6 @@ def threshold_isodata(image, nbins=256, return_all=False):
     >>> thresh = threshold_isodata(image)
     >>> binary = image > thresh
     """
-
     hist, bin_centers = histogram(image.ravel(), nbins)
 
     # image only contains one unique value
@@ -335,15 +334,16 @@ def threshold_li(image):
     >>> thresh = threshold_li(image)
     >>> binary = image > thresh
     """
+    # Copy to ensure input image is not modified
+    image = image.copy()
     # Requires positive image (because of log(mean))
-    offset = image.min()
-    # Can not use fixed tolerance for float image
-    imrange = image.max() - offset
-    image -= offset
+    immin = np.min(image)
+    image -= immin
+    imrange = np.max(image)
+    tolerance = 0.5 * imrange / 256
 
-    tolerance = 0.5 * imrange / 256.0
     # Calculate the mean gray-level
-    mean = image.mean()
+    mean = np.mean(image)
 
     # Initial estimate
     new_thresh = mean
@@ -365,4 +365,4 @@ def threshold_li(image):
         else:
             new_thresh = temp + tolerance
 
-    return threshold + offset
+    return threshold + immin


Test patch:
Repository: scikit-image/scikit-image

Issue:
import configparser for python2
I use python2.7
File "Anaconda\lib\site-packages\skimage\io\manage_plugins.py", line 101, in _parse_config_file
    parser = ConfigParser()
this is because the wrong import of configparser,
from configparser import ConfigParser works for no exception, so the except part doesn't run
we can change 
try:
    from configparser import ConfigParser  # Python 3
except ImportError:
    from ConfigParser import ConfigParser  # Python 2
to the following code 
import sys
PY2 = sys.version[0] == '2'
PY3 = sys.version[0] == '3'
if PY2:
    from ConfigParser import ConfigParser  # Python 2
else:
    from configparser import ConfigParser  # Python 3  



Discussion:
I'm confused--how did this manage to pass all the unit tests?

I tried `from configparser import ConfigParser` on Python 2.7, it gives an `ImportError` as expected.  Something must be off on your system @CharlesMei.

But, we could certainly be more explicit here.


Resolving patch:
diff --git a/skimage/io/manage_plugins.py b/skimage/io/manage_plugins.py
--- a/skimage/io/manage_plugins.py
+++ b/skimage/io/manage_plugins.py
@@ -15,10 +15,11 @@
         loaded explicitly by the user.
 
 """
+import sys
 
-try:
+if sys.version.startswith('3'):
     from configparser import ConfigParser  # Python 3
-except ImportError:
+else:
     from ConfigParser import ConfigParser  # Python 2
 
 import os.path


Test patch:
Repository: scikit-image/scikit-image

Issue:
`denoise_bilateral` has undocumented default for parameter `sigma_range`

`denoise_bilateral` has undocumented default for parameter `sigma_range`



Discussion:
Confirmed. It's set to the standard deviation of the input image if the default `None` is left alone.

This is a nice topic for todays sprint !

Confirmed. It's set to the standard deviation of the input image if the default `None` is left alone.

This is a nice topic for todays sprint !


Resolving patch:
diff --git a/skimage/restoration/_denoise.py b/skimage/restoration/_denoise.py
--- a/skimage/restoration/_denoise.py
+++ b/skimage/restoration/_denoise.py
@@ -31,7 +31,8 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
         similarity). A larger value results in averaging of pixels with larger
         radiometric differences. Note, that the image will be converted using
         the `img_as_float` function and thus the standard deviation is in
-        respect to the range `[0, 1]`.
+        respect to the range ``[0, 1]``. If the value is ``None`` the standard 
+        deviation of the ``image`` will be used.
     sigma_spatial : float
         Standard deviation for range distance. A larger value results in
         averaging of pixels with larger spatial differences.


Test patch:
Repository: scikit-image/scikit-image

Issue:
Add Continuous Docs Release
Based on https://medium.com/@nthgergo/publishing-gh-pages-with-travis-ci-53a8270e87db.

@stefanv, what is the current process for pushing the latest dev documents?



Discussion:

Resolving patch:
diff --git a/doc/ext/notebook.py b/doc/ext/notebook_doc.py
similarity index 100%
rename from doc/ext/notebook.py
rename to doc/ext/notebook_doc.py
diff --git a/doc/ext/plot2rst.py b/doc/ext/plot2rst.py
--- a/doc/ext/plot2rst.py
+++ b/doc/ext/plot2rst.py
@@ -82,7 +82,7 @@
 from skimage import transform
 from skimage.util.dtype import dtype_range
 
-from notebook import Notebook
+from notebook_doc import Notebook
 
 from docutils.core import publish_parts
 from sphinx.domains.python import PythonDomain


Test patch:
Repository: scikit-image/scikit-image

Issue:
peak_local_max Incorrect output type 
This [function](http://scikit-image.org/docs/dev/api/skimage.feature.html#peak-local-max) is returning a `list` instead of an `ndarray` if no peaks are detected.

I traced the problem till this [line](https://github.com/scikit-image/scikit-image/blob/master/skimage/feature/peak.py#L122). However, I have to check if there is other case (beyond this line) that produces an incorrect output.

I will work on it this weekend and submit a pull-request or a code snippet here



Discussion:
Thanks, @escorciav!


Resolving patch:
diff --git a/skimage/feature/peak.py b/skimage/feature/peak.py
--- a/skimage/feature/peak.py
+++ b/skimage/feature/peak.py
@@ -119,7 +119,7 @@ def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
 
     if np.all(image == image.flat[0]):
         if indices is True:
-            return []
+            return np.empty((0, 2), np.int)
         else:
             return out
 


Test patch:
diff --git a/skimage/feature/tests/test_peak.py b/skimage/feature/tests/test_peak.py
--- a/skimage/feature/tests/test_peak.py
+++ b/skimage/feature/tests/test_peak.py
@@ -11,6 +11,7 @@
 def test_trivial_case():
     trivial = np.zeros((25, 25))
     peak_indices = peak.peak_local_max(trivial, min_distance=1, indices=True)
+    assert type(peak_indices) is np.ndarray
     assert not peak_indices     # inherent boolean-ness of empty list
     peaks = peak.peak_local_max(trivial, min_distance=1, indices=False)
     assert (peaks.astype(np.bool) == trivial).all()
@@ -89,7 +90,7 @@ def test_num_peaks3D():
     image[5,5,::5] = np.arange(20)
     peaks_limited = peak.peak_local_max(image, min_distance=1, num_peaks=2)
     assert len(peaks_limited) == 2
-    
+
 
 def test_reorder_labels():
     image = np.random.uniform(size=(40, 60))
Repository: scikit-image/scikit-image

Issue:
Infinite loop in exposure.equalize_adapthist()
The `equalize_adapthist()` function can hang, caused by the following:

When using a very small clip_limit parameter (e.g. 0.001) on a grayscale image with low contrast, the function `clip_histogram()` in `_adapthist.py` hangs in an infinite loop because the `n_excess` variable is not being lowered in the `while n_excess > 0` loop.



Discussion:

Resolving patch:
diff --git a/skimage/exposure/_adapthist.py b/skimage/exposure/_adapthist.py
--- a/skimage/exposure/_adapthist.py
+++ b/skimage/exposure/_adapthist.py
@@ -244,6 +244,8 @@ def clip_histogram(hist, clip_limit):
     n_excess -= mid.size * clip_limit - mid.sum()
     hist[mid_mask] = clip_limit
 
+    prev_n_excess = n_excess
+
     while n_excess > 0:  # Redistribute remaining excess
         index = 0
         while n_excess > 0 and index < hist.size:
@@ -256,6 +258,10 @@ def clip_histogram(hist, clip_limit):
             hist[under_mask] += 1
             n_excess -= under_mask.sum()
             index += 1
+        # bail if we have not distributed any excess
+        if prev_n_excess == n_excess:
+            break
+        prev_n_excess = n_excess
 
     return hist
 


Test patch:
diff --git a/skimage/exposure/tests/test_exposure.py b/skimage/exposure/tests/test_exposure.py
--- a/skimage/exposure/tests/test_exposure.py
+++ b/skimage/exposure/tests/test_exposure.py
@@ -213,7 +213,7 @@ def test_adapthist_grayscale():
     img = np.dstack((img, img, img))
     with expected_warnings(['precision loss|non-contiguous input', 
                             'deprecated']):
-        adapted_old = exposure.equalize_adapthist(img, 10, 9, clip_limit=0.01,
+        adapted_old = exposure.equalize_adapthist(img, 10, 9, clip_limit=0.001,
                                                   nbins=128)
         adapted = exposure.equalize_adapthist(img, kernel_size=(57, 51), clip_limit=0.01, nbins=128)
     assert img.shape == adapted.shape
Repository: scikit-image/scikit-image

Issue:
setup.py broken when numpy not installed
Try `pip install .` without numpy installed.

The solution can be found in SciPy's setup.py.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -87,14 +87,15 @@ def configuration(parent_package='', top_path=None):
     except ImportError:
         if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
                                    sys.argv[1] in ('--help-commands',
-                                                   'egg_info', '--version',
+                                                   '--version',
                                                    'clean')):
             # For these actions, NumPy is not required.
             #
             # They are required to succeed without Numpy for example when
             # pip is used to install scikit-image when Numpy is not yet
             # present in the system.
-            pass
+            from setuptools import setup
+            extra = {}
         else:
             print('To install scikit-image from source, you will need numpy.\n' +
                   'Install numpy with pip:\n' +


Test patch:
Repository: scikit-image/scikit-image

Issue:
Deprecate Python 2.6 after release of 0.12



Discussion:
:+1:

It's probably time.

So, if I understand well, 0.12 will still support Python 2.6 but 0.13 won't? Is that what you suggest? 

Where should we warn users still using Python 2.6 that the next release won't support their version of Python any more? Obvisouly in DEPENDS.txt, anywhere else? Should we issue a warning when users import skimage ?

Yes, that's right.  Since even numpy will probably move to 2.7, I think we've waited long enough.  A warning on Python 2.6 is a good idea.


Resolving patch:
diff --git a/skimage/__init__.py b/skimage/__init__.py
--- a/skimage/__init__.py
+++ b/skimage/__init__.py
@@ -156,4 +156,9 @@ def _raise_build_error(e):
         _raise_build_error(e)
     from .util.dtype import *
 
+
+if sys.version.startswith('2.6'):
+    warnings.warn("Python 2.6 is deprecated and will not be supported in scikit-image 0.13+")
+
+
 del warnings, functools, osp, imp, sys


Test patch:
Repository: scikit-image/scikit-image

Issue:
Allow radon transform to ignore values outside circle
When `circle==True`, values outside the inscribed circle should be ignored.  Currently, an error is thrown if any non-zero values are detected, forcing the user to set them to zero explicitly first.  The error should be changes to a warning and the docstring updated accordingly.



Discussion:

Resolving patch:
diff --git a/skimage/transform/radon_transform.py b/skimage/transform/radon_transform.py
--- a/skimage/transform/radon_transform.py
+++ b/skimage/transform/radon_transform.py
@@ -20,6 +20,7 @@
 from ._warps_cy import _warp_fast
 from ._radon_transform import sart_projection_update
 from .. import util
+from warnings import warn
 
 
 __all__ = ["radon", "iradon", "iradon_sart"]
@@ -49,11 +50,6 @@ def radon(image, theta=None, circle=False):
         at the pixel index ``radon_image.shape[0] // 2`` along the 0th
         dimension of ``radon_image``.
 
-    Raises
-    ------
-    ValueError
-        If called with ``circle=True`` and ``image != 0`` outside the inscribed
-        circle
     """
     if image.ndim != 2:
         raise ValueError('The input image must be 2-D')
@@ -67,8 +63,8 @@ def radon(image, theta=None, circle=False):
                                  + (c1 - image.shape[1] // 2) ** 2)
         reconstruction_circle = reconstruction_circle <= radius ** 2
         if not np.all(reconstruction_circle | (image == 0)):
-            raise ValueError('Image must be zero outside the reconstruction'
-                             ' circle')
+            warn('Radon transform: image must be zero outside the '
+                 'reconstruction circle')
         # Crop image to make it square
         slices = []
         for d in (0, 1):


Test patch:
diff --git a/skimage/transform/tests/test_radon_transform.py b/skimage/transform/tests/test_radon_transform.py
--- a/skimage/transform/tests/test_radon_transform.py
+++ b/skimage/transform/tests/test_radon_transform.py
@@ -9,7 +9,7 @@
 from skimage.io import imread
 from skimage import data_dir
 from skimage._shared.testing import test_parallel
-
+from skimage._shared._warnings import expected_warnings
 
 PHANTOM = imread(os.path.join(data_dir, "phantom.png"),
                    as_grey=True)[::2, ::2]
@@ -215,7 +215,8 @@ def _random_circle(shape):
 
 def test_radon_circle():
     a = np.ones((10, 10))
-    assert_raises(ValueError, radon, a, circle=True)
+    with expected_warnings(['reconstruction circle']):
+        radon(a, circle=True)
 
     # Synthetic data, circular symmetry
     shape = (61, 79)