We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
type error for morphology.remove_small_objects()
Is it better to add type error for non-labeled int? 

``` python
a = np.array([[0, 0, 0, 1, 0],
    [1, 1, 1, 0, 0],
    [1, 1, 1, 0, 1]], int)

b = morphology.remove_small_objects(a, 6)

print b

[[0 0 0 1 0]
 [1 1 1 0 0]
 [1 1 1 0 1]]
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `skimage/morphology/misc.py`
Content:
```
1 import numpy as np
2 import functools
3 import scipy.ndimage as nd
4 from .selem import _default_selem
5 
6 # Our function names don't exactly correspond to ndimages.
7 # This dictionary translates from our names to scipy's.
8 funcs = ('erosion', 'dilation', 'opening', 'closing')
9 skimage2ndimage = dict((x, 'grey_' + x) for x in funcs)
10 
11 # These function names are the same in ndimage.
12 funcs = ('binary_erosion', 'binary_dilation', 'binary_opening',
13          'binary_closing', 'black_tophat', 'white_tophat')
14 skimage2ndimage.update(dict((x, x) for x in funcs))
15 
16 
17 def default_fallback(func):
18     """Decorator to fall back on ndimage for images with more than 2 dimensions
19 
20     Decorator also provides a default structuring element, `selem`, with the
21     appropriate dimensionality if none is specified.
22 
23     Parameters
24     ----------
25     func : function
26         A morphology function such as erosion, dilation, opening, closing,
27         white_tophat, or black_tophat.
28 
29     Returns
30     -------
31     func_out : function
32         If the image dimentionality is greater than 2D, the ndimage
33         function is returned, otherwise skimage function is used.
34     """
35     @functools.wraps(func)
36     def func_out(image, selem=None, out=None, **kwargs):
37         # Default structure element
38         if selem is None:
39             selem = _default_selem(image.ndim)
40 
41         # If image has more than 2 dimensions, use scipy.ndimage
42         if image.ndim > 2:
43             function = getattr(nd, skimage2ndimage[func.__name__])
44             try:
45                 return function(image, footprint=selem, output=out, **kwargs)
46             except TypeError:
47                 # nd.binary_* take structure instead of footprint
48                 return function(image, structure=selem, output=out, **kwargs)
49         else:
50             return func(image, selem=selem, out=out, **kwargs)
51 
52     return func_out
53 
54 
55 def remove_small_objects(ar, min_size=64, connectivity=1, in_place=False):
56     """Remove connected components smaller than the specified size.
57 
58     Parameters
59     ----------
60     ar : ndarray (arbitrary shape, int or bool type)
61         The array containing the connected components of interest. If the array
62         type is int, it is assumed that it contains already-labeled objects.
63         The ints must be non-negative.
64     min_size : int, optional (default: 64)
65         The smallest allowable connected component size.
66     connectivity : int, {1, 2, ..., ar.ndim}, optional (default: 1)
67         The connectivity defining the neighborhood of a pixel.
68     in_place : bool, optional (default: False)
69         If `True`, remove the connected components in the input array itself.
70         Otherwise, make a copy.
71 
72     Raises
73     ------
74     TypeError
75         If the input array is of an invalid type, such as float or string.
76     ValueError
77         If the input array contains negative values.
78 
79     Returns
80     -------
81     out : ndarray, same shape and type as input `ar`
82         The input array with small connected components removed.
83 
84     Examples
85     --------
86     >>> from skimage import morphology
87     >>> a = np.array([[0, 0, 0, 1, 0],
88     ...               [1, 1, 1, 0, 0],
89     ...               [1, 1, 1, 0, 1]], bool)
90     >>> b = morphology.remove_small_objects(a, 6)
91     >>> b
92     array([[False, False, False, False, False],
93            [ True,  True,  True, False, False],
94            [ True,  True,  True, False, False]], dtype=bool)
95     >>> c = morphology.remove_small_objects(a, 7, connectivity=2)
96     >>> c
97     array([[False, False, False,  True, False],
98            [ True,  True,  True, False, False],
99            [ True,  True,  True, False, False]], dtype=bool)
100     >>> d = morphology.remove_small_objects(a, 6, in_place=True)
101     >>> d is a
102     True
103     """
104     # Should use `issubdtype` for bool below, but there's a bug in numpy 1.7
105     if not (ar.dtype == bool or np.issubdtype(ar.dtype, np.integer)):
106         raise TypeError("Only bool or integer image types are supported. "
107                         "Got %s." % ar.dtype)
108 
109     if in_place:
110         out = ar
111     else:
112         out = ar.copy()
113 
114     if min_size == 0:  # shortcut for efficiency
115         return out
116 
117     if out.dtype == bool:
118         selem = nd.generate_binary_structure(ar.ndim, connectivity)
119         ccs = np.zeros_like(ar, dtype=np.int32)
120         nd.label(ar, selem, output=ccs)
121     else:
122         ccs = out
123 
124     try:
125         component_sizes = np.bincount(ccs.ravel())
126     except ValueError:
127         raise ValueError("Negative value labels are not supported. Try "
128                          "relabeling the input with `scipy.ndimage.label` or "
129                          "`skimage.morphology.label`.")
130 
131     too_small = component_sizes < min_size
132     too_small_mask = too_small[ccs]
133     out[too_small_mask] = 0
134 
135     return out
136
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/skimage/morphology/misc.py b/skimage/morphology/misc.py
--- a/skimage/morphology/misc.py
+++ b/skimage/morphology/misc.py
@@ -1,5 +1,6 @@
 import numpy as np
 import functools
