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

Issue:
Pooch update breaks import
## Description

Pooch recently updated to version 1.5.0.  This moved the hash functions to their own module, so the current method of importing them now fails.  Further, the fallback for if pooch is not installed doesn't work because the exact error is different.
<!--
(Note: for guidance on how to use `scikit-image`, please post instead on https://forum.image.sc/tag/scikit-image)
-->

## Way to reproduce
```python
import skimage.metrics
```
Note, install pooch 1.5.0 first.

You'll see
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.8/site-packages/skimage/__init__.py", line 135, in <module>
    from .data import data_dir
  File ".../python3.8/site-packages/skimage/data/__init__.py", line 64, in <module>
    from pooch.utils import file_hash
ImportError: cannot import name 'file_hash' from 'pooch.utils' (.../python3.8/site-packages/pooch/utils.py)
```

## Version information
```python
# Paste the output of the following python commands
from __future__ import print_function
import sys; print(sys.version)
import platform; print(platform.platform())
import skimage; print("scikit-image version: {}".format(skimage.__version__))
import numpy; print("numpy version: {}".format(numpy.__version__))
```

```python
# your output here
3.8.10 (default, May  5 2021, 03:01:07)
[GCC 7.5.0]
Linux-5.4.0-80-generic-x86_64-with-glibc2.27
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.8/site-packages/skimage/__init__.py", line 135, in <module>
    from .data import data_dir
  File ".../python3.8/site-packages/skimage/data/__init__.py", line 64, in <module>
    from pooch.utils import file_hash
ImportError: cannot import name 'file_hash' from 'pooch.utils' (.../python3.8/site-packages/pooch/utils.py)
numpy version: 1.21.2
```

I'm using ```scikit-image version: 0.18.2```

## Possible Fix

One solution would be to change `skimage/data/__init__.py`, where it reads
```
    from pooch.utils import file_hash
```
to
```
    try:
        from pooch.utils import file_hash
    except ImportError:
        from pooch.hashes import file_hash
```



Discussion:

Resolving patch:
diff --git a/skimage/data/__init__.py b/skimage/data/__init__.py
--- a/skimage/data/__init__.py
+++ b/skimage/data/__init__.py
@@ -62,7 +62,7 @@
 skimage_distribution_dir = osp.join(legacy_data_dir, '..')
 
 try:
-    from pooch.utils import file_hash
+    from pooch import file_hash
 except ModuleNotFoundError:
     # Function taken from
     # https://github.com/fatiando/pooch/blob/master/pooch/utils.py


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

Issue:
installation issues with setuptools 58.5.x
## Description

I observed some failures on CI in a recent PR that appear to be related to use of setuptools >= 58.5.0. Example: https://github.com/scikit-image/scikit-image/runs/4104921276?check_suite_focus=true

I was able to reproduce the issue locally with 58.5.0, but it does not occur for 58.4.0. A temporary workaround would be to pin setuptools <58.5 on CI.



## Way to reproduce

build from source with setuptools >= 58.5




Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -8,8 +8,8 @@
 import textwrap
 
 import setuptools
-from distutils.command.build_py import build_py
-from distutils.command.sdist import sdist
+from setuptools.command.build_py import build_py
+from setuptools.command.sdist import sdist
 from distutils.errors import CompileError, LinkError
 from numpy.distutils.command.build_ext import build_ext
 


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

Issue:
API docs for the dev version are currently missing the filter module
## Description

I noticed today that the `filters` module missing from the API section of the dev docs. It shows up correctly in the 0.18.x ones. Specifically it is not listed on this page:

https://scikit-image.org/docs/dev/api/api.html

It is not just that the link is missing at the top-level API page. https://scikit-image.org/docs/dev/api/skimage.filters.html also gives a 404.



Discussion:

Resolving patch:
diff --git a/doc/tools/apigen.py b/doc/tools/apigen.py
--- a/doc/tools/apigen.py
+++ b/doc/tools/apigen.py
@@ -211,9 +211,10 @@ def _parse_module_with_import(self, uri):
         submodules = []
         for obj_str in obj_strs:
             # find the actual object from its string representation
-            if obj_str not in mod.__dict__:
+            try:
+                obj = getattr(mod, obj_str)
+            except AttributeError:
                 continue
-            obj = mod.__dict__[obj_str]
 
             # figure out if obj is a function or class
             if isinstance(obj, (FunctionType, BuiltinFunctionType)):


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

Issue:
unintentional change to skimage.data public API
## Description

The `skimage.data.image_fetcher` is no longer available. This has caused test failures in napari for scikit-image 0.19.0.

I will open a PR now to restore it to the public API.

## Way to reproduce
```Python
from skimage.data import image_fetcher`
```
will result in an `ImportError`


## Version information
0.19.0


Discussion:

Resolving patch:
diff --git a/skimage/data/__init__.py b/skimage/data/__init__.py
--- a/skimage/data/__init__.py
+++ b/skimage/data/__init__.py
@@ -5,11 +5,12 @@
     submodules={},
     submod_attrs={
         '_binary_blobs': ['binary_blobs'],
-        '_fetchers': ['data_dir', 'download_all', 'astronaut', 'binary_blobs',
-                      'brain', 'brick', 'camera', 'cat', 'cell', 'cells3d',
-                      'checkerboard', 'chelsea', 'clock', 'coffee', 'coins',
-                      'colorwheel', 'eagle', 'grass', 'gravel', 'horse',
-                      'hubble_deep_field', 'human_mitosis',
+        '_fetchers': ['create_image_fetcher', 'data_dir', 'download_all',
+                      'file_hash', 'image_fetcher', 'astronaut',
+                      'binary_blobs', 'brain', 'brick', 'camera', 'cat',
+                      'cell', 'cells3d', 'checkerboard', 'chelsea', 'clock',
+                      'coffee', 'coins', 'colorwheel', 'eagle', 'grass',
+                      'gravel', 'horse', 'hubble_deep_field', 'human_mitosis',
                       'immunohistochemistry', 'kidney',
                       'lbp_frontal_face_cascade_filename', 'lily',
                       'lfw_subset', 'logo', 'microaneurysms', 'moon', 'page',


Test patch:
diff --git a/skimage/data/tests/test_data.py b/skimage/data/tests/test_data.py
--- a/skimage/data/tests/test_data.py
+++ b/skimage/data/tests/test_data.py
@@ -198,3 +198,12 @@ def test_vortex():
     image0, image1 = data.vortex()
     for image in [image0, image1]:
         assert image.shape == (512, 512)
+
+
+@pytest.mark.parametrize(
+    'function_name', ['create_image_fetcher', 'file_hash', 'image_fetcher']
+)
+def test_fetchers_are_public(function_name):
+    # Check that the following functions that are only used indirectly in the
+    # above tests are public.
+    assert hasattr(data, function_name)
Repository: scikit-image/scikit-image

Issue:
broken match histograms gallery example
## Description

This bug was reported here: https://forum.image.sc/t/exposure-match-histograms-broken/61682

Most likely this is due to some unintended change in scaling that was introduced when adding the float32 support, so hopefully it is an easy fix. I can take a look soon.

## Way to reproduce

Run the following demo with v0.19.0 or v0.19.1: https://scikit-image.org/docs/stable/auto_examples/color_exposure/plot_histogram_matching.html#sphx-glr-auto-examples-color-exposure-plot-histogram-matching-py



Discussion:

Resolving patch:
diff --git a/skimage/exposure/histogram_matching.py b/skimage/exposure/histogram_matching.py
--- a/skimage/exposure/histogram_matching.py
+++ b/skimage/exposure/histogram_matching.py
@@ -63,7 +63,6 @@ def match_histograms(image, reference, *, channel_axis=None,
     if image.ndim != reference.ndim:
         raise ValueError('Image and reference must have the same number '
                          'of channels.')
-    out_dtype = utils._supported_float_type(image.dtype)
 
     if channel_axis is not None:
         if image.shape[-1] != reference.shape[-1]:
@@ -79,4 +78,8 @@ def match_histograms(image, reference, *, channel_axis=None,
         # _match_cumulative_cdf will always return float64 due to np.interp
         matched = _match_cumulative_cdf(image, reference)
 
-    return matched.astype(out_dtype, copy=False)
+    if matched.dtype.kind == 'f':
+        # output a float32 result when the input is float16 or float32
+        out_dtype = utils._supported_float_type(image.dtype)
+        matched = matched.astype(out_dtype, copy=False)
+    return matched


Test patch:
diff --git a/skimage/exposure/tests/test_histogram_matching.py b/skimage/exposure/tests/test_histogram_matching.py
--- a/skimage/exposure/tests/test_histogram_matching.py
+++ b/skimage/exposure/tests/test_histogram_matching.py
@@ -62,6 +62,7 @@ def test_match_histograms_channel_axis(self, channel_axis):
         reference = np.moveaxis(self.template_rgb, -1, channel_axis)
         matched = exposure.match_histograms(image, reference,
                                             channel_axis=channel_axis)
+        assert matched.dtype == image.dtype
         matched = np.moveaxis(matched, channel_axis, -1)
         reference = np.moveaxis(reference, channel_axis, -1)
         matched_pdf = self._calculate_image_empirical_pdf(matched)
Repository: scikit-image/scikit-image

Issue:
Confusing example on perimeter measurements
## Description

Looking at the gallery, I'm confused by this example: https://scikit-image.org/docs/stable/auto_examples/segmentation/plot_perimeters.html#sphx-glr-auto-examples-segmentation-plot-perimeters-py

The text speaks about a square and its rotated version, but the code is about a square and a disk. Am I missing something?


Discussion:

Resolving patch:
diff --git a/doc/examples/segmentation/plot_perimeters.py b/doc/examples/segmentation/plot_perimeters.py
--- a/doc/examples/segmentation/plot_perimeters.py
+++ b/doc/examples/segmentation/plot_perimeters.py
@@ -1,25 +1,26 @@
 """
-=========================
-Different perimeters
-=========================
+============================================
+Measure perimeters with different estimators
+============================================
 
-In this example we show the uncertainty on calculating perimeters, comparing
-classic and Crofton ones. For that, we evaluate the perimeters of a square and
-its rotated version.
+In this example, we show the error on measuring perimeters, comparing classic
+approximations and Crofton ones. For that, we estimate the perimeter of an
+object (either a square or a disk) and its rotated version, as we increase the
+rotation angle.
 
 """
-from skimage.measure import perimeter
-from skimage.measure import perimeter_crofton
-from skimage.transform import rotate
 import matplotlib.pyplot as plt
 import numpy as np
 
+from skimage.measure import perimeter, perimeter_crofton
+from skimage.transform import rotate
+
 
 # scale parameter can be used to increase the grid size. The resulting curves
 # should be smoothed with higher scales
 scale = 10
 
-# Construct 2 figures, square and disks
+# Construct two objects, a square and a disk
 square = np.zeros((100*scale, 100*scale))
 square[40*scale:60*scale, 40*scale:60*scale] = 1
 
@@ -33,25 +34,24 @@
 dX = X[0, 1] - X[0, 0]
 true_perimeters = [80 * scale, 2 * np.pi * R / dX]
 
-# for each type of objects, the different perimeters are evaluated
+# For each type of object, estimate its perimeter as the object is rotated,
+# according to different approximations
 for index, obj in enumerate([square, disk]):
 
-    # 2 neighborhood configurations for measure.perimeter
-    for n in [4, 6]:
+    # `neighbourhood` value can be 4 or 8 for the classic perimeter estimator
+    for n in [4, 8]:
         p = []
         angles = range(90)
         for i in angles:
-            # rotation and perimeter evaluation
             rotated = rotate(obj, i, order=0)
             p.append(perimeter(rotated, n))
         ax[index].plot(angles, p)
 
-    # 2 or 4 directions can be used by measure.perimeter_crofton
+    # `directions` value can be 2 or 4 for the Crofton estimator
     for d in [2, 4]:
         p = []
         angles = np.arange(0, 90, 2)
         for i in angles:
-            # rotation and perimeter evaluation
             rotated = rotate(obj, i, order=0)
             p.append(perimeter_crofton(rotated, d))
         ax[index].plot(angles, p)


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

Issue:
Undefined names in Python code found with flake8
## Description


## Way to reproduce
[flake8](http://flake8.pycqa.org) testing of https://github.com/scikit-image/scikit-image on Python 3.7.1

$ __flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics__
```
./skimage/measure/mc_meta/createluts.py:139:18: F821 undefined name 'luts'
    for a in dir(luts):
                 ^
./doc/ext/notebook_doc.py:1:1: F822 undefined name 'python_to_notebook' in __all__
__all__ = ['python_to_notebook', 'Notebook']
^
1     F821 undefined name 'luts'
1     F822 undefined name 'python_to_notebook' in __all__
2
```
__E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety.
* F821: undefined name `name`
* F822: undefined name `name` in `__all__`
* F823: local variable name referenced before assignment
* E901: SyntaxError or IndentationError
* E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree



Discussion:
Hmm, thanks. I had a flake8 cleanup at some point. I like your showstopper idea. That might be a good way to choose what flake 8 tests to include.
`./skimage/measure/mc_meta` directory is here for maint/dev purpose. Can't it be removed from skimage source tree, or moved to its own repo?

Resolving patch:
diff --git a/doc/ext/notebook_doc.py b/doc/ext/notebook_doc.py
--- a/doc/ext/notebook_doc.py
+++ b/doc/ext/notebook_doc.py
@@ -1,4 +1,4 @@
-__all__ = ['python_to_notebook', 'Notebook']
+__all__ = ['Notebook']
 
 import json
 import copy


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

Issue:
`imsave` has incorrect type in docstring
## Description

The docstring for `skimage.io.imsave` is incorrect:

https://github.com/scikit-image/scikit-image/blob/376d30f5ba83e98d2745622d9d4951914e0c91f7/skimage/io/_io.py#L106

The actual implementation accepts `str | Path`

https://github.com/scikit-image/scikit-image/blob/376d30f5ba83e98d2745622d9d4951914e0c91f7/skimage/io/_io.py#L131-L132

IDEs such as PyCharm read the docstring and provide a warning when passing in a `Path`, even though this is valid.

The problem as a whole would probably be better solved by moving this information into true type annotations:
- #3153


Discussion:
Thank you for this. I think helping IDEs is an important consideration (there are other considerations of course!)

I think you can change the docstring to `path-like` or something similar. I would support a PR doing this.

You can try by simply editing the source and changin it to `Pathlike` and seeing if the complaints go away. Then you can make a easy PR to scikit-image.
For reference here is the syntax that PyCharm supports in docstring type annotations:

- https://www.jetbrains.com/help/pycharm/type-syntax-for-docstrings.html

Resolving patch:
diff --git a/skimage/io/_io.py b/skimage/io/_io.py
--- a/skimage/io/_io.py
+++ b/skimage/io/_io.py
@@ -18,7 +18,7 @@ def imread(fname, as_gray=False, plugin=None, **plugin_args):
 
     Parameters
     ----------
-    fname : string
+    fname : str or pathlib.Path
         Image file name, e.g. ``test.jpg`` or URL.
     as_gray : bool, optional
         If True, convert color images to gray-scale (64-bit floats).
@@ -103,7 +103,7 @@ def imsave(fname, arr, plugin=None, check_contrast=True, **plugin_args):
 
     Parameters
     ----------
-    fname : str
+    fname : str or pathlib.Path
         Target filename.
     arr : ndarray of shape (M,N) or (M,N,3) or (M,N,4)
         Image data.


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

Issue:
Address new matplotlib >= 3.5 dependency in skimage.future.graph.rag.show_rag
## Description

With #6483, `skimage.future.graph.rag.show_rag` now requires matplotlib >= 3.5 which trips up our CI when matplotlib 3.4 or earlier are used. We can either (a) bump our matplotlib for the whole package (currently >=3.3) or (b) we configure our test suite to ignore it "for now". I'm voting for the first (a).

## Way to reproduce

Run doctests with matplotlib < 3.5.


Discussion:

Resolving patch:
diff --git a/skimage/future/graph/rag.py b/skimage/future/graph/rag.py
--- a/skimage/future/graph/rag.py
+++ b/skimage/future/graph/rag.py
@@ -446,7 +446,7 @@ def rag_boundary(labels, edge_map, connectivity=2):
     return rag
 
 
-@require("matplotlib", ">=3.5")
+@require("matplotlib", ">=3.3")
 def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
              edge_cmap='magma', img_cmap='bone', in_place=True, ax=None):
     """Show a Region Adjacency Graph on an image.
@@ -498,7 +498,7 @@ def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
     >>> lc = graph.show_rag(labels, g, img)
     >>> cbar = plt.colorbar(lc)
     """
-    from matplotlib import colors, colormaps
+    from matplotlib import colors
     from matplotlib import pyplot as plt
     from matplotlib.collections import LineCollection
 
@@ -516,12 +516,12 @@ def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
         # Ignore the alpha channel
         out = image[:, :, :3]
     else:
-        img_cmap = colormaps[img_cmap]
+        img_cmap = plt.get_cmap(img_cmap)
         out = color.rgb2gray(image)
         # Ignore the alpha channel
         out = img_cmap(out)[:, :, :3]
 
-    edge_cmap = colormaps[edge_cmap]
+    edge_cmap = plt.get_cmap(edge_cmap)
 
     # Handling the case where one node has multiple labels
     # offset is 1 so that regionprops does not ignore 0


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

Issue:
api_changes.md not updated since 0.16
## Description

[API Changes](https://scikit-image.org/docs/0.19.x/api_changes.html) has not been updated since 0.16, although notable changes took place.


Discussion:
Hmm, the [source file](https://github.com/scikit-image/scikit-image/blob/main/doc/source/api_changes.md) hasn't been edited in two years indeed... and it's not entirely clear to me that each version entry would be a summary of the more detailed "API Changes" section for each minor version release (release notes found at: https://github.com/scikit-image/scikit-image/tree/main/doc/release).
It seems that the release notes should be the single source of truth. They are already linked on the docs main page, but I overlooked them, because of the prominent "API Reference ([**changes**](https://scikit-image.org/docs/0.19.x/api_changes.html))" link.

If `api_changes` is not updated anymore, it should be dropped, I think.
@moi90 you are right. Would you be able to submit a PR removing `api_changes.md` and all references to it (seeing references to `api_changes.txt` as well, although this file doesn't exist)? Thanks anyway!
`CONTRIBUTING.rst` and `TODO.txt` currently reference api_changes.

> If your change introduces any API modifications, please update `doc/source/api_changes.txt`.

What is the current appropriate place? `doc/release/release_dev.rst`?

Although I can create a pull request with search&replace, I think the @scikit-image/core developers should define and phrase a proper policy.

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -452,3 +452,13 @@ def linkcode_resolve(domain, info):
     else:
         return ("https://github.com/scikit-image/scikit-image/blob/"
                 "v%s/skimage/%s%s" % (skimage.__version__, fn, linespec))
+
+
+# ----------------------------------------------------------------------------
+# MyST
+# ----------------------------------------------------------------------------
+
+myst_enable_extensions = [
+    # Enable fieldlist to allow for Field Lists like in rST (e.g., :orphan:)
+    "fieldlist",
+]


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

Issue:
matplotlib 3.6.0 compatibility
## Description

Just now in #6446, I saw the following new test failure in our Euler number example. It seems to be related to a deprecation in Matplotlib 3.6.0.

```
Warning, treated as error:
/home/runner/work/scikit-image/scikit-image/doc/examples/segmentation/plot_euler_number.py failed to execute correctly: Traceback (most recent call last):
  File "/home/runner/work/scikit-image/scikit-image/doc/examples/segmentation/plot_euler_number.py", line 151, in <module>
    display_voxels(cube)
  File "/home/runner/work/scikit-image/scikit-image/doc/examples/segmentation/plot_euler_number.py", line 129, in display_voxels
    ax = make_ax()
  File "/home/runner/work/scikit-image/scikit-image/doc/examples/segmentation/plot_euler_number.py", line 74, in make_ax
    ax = fig.gca(projection='3d')
TypeError: gca() got an unexpected keyword argument 'projection'
```

## Way to reproduce
see CI log [here](https://github.com/scikit-image/scikit-image/actions/runs/3068167689/jobs/4955299213)



Discussion:
Change is mentioned here: https://matplotlib.org/devdocs/api/next_api_changes/removals/23077-GL.html#
Looks like we just need to update that example to not pass any kwargs to `gca`

Resolving patch:
diff --git a/doc/examples/segmentation/plot_euler_number.py b/doc/examples/segmentation/plot_euler_number.py
--- a/doc/examples/segmentation/plot_euler_number.py
+++ b/doc/examples/segmentation/plot_euler_number.py
@@ -70,8 +70,7 @@
 
 
 def make_ax(grid=False):
-    fig = plt.figure()
-    ax = fig.gca(projection='3d')
+    ax = plt.figure().add_subplot(projection='3d')
     ax.grid(grid)
     ax.set_axis_off()
     return ax


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

Issue:
skimage segmentation flood docs
https://github.com/scikit-image/scikit-image/blob/b8ce4d0c2c65684b131870abfe60228136108d4e/skimage/morphology/_flood_fill.py#L138

I'm checking the docs on the flood function:
"Adjacent pixels whose squared distance from the center is **larger** or equal to connectivity are considered neighbors. Ignored if footprint is not None."

Maybe I'm wrong, but shouldn't this be "less" instead of larger?

Example:
if connectivity == 1, that should mean a pixel's neighbors will be up, down, left, right, and
if connectivity == 2, then all 8 surrounding pixels are neighbors, since diagonal elements are sqrt(2) distance away, which equals 2 squared distance.

Can you fix this in the docs?
Or explain it, if I'm wrong?
Thanks


Discussion:
Oops! Yes, of course, it should read "less than or equal to" -- thanks for reporting, @balazon! Would you mind submitting a PR to fix this typo?

Resolving patch:
diff --git a/skimage/morphology/_flood_fill.py b/skimage/morphology/_flood_fill.py
--- a/skimage/morphology/_flood_fill.py
+++ b/skimage/morphology/_flood_fill.py
@@ -135,7 +135,7 @@ def flood(image, seed_point, *, footprint=None, connectivity=None,
         are considered as part of the neighborhood (fully connected).
     connectivity : int, optional
         A number used to determine the neighborhood of each evaluated pixel.
-        Adjacent pixels whose squared distance from the center is larger or
+        Adjacent pixels whose squared distance from the center is less than or
         equal to `connectivity` are considered neighbors. Ignored if
         `footprint` is not None.
     tolerance : float or int, optional


Test patch: