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

Issue:
Add examples to docstring for structuring elements to visualize the shape
## Description

Add examples to show for each of these functions:

* [ ] skimage.morphology.square(width[, dtype])
* [ ] skimage.morphology.rectangle(width, height)
* [ ] skimage.morphology.diamond(radius[, dtype])
* [ ] skimage.morphology.disk(radius[, dtype])
* [ ] skimage.morphology.cube(width[, dtype])
* [ ] skimage.morphology.octahedron(radius[, dtype])
* [ ] skimage.morphology.ball(radius[, dtype])
* [ ] skimage.morphology.octagon(m, n[, dtype])
* [ ] skimage.morphology.star(a[, dtype])

the typical shape of the structuring element.


Cc ( @emmanuelle : another first issue idea).



Discussion:
Hi!
I would love to work on this issue.
Hi @07harshita that's great to hear! Don't hesitate to submit a work in progress pull request with for example just one example in one function, if you want some early feedback to be sure that you're on the right track.

Resolving patch:
diff --git a/doc/examples/numpy_operations/plot_structuring_elements.py b/doc/examples/numpy_operations/plot_structuring_elements.py
new file mode 100644
--- /dev/null
+++ b/doc/examples/numpy_operations/plot_structuring_elements.py
@@ -0,0 +1,56 @@
+"""
+=============================
+Generate structuring elements
+=============================
+
+This example shows how to use functions in :py:mod:`skimage.morphology`
+to generate structuring elements.
+The title of each plot indicates the call of the function.
+
+"""
+
+import numpy as np
+import matplotlib.pyplot as plt
+from mpl_toolkits.mplot3d import Axes3D
+
+from skimage.morphology import (square, rectangle, diamond, disk, cube,
+                                octahedron, ball, octagon, star)
+
+# Generate 2D and 3D structuring elements.
+struc_2d = {
+    "square(15)": square(15),
+    "rectangle(15, 10)": rectangle(15, 10),
+    "diamond(7)": diamond(7),
+    "disk(7)": disk(7),
+    "octagon(7, 4)": octagon(7, 4),
+    "star(5)": star(5)
+}
+
+struc_3d = {
+    "cube(11)": cube(11),
+    "octahedron(5)": octahedron(5),
+    "ball(5)": ball(5)
+}
+
+# Visualize the elements.
+fig = plt.figure(figsize=(8, 8))
+
+idx = 1
+for title, struc in struc_2d.items():
+    ax = fig.add_subplot(3, 3, idx)
+    ax.imshow(struc, cmap="Paired", vmin=0, vmax=12)
+    for i in range(struc.shape[0]):
+        for j in range(struc.shape[1]):
+            ax.text(j, i, struc[i, j], ha="center", va="center", color="w")
+    ax.set_axis_off()
+    ax.set_title(title)
+    idx += 1
+
+for title, struc in struc_3d.items():
+    ax = fig.add_subplot(3, 3, idx, projection=Axes3D.name)
+    ax.voxels(struc)
+    ax.set_title(title)
+    idx += 1
+
+fig.tight_layout()
+plt.show()


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

Issue:
Signatures in dev API have backslashes before *
## Description

Compare 

https://scikit-image.org/docs/dev/api/skimage.metrics.html#adapted-rand-error
https://scikit-image.org/docs/stable/api/skimage.metrics.html#adapted-rand-error



Discussion:
Thanks for the report @sciunto. This is weird because it's not in the source code...

I found it in a couple of other places like 
https://scikit-image.org/docs/dev/api/skimage.metrics.html#skimage.metrics.contingency_table
https://scikit-image.org/docs/dev/api/skimage.metrics.html#normalized-root-mse
https://scikit-image.org/docs/dev/api/skimage.metrics.html#peak-signal-noise-ratio

In https://scikit-image.org/docs/dev/api/skimage.measure.html#compare-ssim there is the "\*\*" for kwargs which is very ugly.

Maybe something changed in sphinx?

New major version of sphinx released a few days ago, this might explain... https://pypi.org/project/Sphinx/3.0.0/#history
I'm building the doc with two different sphinx versions to check.


I can reproduce by updating sphinx from 2.4.4 to 3.0.0 (reported upstream)

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -29,6 +29,9 @@
 
 # -- General configuration -----------------------------------------------------
 
+# Strip backslahes in function's signature
+strip_signature_backslash = True
+
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx_copybutton',


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

Issue:
match_descriptors docstring describes descriptors too narrowly
The docstring for `match_descriptors` currently reads:

```
Parameters
----------
descriptors1 : (M, P) array
    Binary descriptors of size P about M keypoints in the first image.
descriptors2 : (N, P) array
    Binary descriptors of size P about N keypoints in the second image.
metric : {'euclidean', 'cityblock', 'minkowski', 'hamming', ...} , optional
    The metric to compute the distance between two descriptors. See
    `scipy.spatial.distance.cdist` for all possible types. The hamming
    distance should be used for binary descriptors. By default the L2-norm
    is used for all descriptors of dtype float or double and the Hamming
    distance is used for binary descriptors automatically.
...
```
however, the method supports float descriptors as well. The docstring description for `descriptors1` and `descriptors2` should drop the `Binary` adjective. 


Discussion:

Resolving patch:
diff --git a/skimage/feature/match.py b/skimage/feature/match.py
--- a/skimage/feature/match.py
+++ b/skimage/feature/match.py
@@ -13,9 +13,9 @@ def match_descriptors(descriptors1, descriptors2, metric=None, p=2,
     Parameters
     ----------
     descriptors1 : (M, P) array
-        Binary descriptors of size P about M keypoints in the first image.
+        Descriptors of size P about M keypoints in the first image.
     descriptors2 : (N, P) array
-        Binary descriptors of size P about N keypoints in the second image.
+        Descriptors of size P about N keypoints in the second image.
     metric : {'euclidean', 'cityblock', 'minkowski', 'hamming', ...} , optional
         The metric to compute the distance between two descriptors. See
         `scipy.spatial.distance.cdist` for all possible types. The hamming


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

Issue:
Examples in `doc/examples/registration` are not displayed in the gallery
This is because  `sphinx_gallery_conf['subsection_order']` does not include this subdirectory (see https://github.com/scikit-image/scikit-image/blob/master/doc/source/conf.py#L59). Also, some examples of `doc/examples/transform` should be moved to `doc/examples/registration`.


Discussion:
Please see #4503 and #4502. The register functions are moved to the `skimage.register` module and the corresponding examples are moved to `doc/example/registration`

Resolving patch:
diff --git a/doc/examples/registration/plot_opticalflow.py b/doc/examples/registration/plot_opticalflow.py
--- a/doc/examples/registration/plot_opticalflow.py
+++ b/doc/examples/registration/plot_opticalflow.py
@@ -1,6 +1,6 @@
 # coding: utf-8
-"""Image registration
-==================
+"""Registration using optical flow
+==================================
 
 Demonstration of image registration using optical flow.
 
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -166,6 +166,7 @@
         '../examples/color_exposure',
         '../examples/edges',
         '../examples/transform',
+        '../examples/registration',
         '../examples/filters',
         '../examples/features_detection',
         '../examples/segmentation',


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

Issue:
corner_harris returns peaks in a non "natural" order when the peaks have the same amplitude
## Description

@emmanuelle [caught](https://github.com/scikit-image/scikit-image/pull/4218#issuecomment-612629627) a bug in `corner_peaks`: it returns the peaks coordinates in the wrong order when the peaks have the same amplitude.


Discussion:
Well, is "wrong" the correct word here? =) But, granted, it would be unintuitive to get this result. =)

Resolving patch:
diff --git a/skimage/feature/corner.py b/skimage/feature/corner.py
--- a/skimage/feature/corner.py
+++ b/skimage/feature/corner.py
@@ -951,10 +951,10 @@ def corner_peaks(image, min_distance=1, threshold_abs=None, threshold_rel=None,
            [0., 0., 1., 1., 0.],
            [0., 0., 0., 0., 0.]])
     >>> peak_local_max(response)
-    array([[3, 3],
-           [3, 2],
+    array([[2, 2],
            [2, 3],
-           [2, 2]])
+           [3, 2],
+           [3, 3]])
     >>> corner_peaks(response, threshold_rel=0)
     array([[2, 2]])
 
diff --git a/skimage/feature/peak.py b/skimage/feature/peak.py
--- a/skimage/feature/peak.py
+++ b/skimage/feature/peak.py
@@ -12,7 +12,7 @@ def _get_high_intensity_peaks(image, mask, num_peaks):
     coord = np.nonzero(mask)
     intensities = image[coord]
     # Highest peak first
