We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error revealed by numpy 1.9.0r1
```
======================================================================
ERROR: test_join.test_relabel_sequential_offset1
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python27-x64\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "X:\Python27-x64\lib\site-packages\skimage\segmentation\tests\test_join.py", line 30, in test_relabel_sequential_offset1
    ar_relab, fw, inv = relabel_sequential(ar)
  File "X:\Python27-x64\lib\site-packages\skimage\segmentation\_join.py", line 127, in relabel_sequential
    forward_map[labels0] = np.arange(offset, offset + len(labels0) + 1)
ValueError: shape mismatch: value array of shape (6,) could not be broadcast to indexing result of shape (5,)
```

The `+ 1` is incorrect.


--- 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/segmentation/_join.py`
Content:
```
1 import numpy as np
2 from skimage._shared.utils import deprecated
3 
4 
5 def join_segmentations(s1, s2):
6     """Return the join of the two input segmentations.
7 
8     The join J of S1 and S2 is defined as the segmentation in which two
9     voxels are in the same segment if and only if they are in the same
10     segment in *both* S1 and S2.
11 
12     Parameters
13     ----------
14     s1, s2 : numpy arrays
15         s1 and s2 are label fields of the same shape.
16 
17     Returns
18     -------
19     j : numpy array
20         The join segmentation of s1 and s2.
21 
22     Examples
23     --------
24     >>> from skimage.segmentation import join_segmentations
25     >>> s1 = np.array([[0, 0, 1, 1],
26     ...                [0, 2, 1, 1],
27     ...                [2, 2, 2, 1]])
28     >>> s2 = np.array([[0, 1, 1, 0],
29     ...                [0, 1, 1, 0],
30     ...                [0, 1, 1, 1]])
31     >>> join_segmentations(s1, s2)
32     array([[0, 1, 3, 2],
33            [0, 5, 3, 2],
34            [4, 5, 5, 3]])
35     """
36     if s1.shape != s2.shape:
37         raise ValueError("Cannot join segmentations of different shape. " +
38                          "s1.shape: %s, s2.shape: %s" % (s1.shape, s2.shape))
39     s1 = relabel_sequential(s1)[0]
40     s2 = relabel_sequential(s2)[0]
41     j = (s2.max() + 1) * s1 + s2
42     j = relabel_sequential(j)[0]
43     return j
44 
45 
46 @deprecated('relabel_sequential')
47 def relabel_from_one(label_field):
48     """Convert labels in an arbitrary label field to {1, ... number_of_labels}.
49 
50     This function is deprecated, see ``relabel_sequential`` for more.
51     """
52     return relabel_sequential(label_field, offset=1)
53 
54 
55 def relabel_sequential(label_field, offset=1):
56     """Relabel arbitrary labels to {`offset`, ... `offset` + number_of_labels}.
57 
58     This function also returns the forward map (mapping the original labels to
59     the reduced labels) and the inverse map (mapping the reduced labels back
60     to the original ones).
61 
62     Parameters
63     ----------
64     label_field : numpy array of int, arbitrary shape
65         An array of labels.
66     offset : int, optional
67         The return labels will start at `offset`, which should be
68         strictly positive.
69 
70     Returns
71     -------
72     relabeled : numpy array of int, same shape as `label_field`
73         The input label field with labels mapped to
74         {offset, ..., number_of_labels + offset - 1}.
75     forward_map : numpy array of int, shape ``(label_field.max() + 1,)``
76         The map from the original label space to the returned label
77         space. Can be used to re-apply the same mapping. See examples
78         for usage.
79     inverse_map : 1D numpy array of int, of length offset + number of labels
80         The map from the new label space to the original space. This
81         can be used to reconstruct the original label field from the
82         relabeled one.
83 
84     Notes
85     -----
86     The label 0 is assumed to denote the background and is never remapped.
87 
88     The forward map can be extremely big for some inputs, since its
89     length is given by the maximum of the label field. However, in most
90     situations, ``label_field.max()`` is much smaller than
91     ``label_field.size``, and in these cases the forward map is
92     guaranteed to be smaller than either the input or output images.
93 
94     Examples
95     --------
96     >>> from skimage.segmentation import relabel_sequential
97     >>> label_field = np.array([1, 1, 5, 5, 8, 99, 42])
98     >>> relab, fw, inv = relabel_sequential(label_field)
99     >>> relab
100     array([1, 1, 2, 2, 3, 5, 4])
101     >>> fw
102     array([0, 1, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
104            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
106            0, 0, 0, 0, 0, 0, 0, 5])
107     >>> inv
108     array([ 0,  1,  5,  8, 42, 99])
109     >>> (fw[label_field] == relab).all()
110     True
111     >>> (inv[relab] == label_field).all()
112     True
113     >>> relab, fw, inv = relabel_sequential(label_field, offset=5)
114     >>> relab
115     array([5, 5, 6, 6, 7, 9, 8])
116     """
117     m = label_field.max()
118     if not np.issubdtype(label_field.dtype, np.int):
119         new_type = np.min_scalar_type(int(m))
120         label_field = label_field.astype(new_type)
121         m = m.astype(new_type)  # Ensures m is an integer
122     labels = np.unique(label_field)
123     labels0 = labels[labels != 0]
124     if m == len(labels0):  # nothing to do, already 1...n labels
125         return label_field, labels, labels
126     forward_map = np.zeros(m + 1, int)
127     forward_map[labels0] = np.arange(offset, offset + len(labels0) + 1)
128     if not (labels == 0).any():
129         labels = np.concatenate(([0], labels))
130     inverse_map = np.zeros(offset - 1 + len(labels), dtype=np.intp)
131     inverse_map[(offset - 1):] = labels
132     relabeled = forward_map[label_field]
133     return relabeled, forward_map, inverse_map
134
```
--- 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/segmentation/_join.py b/skimage/segmentation/_join.py
--- a/skimage/segmentation/_join.py
+++ b/skimage/segmentation/_join.py
@@ -124,7 +124,7 @@
     if m == len(labels0):  # nothing to do, already 1...n labels
         return label_field, labels, labels
     forward_map = np.zeros(m + 1, int)
-    forward_map[labels0] = np.arange(offset, offset + len(labels0) + 1)
+    forward_map[labels0] = np.arange(offset, offset + len(labels0))
     if not (labels == 0).any():
         labels = np.concatenate(([0], labels))
     inverse_map = np.zeros(offset - 1 + len(labels), dtype=np.intp)

{"golden_diff": "diff --git a/skimage/segmentation/_join.py b/skimage/segmentation/_join.py\n--- a/skimage/segmentation/_join.py\n+++ b/skimage/segmentation/_join.py\n@@ -124,7 +124,7 @@\n     if m == len(labels0):  # nothing to do, already 1...n labels\n         return label_field, labels, labels\n     forward_map = np.zeros(m + 1, int)\n-    forward_map[labels0] = np.arange(offset, offset + len(labels0) + 1)\n+    forward_map[labels0] = np.arange(offset, offset + len(labels0))\n     if not (labels == 0).any():\n         labels = np.concatenate(([0], labels))\n     inverse_map = np.zeros(offset - 1 + len(labels), dtype=np.intp)\n", "issue": "Error revealed by numpy 1.9.0r1\n```\n======================================================================\nERROR: test_join.test_relabel_sequential_offset1\n----------------------------------------------------------------------\nTraceback (most recent call last):\n  File \"X:\\Python27-x64\\lib\\site-packages\\nose\\case.py\", line 197, in runTest\n    self.test(*self.arg)\n  File \"X:\\Python27-x64\\lib\\site-packages\\skimage\\segmentation\\tests\\test_join.py\", line 30, in test_relabel_sequential_offset1\n    ar_relab, fw, inv = relabel_sequential(ar)\n  File \"X:\\Python27-x64\\lib\\site-packages\\skimage\\segmentation\\_join.py\", line 127, in relabel_sequential\n    forward_map[labels0] = np.arange(offset, offset + len(labels0) + 1)\nValueError: shape mismatch: value array of shape (6,) could not be broadcast to indexing result of shape (5,)\n```\n\nThe `+ 1` is incorrect.\n\n", "before_files": [{"content": "import numpy as np\nfrom skimage._shared.utils import deprecated\n\n\ndef join_segmentations(s1, s2):\n    \"\"\"Return the join of the two input segmentations.\n\n    The join J of S1 and S2 is defined as the segmentation in which two\n    voxels are in the same segment if and only if they are in the same\n    segment in *both* S1 and S2.\n\n    Parameters\n    ----------\n    s1, s2 : numpy arrays\n        s1 and s2 are label fields of the same shape.\n\n    Returns\n    -------\n    j : numpy array\n        The join segmentation of s1 and s2.\n\n    Examples\n    --------\n    >>> from skimage.segmentation import join_segmentations\n    >>> s1 = np.array([[0, 0, 1, 1],\n    ...                [0, 2, 1, 1],\n    ...                [2, 2, 2, 1]])\n    >>> s2 = np.array([[0, 1, 1, 0],\n    ...                [0, 1, 1, 0],\n    ...                [0, 1, 1, 1]])\n    >>> join_segmentations(s1, s2)\n    array([[0, 1, 3, 2],\n           [0, 5, 3, 2],\n           [4, 5, 5, 3]])\n    \"\"\"\n    if s1.shape != s2.shape:\n        raise ValueError(\"Cannot join segmentations of different shape. \" +\n                         \"s1.shape: %s, s2.shape: %s\" % (s1.shape, s2.shape))\n    s1 = relabel_sequential(s1)[0]\n    s2 = relabel_sequential(s2)[0]\n    j = (s2.max() + 1) * s1 + s2\n    j = relabel_sequential(j)[0]\n    return j\n\n\n@deprecated('relabel_sequential')\ndef relabel_from_one(label_field):\n    \"\"\"Convert labels in an arbitrary label field to {1, ... number_of_labels}.\n\n    This function is deprecated, see ``relabel_sequential`` for more.\n    \"\"\"\n    return relabel_sequential(label_field, offset=1)\n\n\ndef relabel_sequential(label_field, offset=1):\n    \"\"\"Relabel arbitrary labels to {`offset`, ... `offset` + number_of_labels}.\n\n    This function also returns the forward map (mapping the original labels to\n    the reduced labels) and the inverse map (mapping the reduced labels back\n    to the original ones).\n\n    Parameters\n    ----------\n    label_field : numpy array of int, arbitrary shape\n        An array of labels.\n    offset : int, optional\n        The return labels will start at `offset`, which should be\n        strictly positive.\n\n    Returns\n    -------\n    relabeled : numpy array of int, same shape as `label_field`\n        The input label field with labels mapped to\n        {offset, ..., number_of_labels + offset - 1}.\n    forward_map : numpy array of int, shape ``(label_field.max() + 1,)``\n        The map from the original label space to the returned label\n        space. Can be used to re-apply the same mapping. See examples\n        for usage.\n    inverse_map : 1D numpy array of int, of length offset + number of labels\n        The map from the new label space to the original space. This\n        can be used to reconstruct the original label field from the\n        relabeled one.\n\n    Notes\n    -----\n    The label 0 is assumed to denote the background and is never remapped.\n\n    The forward map can be extremely big for some inputs, since its\n    length is given by the maximum of the label field. However, in most\n    situations, ``label_field.max()`` is much smaller than\n    ``label_field.size``, and in these cases the forward map is\n    guaranteed to be smaller than either the input or output images.\n\n    Examples\n    --------\n    >>> from skimage.segmentation import relabel_sequential\n    >>> label_field = np.array([1, 1, 5, 5, 8, 99, 42])\n    >>> relab, fw, inv = relabel_sequential(label_field)\n    >>> relab\n    array([1, 1, 2, 2, 3, 5, 4])\n    >>> fw\n    array([0, 1, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 5])\n    >>> inv\n    array([ 0,  1,  5,  8, 42, 99])\n    >>> (fw[label_field] == relab).all()\n    True\n    >>> (inv[relab] == label_field).all()\n    True\n    >>> relab, fw, inv = relabel_sequential(label_field, offset=5)\n    >>> relab\n    array([5, 5, 6, 6, 7, 9, 8])\n    \"\"\"\n    m = label_field.max()\n    if not np.issubdtype(label_field.dtype, np.int):\n        new_type = np.min_scalar_type(int(m))\n        label_field = label_field.astype(new_type)\n        m = m.astype(new_type)  # Ensures m is an integer\n    labels = np.unique(label_field)\n    labels0 = labels[labels != 0]\n    if m == len(labels0):  # nothing to do, already 1...n labels\n        return label_field, labels, labels\n    forward_map = np.zeros(m + 1, int)\n    forward_map[labels0] = np.arange(offset, offset + len(labels0) + 1)\n    if not (labels == 0).any():\n        labels = np.concatenate(([0], labels))\n    inverse_map = np.zeros(offset - 1 + len(labels), dtype=np.intp)\n    inverse_map[(offset - 1):] = labels\n    relabeled = forward_map[label_field]\n    return relabeled, forward_map, inverse_map\n", "path": "skimage/segmentation/_join.py"}], "after_files": [{"content": "import numpy as np\nfrom skimage._shared.utils import deprecated\n\n\ndef join_segmentations(s1, s2):\n    \"\"\"Return the join of the two input segmentations.\n\n    The join J of S1 and S2 is defined as the segmentation in which two\n    voxels are in the same segment if and only if they are in the same\n    segment in *both* S1 and S2.\n\n    Parameters\n    ----------\n    s1, s2 : numpy arrays\n        s1 and s2 are label fields of the same shape.\n\n    Returns\n    -------\n    j : numpy array\n        The join segmentation of s1 and s2.\n\n    Examples\n    --------\n    >>> from skimage.segmentation import join_segmentations\n    >>> s1 = np.array([[0, 0, 1, 1],\n    ...                [0, 2, 1, 1],\n    ...                [2, 2, 2, 1]])\n    >>> s2 = np.array([[0, 1, 1, 0],\n    ...                [0, 1, 1, 0],\n    ...                [0, 1, 1, 1]])\n    >>> join_segmentations(s1, s2)\n    array([[0, 1, 3, 2],\n           [0, 5, 3, 2],\n           [4, 5, 5, 3]])\n    \"\"\"\n    if s1.shape != s2.shape:\n        raise ValueError(\"Cannot join segmentations of different shape. \" +\n                         \"s1.shape: %s, s2.shape: %s\" % (s1.shape, s2.shape))\n    s1 = relabel_sequential(s1)[0]\n    s2 = relabel_sequential(s2)[0]\n    j = (s2.max() + 1) * s1 + s2\n    j = relabel_sequential(j)[0]\n    return j\n\n\n@deprecated('relabel_sequential')\ndef relabel_from_one(label_field):\n    \"\"\"Convert labels in an arbitrary label field to {1, ... number_of_labels}.\n\n    This function is deprecated, see ``relabel_sequential`` for more.\n    \"\"\"\n    return relabel_sequential(label_field, offset=1)\n\n\ndef relabel_sequential(label_field, offset=1):\n    \"\"\"Relabel arbitrary labels to {`offset`, ... `offset` + number_of_labels}.\n\n    This function also returns the forward map (mapping the original labels to\n    the reduced labels) and the inverse map (mapping the reduced labels back\n    to the original ones).\n\n    Parameters\n    ----------\n    label_field : numpy array of int, arbitrary shape\n        An array of labels.\n    offset : int, optional\n        The return labels will start at `offset`, which should be\n        strictly positive.\n\n    Returns\n    -------\n    relabeled : numpy array of int, same shape as `label_field`\n        The input label field with labels mapped to\n        {offset, ..., number_of_labels + offset - 1}.\n    forward_map : numpy array of int, shape ``(label_field.max() + 1,)``\n        The map from the original label space to the returned label\n        space. Can be used to re-apply the same mapping. See examples\n        for usage.\n    inverse_map : 1D numpy array of int, of length offset + number of labels\n        The map from the new label space to the original space. This\n        can be used to reconstruct the original label field from the\n        relabeled one.\n\n    Notes\n    -----\n    The label 0 is assumed to denote the background and is never remapped.\n\n    The forward map can be extremely big for some inputs, since its\n    length is given by the maximum of the label field. However, in most\n    situations, ``label_field.max()`` is much smaller than\n    ``label_field.size``, and in these cases the forward map is\n    guaranteed to be smaller than either the input or output images.\n\n    Examples\n    --------\n    >>> from skimage.segmentation import relabel_sequential\n    >>> label_field = np.array([1, 1, 5, 5, 8, 99, 42])\n    >>> relab, fw, inv = relabel_sequential(label_field)\n    >>> relab\n    array([1, 1, 2, 2, 3, 5, 4])\n    >>> fw\n    array([0, 1, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n           0, 0, 0, 0, 0, 0, 0, 5])\n    >>> inv\n    array([ 0,  1,  5,  8, 42, 99])\n    >>> (fw[label_field] == relab).all()\n    True\n    >>> (inv[relab] == label_field).all()\n    True\n    >>> relab, fw, inv = relabel_sequential(label_field, offset=5)\n    >>> relab\n    array([5, 5, 6, 6, 7, 9, 8])\n    \"\"\"\n    m = label_field.max()\n    if not np.issubdtype(label_field.dtype, np.int):\n        new_type = np.min_scalar_type(int(m))\n        label_field = label_field.astype(new_type)\n        m = m.astype(new_type)  # Ensures m is an integer\n    labels = np.unique(label_field)\n    labels0 = labels[labels != 0]\n    if m == len(labels0):  # nothing to do, already 1...n labels\n        return label_field, labels, labels\n    forward_map = np.zeros(m + 1, int)\n    forward_map[labels0] = np.arange(offset, offset + len(labels0))\n    if not (labels == 0).any():\n        labels = np.concatenate(([0], labels))\n    inverse_map = np.zeros(offset - 1 + len(labels), dtype=np.intp)\n    inverse_map[(offset - 1):] = labels\n    relabeled = forward_map[label_field]\n    return relabeled, forward_map, inverse_map\n", "path": "skimage/segmentation/_join.py"}]}