+import warnings
 import scipy.ndimage as nd
 from .selem import _default_selem
 
@@ -128,6 +129,10 @@
                          "relabeling the input with `scipy.ndimage.label` or "
                          "`skimage.morphology.label`.")
 
+    if len(component_sizes) == 2:
+        warnings.warn("Only one label was provided to `remove_small_objects`. "
+                      "Did you mean to use a boolean array?")
+
     too_small = component_sizes < min_size
     too_small_mask = too_small[ccs]
     out[too_small_mask] = 0

{"golden_diff": "diff --git a/skimage/morphology/misc.py b/skimage/morphology/misc.py\n--- a/skimage/morphology/misc.py\n+++ b/skimage/morphology/misc.py\n@@ -1,5 +1,6 @@\n import numpy as np\n import functools\n+import warnings\n import scipy.ndimage as nd\n from .selem import _default_selem\n \n@@ -128,6 +129,10 @@\n                          \"relabeling the input with `scipy.ndimage.label` or \"\n                          \"`skimage.morphology.label`.\")\n \n+    if len(component_sizes) == 2:\n+        warnings.warn(\"Only one label was provided to `remove_small_objects`. \"\n+                      \"Did you mean to use a boolean array?\")\n+\n     too_small = component_sizes < min_size\n     too_small_mask = too_small[ccs]\n     out[too_small_mask] = 0\n", "issue": "type error for morphology.remove_small_objects()\nIs it better to add type error for non-labeled int? \n\n``` python\na = np.array([[0, 0, 0, 1, 0],\n    [1, 1, 1, 0, 0],\n    [1, 1, 1, 0, 1]], int)\n\nb = morphology.remove_small_objects(a, 6)\n\nprint b\n\n[[0 0 0 1 0]\n [1 1 1 0 0]\n [1 1 1 0 1]]\n```\n\n", "before_files": [{"content": "import numpy as np\nimport functools\nimport scipy.ndimage as nd\nfrom .selem import _default_selem\n\n# Our function names don't exactly correspond to ndimages.\n# This dictionary translates from our names to scipy's.\nfuncs = ('erosion', 'dilation', 'opening', 'closing')\nskimage2ndimage = dict((x, 'grey_' + x) for x in funcs)\n\n# These function names are the same in ndimage.\nfuncs = ('binary_erosion', 'binary_dilation', 'binary_opening',\n         'binary_closing', 'black_tophat', 'white_tophat')\nskimage2ndimage.update(dict((x, x) for x in funcs))\n\n\ndef default_fallback(func):\n    \"\"\"Decorator to fall back on ndimage for images with more than 2 dimensions\n\n    Decorator also provides a default structuring element, `selem`, with the\n    appropriate dimensionality if none is specified.\n\n    Parameters\n    ----------\n    func : function\n        A morphology function such as erosion, dilation, opening, closing,\n        white_tophat, or black_tophat.\n\n    Returns\n    -------\n    func_out : function\n        If the image dimentionality is greater than 2D, the ndimage\n        function is returned, otherwise skimage function is used.\n    \"\"\"\n    @functools.wraps(func)\n    def func_out(image, selem=None, out=None, **kwargs):\n        # Default structure element\n        if selem is None:\n            selem = _default_selem(image.ndim)\n\n        # If image has more than 2 dimensions, use scipy.ndimage\n        if image.ndim > 2:\n            function = getattr(nd, skimage2ndimage[func.__name__])\n            try:\n                return function(image, footprint=selem, output=out, **kwargs)\n            except TypeError:\n                # nd.binary_* take structure instead of footprint\n                return function(image, structure=selem, output=out, **kwargs)\n        else:\n            return func(image, selem=selem, out=out, **kwargs)\n\n    return func_out\n\n\ndef remove_small_objects(ar, min_size=64, connectivity=1, in_place=False):\n    \"\"\"Remove connected components smaller than the specified size.\n\n    Parameters\n    ----------\n    ar : ndarray (arbitrary shape, int or bool type)\n        The array containing the connected components of interest. If the array\n        type is int, it is assumed that it contains already-labeled objects.\n        The ints must be non-negative.\n    min_size : int, optional (default: 64)\n        The smallest allowable connected component size.\n    connectivity : int, {1, 2, ..., ar.ndim}, optional (default: 1)\n        The connectivity defining the neighborhood of a pixel.\n    in_place : bool, optional (default: False)\n        If `True`, remove the connected components in the input array itself.\n        Otherwise, make a copy.\n\n    Raises\n    ------\n    TypeError\n        If the input array is of an invalid type, such as float or string.\n    ValueError\n        If the input array contains negative values.\n\n    Returns\n    -------\n    out : ndarray, same shape and type as input `ar`\n        The input array with small connected components removed.\n\n    Examples\n    --------\n    >>> from skimage import morphology\n    >>> a = np.array([[0, 0, 0, 1, 0],\n    ...               [1, 1, 1, 0, 0],\n    ...               [1, 1, 1, 0, 1]], bool)\n    >>> b = morphology.remove_small_objects(a, 6)\n    >>> b\n    array([[False, False, False, False, False],\n           [ True,  True,  True, False, False],\n           [ True,  True,  True, False, False]], dtype=bool)\n    >>> c = morphology.remove_small_objects(a, 7, connectivity=2)\n    >>> c\n    array([[False, False, False,  True, False],\n           [ True,  True,  True, False, False],\n           [ True,  True,  True, False, False]], dtype=bool)\n    >>> d = morphology.remove_small_objects(a, 6, in_place=True)\n    >>> d is a\n    True\n    \"\"\"\n    # Should use `issubdtype` for bool below, but there's a bug in numpy 1.7\n    if not (ar.dtype == bool or np.issubdtype(ar.dtype, np.integer)):\n        raise TypeError(\"Only bool or integer image types are supported. \"\n                        \"Got %s.\" % ar.dtype)\n\n    if in_place:\n        out = ar\n    else:\n        out = ar.copy()\n\n    if min_size == 0:  # shortcut for efficiency\n        return out\n\n    if out.dtype == bool:\n        selem = nd.generate_binary_structure(ar.ndim, connectivity)\n        ccs = np.zeros_like(ar, dtype=np.int32)\n        nd.label(ar, selem, output=ccs)\n    else:\n        ccs = out\n\n    try:\n        component_sizes = np.bincount(ccs.ravel())\n    except ValueError:\n        raise ValueError(\"Negative value labels are not supported. Try \"\n                         \"relabeling the input with `scipy.ndimage.label` or \"\n                         \"`skimage.morphology.label`.\")\n\n    too_small = component_sizes < min_size\n    too_small_mask = too_small[ccs]\n    out[too_small_mask] = 0\n\n    return out\n", "path": "skimage/morphology/misc.py"}], "after_files": [{"content": "import numpy as np\nimport functools\nimport warnings\nimport scipy.ndimage as nd\nfrom .selem import _default_selem\n\n# Our function names don't exactly correspond to ndimages.\n# This dictionary translates from our names to scipy's.\nfuncs = ('erosion', 'dilation', 'opening', 'closing')\nskimage2ndimage = dict((x, 'grey_' + x) for x in funcs)\n\n# These function names are the same in ndimage.\nfuncs = ('binary_erosion', 'binary_dilation', 'binary_opening',\n         'binary_closing', 'black_tophat', 'white_tophat')\nskimage2ndimage.update(dict((x, x) for x in funcs))\n\n\ndef default_fallback(func):\n    \"\"\"Decorator to fall back on ndimage for images with more than 2 dimensions\n\n    Decorator also provides a default structuring element, `selem`, with the\n    appropriate dimensionality if none is specified.\n\n    Parameters\n    ----------\n    func : function\n        A morphology function such as erosion, dilation, opening, closing,\n        white_tophat, or black_tophat.\n\n    Returns\n    -------\n    func_out : function\n        If the image dimentionality is greater than 2D, the ndimage\n        function is returned, otherwise skimage function is used.\n    \"\"\"\n    @functools.wraps(func)\n    def func_out(image, selem=None, out=None, **kwargs):\n        # Default structure element\n        if selem is None:\n            selem = _default_selem(image.ndim)\n\n        # If image has more than 2 dimensions, use scipy.ndimage\n        if image.ndim > 2:\n            function = getattr(nd, skimage2ndimage[func.__name__])\n            try:\n                return function(image, footprint=selem, output=out, **kwargs)\n            except TypeError:\n                # nd.binary_* take structure instead of footprint\n                return function(image, structure=selem, output=out, **kwargs)\n        else:\n            return func(image, selem=selem, out=out, **kwargs)\n\n    return func_out\n\n\ndef remove_small_objects(ar, min_size=64, connectivity=1, in_place=False):\n    \"\"\"Remove connected components smaller than the specified size.\n\n    Parameters\n    ----------\n    ar : ndarray (arbitrary shape, int or bool type)\n        The array containing the connected components of interest. If the array\n        type is int, it is assumed that it contains already-labeled objects.\n        The ints must be non-negative.\n    min_size : int, optional (default: 64)\n        The smallest allowable connected component size.\n    connectivity : int, {1, 2, ..., ar.ndim}, optional (default: 1)\n        The connectivity defining the neighborhood of a pixel.\n    in_place : bool, optional (default: False)\n        If `True`, remove the connected components in the input array itself.\n        Otherwise, make a copy.\n\n    Raises\n    ------\n    TypeError\n        If the input array is of an invalid type, such as float or string.\n    ValueError\n        If the input array contains negative values.\n\n    Returns\n    -------\n    out : ndarray, same shape and type as input `ar`\n        The input array with small connected components removed.\n\n    Examples\n    --------\n    >>> from skimage import morphology\n    >>> a = np.array([[0, 0, 0, 1, 0],\n    ...               [1, 1, 1, 0, 0],\n    ...               [1, 1, 1, 0, 1]], bool)\n    >>> b = morphology.remove_small_objects(a, 6)\n    >>> b\n    array([[False, False, False, False, False],\n           [ True,  True,  True, False, False],\n           [ True,  True,  True, False, False]], dtype=bool)\n    >>> c = morphology.remove_small_objects(a, 7, connectivity=2)\n    >>> c\n    array([[False, False, False,  True, False],\n           [ True,  True,  True, False, False],\n           [ True,  True,  True, False, False]], dtype=bool)\n    >>> d = morphology.remove_small_objects(a, 6, in_place=True)\n    >>> d is a\n    True\n    \"\"\"\n    # Should use `issubdtype` for bool below, but there's a bug in numpy 1.7\n    if not (ar.dtype == bool or np.issubdtype(ar.dtype, np.integer)):\n        raise TypeError(\"Only bool or integer image types are supported. \"\n                        \"Got %s.\" % ar.dtype)\n\n    if in_place:\n        out = ar\n    else:\n        out = ar.copy()\n\n    if min_size == 0:  # shortcut for efficiency\n        return out\n\n    if out.dtype == bool:\n        selem = nd.generate_binary_structure(ar.ndim, connectivity)\n        ccs = np.zeros_like(ar, dtype=np.int32)\n        nd.label(ar, selem, output=ccs)\n    else:\n        ccs = out\n\n    try:\n        component_sizes = np.bincount(ccs.ravel())\n    except ValueError:\n        raise ValueError(\"Negative value labels are not supported. Try \"\n                         \"relabeling the input with `scipy.ndimage.label` or \"\n                         \"`skimage.morphology.label`.\")\n\n    if len(component_sizes) == 2:\n        warnings.warn(\"Only one label was provided to `remove_small_objects`. \"\n                      \"Did you mean to use a boolean array?\")\n\n    too_small = component_sizes < min_size\n    too_small_mask = too_small[ccs]\n    out[too_small_mask] = 0\n\n    return out\n", "path": "skimage/morphology/misc.py"}]}