-    idx_maxsort = np.argsort(intensities)[::-1]
+    idx_maxsort = np.argsort(-intensities)
     coord = np.transpose(coord)[idx_maxsort]
     # select num_peaks peaks
     if len(coord) > num_peaks:


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

Issue:
Negative eigenvalue in inertia_tensor_eigvals due to floating point precision
## Description
skimage.measure.inertia_tensor_eigvals can return a very slightly negative eigenvalue even though it is given a value of mu that should yield a positive semidefinite matrix with only non-negative eigenvalues. Subsequently taking the square root of a negative eigenvalue, which would occur when computing the length of an ellipse axis, produces an error.

## Way to reproduce
```python
import numpy as np
from skimage.measure import inertia_tensor_eigvals
image = np.array([[0,0],[0,0]])
mu = np.array([[3, 0, 98], [0, 14, 0], [2, 0, 98]])
eigvals = inertia_tensor_eigvals(image=image, mu=mu, T=None)
print(eigvals)
```

## Version information
```python
3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0]
Linux-5.3.0-46-generic-x86_64-with-Ubuntu-18.04-bionic
scikit-image version: 0.16.2
numpy version: 1.18.2
```

## Expected Results
```python
[33.33333333333333, 0.]
```

## Actual Results
```python
[33.33333333333333, -2.220446049250313e-16]
```



Discussion:

Resolving patch:
diff --git a/skimage/measure/_moments.py b/skimage/measure/_moments.py
--- a/skimage/measure/_moments.py
+++ b/skimage/measure/_moments.py
@@ -445,4 +445,9 @@ def inertia_tensor_eigvals(image, mu=None, T=None):
     if T is None:
         T = inertia_tensor(image, mu)
     eigvals = np.linalg.eigvalsh(T)
+    # Floating point precision problems could make a positive
+    # semidefinite matrix have an eigenvalue that is very slightly
+    # negative. This can cause problems down the line, so set values
+    # very near zero to zero.
+    eigvals = np.clip(eigvals, 0, None, out=eigvals)
     return sorted(eigvals, reverse=True)


Test patch:
diff --git a/skimage/measure/tests/test_moments.py b/skimage/measure/tests/test_moments.py
--- a/skimage/measure/tests/test_moments.py
+++ b/skimage/measure/tests/test_moments.py
@@ -173,3 +173,15 @@ def test_inertia_tensor_3d():
     expected_vr = R @ v0
     assert (np.allclose(vr, expected_vr, atol=1e-3, rtol=0.01) or
             np.allclose(-vr, expected_vr, atol=1e-3, rtol=0.01))
+
+
+def test_inertia_tensor_eigvals():
+    # Floating point precision problems could make a positive
+    # semidefinite matrix have an eigenvalue that is very slightly
+    # negative.  Check that we have caught and fixed this problem.
+    image = np.array([[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+                      [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
+                      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]])
+    # mu = np.array([[3, 0, 98], [0, 14, 0], [2, 0, 98]])
+    eigvals = inertia_tensor_eigvals(image=image)
+    assert (min(eigvals) >= 0)
Repository: scikit-image/scikit-image

Issue:
Misleading "ValueError: Input array has to be either 3- or 4-dimensional" in montage
## Description
When inputting a 4-dimensional array into `skimage.util.montage`, I get a misleading error message:
> ValueError: Input array has to be either 3- or 4-dimensional

But the input array *is* 4-dimensional already, what is missing is `multichannel=True`.

## Way to reproduce
```python
import numpy as np
from skimage.util import montage

data = np.zeros((10, 128, 128, 3))
print(f"'data' is {data.ndim}-dimensional.")

montage(data)
```

> 'data' is 4-dimensional.
> ValueError: Input array has to be either 3- or 4-dimensional


## Version information
```
3.8.2 (default, Feb 26 2020, 09:52:54) 
[GCC 7.5.0]
Linux-4.12.14-lp151.28.32-default-x86_64-with-glibc2.26
scikit-image version: 0.16.2
numpy version: 1.18.3
```


Discussion:
@bersbersbers good point! Would you like to submit a PR for fixing the message?
@soupault not really, I'm not a bit git user (yet). Also, there's a number of options.

One could simply modify 
https://github.com/scikit-image/scikit-image/blob/11bb9be96b126960bc3b1a68bf27b7d9a13d3aea/skimage/util/_montage.py#L97

to say
```
raise ValueError('Input array has to be 3-dimensional, or 4-dimensional with `multichannel=True`')
```

Alternatively, one could set `multichannel=None` by default and auto-detect it based on `np.asarray(arr_in).ndim`. 
Thank you. I agree with the edit on the error message. We do not want to perform guessing based on input values to avoid magic behaviors in the library. I'll open a PR.

Resolving patch:
diff --git a/skimage/util/_montage.py b/skimage/util/_montage.py
--- a/skimage/util/_montage.py
+++ b/skimage/util/_montage.py
@@ -94,7 +94,8 @@ def montage(arr_in, fill='mean', rescale_intensity=False, grid_shape=None,
         arr_in = np.asarray(arr_in)[..., np.newaxis]
 
     if arr_in.ndim != 4:
-        raise ValueError('Input array has to be either 3- or 4-dimensional')
+        raise ValueError('Input array has to be 3-dimensional '
+                         'or 4-dimensional, with `multichannel=True`')
 
     n_images, n_rows, n_cols, n_chan = arr_in.shape
 


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

Issue:
Misleading "ValueError: Input array has to be either 3- or 4-dimensional" in montage
## Description
When inputting a 4-dimensional array into `skimage.util.montage`, I get a misleading error message:
> ValueError: Input array has to be either 3- or 4-dimensional

But the input array *is* 4-dimensional already, what is missing is `multichannel=True`.

## Way to reproduce
```python
import numpy as np
from skimage.util import montage

data = np.zeros((10, 128, 128, 3))
print(f"'data' is {data.ndim}-dimensional.")

montage(data)
```

> 'data' is 4-dimensional.
> ValueError: Input array has to be either 3- or 4-dimensional


## Version information
```
3.8.2 (default, Feb 26 2020, 09:52:54) 
[GCC 7.5.0]
Linux-4.12.14-lp151.28.32-default-x86_64-with-glibc2.26
scikit-image version: 0.16.2
numpy version: 1.18.3
```


Discussion:
@bersbersbers good point! Would you like to submit a PR for fixing the message?
@soupault not really, I'm not a bit git user (yet). Also, there's a number of options.

One could simply modify 
https://github.com/scikit-image/scikit-image/blob/11bb9be96b126960bc3b1a68bf27b7d9a13d3aea/skimage/util/_montage.py#L97

to say
```
raise ValueError('Input array has to be 3-dimensional, or 4-dimensional with `multichannel=True`')
```

Alternatively, one could set `multichannel=None` by default and auto-detect it based on `np.asarray(arr_in).ndim`. 
Thank you. I agree with the edit on the error message. We do not want to perform guessing based on input values to avoid magic behaviors in the library. I'll open a PR.
I would like this re-opened, I do not agree that #4607 fixes this (yet).
I shouldn't have pushed the commit. I implemented @jni's suggestion, wanted to read again the function, and after switching to something else I pushed I forgot to come back to it. :/ I wanted to check the unittests as well.
I'll have a look again later on, except if someone else want to do it sooner.

Resolving patch:
diff --git a/skimage/util/_montage.py b/skimage/util/_montage.py
--- a/skimage/util/_montage.py
+++ b/skimage/util/_montage.py
@@ -94,8 +94,9 @@ def montage(arr_in, fill='mean', rescale_intensity=False, grid_shape=None,
         arr_in = np.asarray(arr_in)[..., np.newaxis]
 
     if arr_in.ndim != 4:
-        raise ValueError('Input array has to be 3-dimensional '
-                         'or 4-dimensional, with `multichannel=True`')
+        raise ValueError('Input array has to be 3-dimensional for grayscale '
+                         'images, or 4-dimensional with `multichannel=True` '
+                         'for color images.')
 
     n_images, n_rows, n_cols, n_chan = arr_in.shape
 


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

Issue:
Broken link in `separate_stains` docstring
https://mecourse.com/landinig/software/cdeconv/cdeconv.html returns a 404. I could not find an equivalent from an (extremely quick) google search. 


Discussion:
How about switching to an archive: https://web.archive.org/web/20160624145052/http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html
I like your idea @sciunto !

Resolving patch:
diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py
--- a/skimage/color/colorconv.py
+++ b/skimage/color/colorconv.py
@@ -503,7 +503,7 @@ def get_xyz_coords(illuminant, observer, dtype=float):
 
 # Following matrices are adapted form the Java code written by G.Landini.
 # The original code is available at:
-# https://mecourse.com/landinig/software/cdeconv/cdeconv.html
+# https://web.archive.org/web/20160624145052/http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html
 
 # Hematoxylin + DAB
 rgb_from_hdx = np.array([[0.650, 0.704, 0.286],
@@ -1447,7 +1447,7 @@ def separate_stains(rgb, conv_matrix):
 
     References
     ----------
-    .. [1] https://mecourse.com/landinig/software/cdeconv/cdeconv.html
+    .. [1] https://web.archive.org/web/20160624145052/http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html
 
     Examples
     --------
@@ -1502,7 +1502,7 @@ def combine_stains(stains, conv_matrix):
 
     References
     ----------
-    .. [1] https://mecourse.com/landinig/software/cdeconv/cdeconv.html
+    .. [1] https://web.archive.org/web/20160624145052/http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html
 
     Examples
     --------


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

Issue:
Bugs in label2rgb
There seem to be one or several bugs in `label2rgb`. I discovered this when building the website doc for 0.17.0 and it might be serious enough that I want to hold the release. 

For example
```
img = np.random.randint(0, 255, (10, 10), dtype=np.uint8) 
labels = np.zeros((10, 10), dtype=np.uint8)
labels[1:3, 1:3]=1
labels[6:9, 6:9] = 2
color.label2rgb(labels, image=img, bg_color=0)
```
gives a ValueError

In the gallery `segmentation/plot_label.py` example, `label2rgb` is returning an array of floats which is bizarre, and the floats are between 0 and 255.

The broken gallery examples are
 https://scikit-image.org/docs/dev/auto_examples/segmentation/plot_join_segmentations.html#sphx-glr-auto-examples-segmentation-plot-join-segmentations-py
https://scikit-image.org/docs/dev/auto_examples/segmentation/plot_label.html#sphx-glr-auto-examples-segmentation-plot-label-py
https://scikit-image.org/docs/dev/auto_examples/segmentation/plot_compact_watershed.html#sphx-glr-auto-examples-segmentation-plot-compact-watershed-py

If someone has the time to investigate that'd be awesome because I'm reluctant to release with such a regression (BTW I already pushed the stable docs for this branch but we can upload a new version after when we have a fix, it's not as bad as having a buggy version on Pypi).
 


Discussion:

Resolving patch:
diff --git a/skimage/__init__.py b/skimage/__init__.py
--- a/skimage/__init__.py
+++ b/skimage/__init__.py
@@ -69,7 +69,7 @@
 import sys
 
 
-__version__ = '0.17.dev0'
+__version__ = '0.18.dev0'
 
 from ._shared.version_requirements import ensure_python_version
 ensure_python_version((3, 5))
diff --git a/skimage/color/colorlabel.py b/skimage/color/colorlabel.py
--- a/skimage/color/colorlabel.py
+++ b/skimage/color/colorlabel.py
@@ -166,6 +166,8 @@ def _label2rgb_overlay(label, image=None, colors=None, alpha=0.3,
 
         if image.ndim > label.ndim:
             image = img_as_float(rgb2gray(image))
+        else:
+            image = img_as_float(image)
         image = gray2rgb(image) * image_alpha + (1 - image_alpha)
 
     # Ensure that all labels are non-negative so we can index into


Test patch:
diff --git a/skimage/color/tests/test_colorlabel.py b/skimage/color/tests/test_colorlabel.py
--- a/skimage/color/tests/test_colorlabel.py
+++ b/skimage/color/tests/test_colorlabel.py
@@ -38,6 +38,17 @@ def test_wrong_kind():
         label2rgb(label, kind='foo', bg_label=-1)
 
 
+def test_uint_image():
+    img = np.random.randint(0, 255, (10, 10), dtype=np.uint8)
+    labels = np.zeros((10, 10), dtype=np.int64)
+    labels[1:3, 1:3] = 1
+    labels[6:9, 6:9] = 2
+    output = label2rgb(labels, image=img, bg_label=0)
+    # Make sure that the output is made of floats and in the correct range
+    assert np.issubdtype(output.dtype, np.floating)
+    assert output.max() <= 1
+
+
 def test_rgb():
     image = np.ones((1, 3))
     label = np.arange(3).reshape(1, -1)