We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add unit tests for stride_tricks/broadcast_shape


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `heat/core/stride_tricks.py`
Content:
```
1 import itertools
2 
3 
4 def broadcast_shape(shape_a, shape_b):
5     """
6     Infers, if possible, the broadcast output shape of two operands a and b. Inspired by stackoverflow post:
7     https://stackoverflow.com/questions/24743753/test-if-an-array-is-broadcastable-to-a-shape
8 
9     Parameters
10     ----------
11     shape_a : tuple of ints
12         shape of operand a
13     shape_b : tuple of ints
14         shape of operand b
15 
16     Returns
17     -------
18     broadcast_shape : tuple of ints
19         the broadcast shape
20 
21     Raises
22     -------
23     ValueError
24         If the two shapes cannot be broadcast.
25     """
26     #TODO: test me
27     it = itertools.zip_longest(shape_a[::-1], shape_b[::-1], fillvalue=1)
28     resulting_shape = max(len(shape_a), len(shape_b)) * [None]
29     for i, (a, b) in enumerate(it):
30         if a == 1 or b == 1 or a == b:
31             resulting_shape[i] = max(a, b)
32         else:
33             raise ValueError('operands could not be broadcast, input shapes {} {}'.format(shape_a, shape_b))
34 
35     return tuple(resulting_shape[::-1])
36 
37 
38 def sanitize_axis(shape, axis):
39     """
40     Checks conformity of an axis with respect to a given shape. The axis will be converted to its positive equivalent
41     and is checked to be within bounds
42 
43     Parameters
44     ----------
45     shape : tuple of ints
46         shape of an array
47     axis : ints
48         the axis to be sanitized
49 
50     Returns
51     -------
52     sane_axis : int
53         the sane axis
54 
55     Raises
56     -------
57     ValueError
58         if the axis cannot be sanitized, i.e. out of bounds.
59     TypeError
60         if the the axis is not integral.
61     """
62     #TODO: test me
63     
64     if axis is not None:
65         if isinstance(axis, tuple):
66             raise NotImplementedError('Not implemented for axis: tuple of ints')
67         if not isinstance(axis, int):
68             raise TypeError('axis must be None or int, but was {}'.format(type(axis)))
69 
70     if axis is None or 0 <= axis < len(shape):
71         return axis
72     elif axis < 0:
73         axis += len(shape)
74 
75     if axis < 0 or axis >= len(shape):
76         raise ValueError('axis axis {} is out of bounds for shape {}'.format(axis, shape))
77 
78     return axis
79 
80 
81 def sanitize_shape(shape):
82     """
83     Verifies and normalizes the given shape.
84 
85     Parameters
86     ----------
87     shape : int or sequence of ints
88         Shape of an array.
89 
90     Returns
91     -------
92     sane_shape : tuple of ints
93         The sanitized shape.
94 
95     Raises
96     -------
97     ValueError
98         If the shape contains illegal values, e.g. negative numbers.
99     TypeError
100         If the given shape is neither and int or a sequence of ints.
101 
102     Examples
103     --------
104     >>> sanitize_shape(3)
105     (3,)
106 
107     >>> sanitize_shape([1, 2, 3])
108     (1, 2, 3,)
109 
110     >>> sanitize_shape(1.0)
111     TypeError
112     """
113     shape = (shape,) if not hasattr(shape, '__iter__') else tuple(shape)
114 
115     for dimension in shape:
116         if not isinstance(dimension, int):
117             raise TypeError('expected sequence object with length >= 0 or a single integer')
118         if dimension <= 0:
119             raise ValueError('negative dimensions are not allowed')
120 
121     return shape
122
```
--- 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/heat/core/stride_tricks.py b/heat/core/stride_tricks.py
--- a/heat/core/stride_tricks.py
+++ b/heat/core/stride_tricks.py
@@ -22,8 +22,22 @@
     -------
     ValueError
         If the two shapes cannot be broadcast.
+
+    Examples
+    -------
+    >>> broadcast_shape((5,4),(4,))
+    (5,4)
+
+    >>> broadcast_shape((1,100,1),(10,1,5))
+    (10,100,5)
+
+    >>> broadcast_shape((8,1,6,1),(7,1,5,))
+    (8,7,6,5))
+
+    >>> broadcast_shape((2,1),(8,4,3))
+    ValueError
     """
-    #TODO: test me
+
     it = itertools.zip_longest(shape_a[::-1], shape_b[::-1], fillvalue=1)
     resulting_shape = max(len(shape_a), len(shape_b)) * [None]
     for i, (a, b) in enumerate(it):
@@ -58,9 +72,23 @@
         if the axis cannot be sanitized, i.e. out of bounds.
     TypeError
         if the the axis is not integral.
+
+    Examples
+    -------
+    >>> sanitize_axis((5,4,4),1)
+    1
+
+    >>> sanitize_axis((5,4,4),-1)
+    2
+
+    >>> sanitize_axis((5, 4), (1,))
+    NotImplementedError
+
+    >>> sanitize_axis((5, 4), 1.0)
+    TypeError
+
     """
-    #TODO: test me
-    
+
     if axis is not None:
         if isinstance(axis, tuple):
             raise NotImplementedError('Not implemented for axis: tuple of ints')

{"golden_diff": "diff --git a/heat/core/stride_tricks.py b/heat/core/stride_tricks.py\n--- a/heat/core/stride_tricks.py\n+++ b/heat/core/stride_tricks.py\n@@ -22,8 +22,22 @@\n     -------\n     ValueError\n         If the two shapes cannot be broadcast.\n+\n+    Examples\n+    -------\n+    >>> broadcast_shape((5,4),(4,))\n+    (5,4)\n+\n+    >>> broadcast_shape((1,100,1),(10,1,5))\n+    (10,100,5)\n+\n+    >>> broadcast_shape((8,1,6,1),(7,1,5,))\n+    (8,7,6,5))\n+\n+    >>> broadcast_shape((2,1),(8,4,3))\n+    ValueError\n     \"\"\"\n-    #TODO: test me\n+\n     it = itertools.zip_longest(shape_a[::-1], shape_b[::-1], fillvalue=1)\n     resulting_shape = max(len(shape_a), len(shape_b)) * [None]\n     for i, (a, b) in enumerate(it):\n@@ -58,9 +72,23 @@\n         if the axis cannot be sanitized, i.e. out of bounds.\n     TypeError\n         if the the axis is not integral.\n+\n+    Examples\n+    -------\n+    >>> sanitize_axis((5,4,4),1)\n+    1\n+\n+    >>> sanitize_axis((5,4,4),-1)\n+    2\n+\n+    >>> sanitize_axis((5, 4), (1,))\n+    NotImplementedError\n+\n+    >>> sanitize_axis((5, 4), 1.0)\n+    TypeError\n+\n     \"\"\"\n-    #TODO: test me\n-    \n+\n     if axis is not None:\n         if isinstance(axis, tuple):\n             raise NotImplementedError('Not implemented for axis: tuple of ints')\n", "issue": "Add unit tests for stride_tricks/broadcast_shape\n\n", "before_files": [{"content": "import itertools\n\n\ndef broadcast_shape(shape_a, shape_b):\n    \"\"\"\n    Infers, if possible, the broadcast output shape of two operands a and b. Inspired by stackoverflow post:\n    https://stackoverflow.com/questions/24743753/test-if-an-array-is-broadcastable-to-a-shape\n\n    Parameters\n    ----------\n    shape_a : tuple of ints\n        shape of operand a\n    shape_b : tuple of ints\n        shape of operand b\n\n    Returns\n    -------\n    broadcast_shape : tuple of ints\n        the broadcast shape\n\n    Raises\n    -------\n    ValueError\n        If the two shapes cannot be broadcast.\n    \"\"\"\n    #TODO: test me\n    it = itertools.zip_longest(shape_a[::-1], shape_b[::-1], fillvalue=1)\n    resulting_shape = max(len(shape_a), len(shape_b)) * [None]\n    for i, (a, b) in enumerate(it):\n        if a == 1 or b == 1 or a == b:\n            resulting_shape[i] = max(a, b)\n        else:\n            raise ValueError('operands could not be broadcast, input shapes {} {}'.format(shape_a, shape_b))\n\n    return tuple(resulting_shape[::-1])\n\n\ndef sanitize_axis(shape, axis):\n    \"\"\"\n    Checks conformity of an axis with respect to a given shape. The axis will be converted to its positive equivalent\n    and is checked to be within bounds\n\n    Parameters\n    ----------\n    shape : tuple of ints\n        shape of an array\n    axis : ints\n        the axis to be sanitized\n\n    Returns\n    -------\n    sane_axis : int\n        the sane axis\n\n    Raises\n    -------\n    ValueError\n        if the axis cannot be sanitized, i.e. out of bounds.\n    TypeError\n        if the the axis is not integral.\n    \"\"\"\n    #TODO: test me\n    \n    if axis is not None:\n        if isinstance(axis, tuple):\n            raise NotImplementedError('Not implemented for axis: tuple of ints')\n        if not isinstance(axis, int):\n            raise TypeError('axis must be None or int, but was {}'.format(type(axis)))\n\n    if axis is None or 0 <= axis < len(shape):\n        return axis\n    elif axis < 0:\n        axis += len(shape)\n\n    if axis < 0 or axis >= len(shape):\n        raise ValueError('axis axis {} is out of bounds for shape {}'.format(axis, shape))\n\n    return axis\n\n\ndef sanitize_shape(shape):\n    \"\"\"\n    Verifies and normalizes the given shape.\n\n    Parameters\n    ----------\n    shape : int or sequence of ints\n        Shape of an array.\n\n    Returns\n    -------\n    sane_shape : tuple of ints\n        The sanitized shape.\n\n    Raises\n    -------\n    ValueError\n        If the shape contains illegal values, e.g. negative numbers.\n    TypeError\n        If the given shape is neither and int or a sequence of ints.\n\n    Examples\n    --------\n    >>> sanitize_shape(3)\n    (3,)\n\n    >>> sanitize_shape([1, 2, 3])\n    (1, 2, 3,)\n\n    >>> sanitize_shape(1.0)\n    TypeError\n    \"\"\"\n    shape = (shape,) if not hasattr(shape, '__iter__') else tuple(shape)\n\n    for dimension in shape:\n        if not isinstance(dimension, int):\n            raise TypeError('expected sequence object with length >= 0 or a single integer')\n        if dimension <= 0:\n            raise ValueError('negative dimensions are not allowed')\n\n    return shape\n", "path": "heat/core/stride_tricks.py"}], "after_files": [{"content": "import itertools\n\n\ndef broadcast_shape(shape_a, shape_b):\n    \"\"\"\n    Infers, if possible, the broadcast output shape of two operands a and b. Inspired by stackoverflow post:\n    https://stackoverflow.com/questions/24743753/test-if-an-array-is-broadcastable-to-a-shape\n\n    Parameters\n    ----------\n    shape_a : tuple of ints\n        shape of operand a\n    shape_b : tuple of ints\n        shape of operand b\n\n    Returns\n    -------\n    broadcast_shape : tuple of ints\n        the broadcast shape\n\n    Raises\n    -------\n    ValueError\n        If the two shapes cannot be broadcast.\n\n    Examples\n    -------\n    >>> broadcast_shape((5,4),(4,))\n    (5,4)\n\n    >>> broadcast_shape((1,100,1),(10,1,5))\n    (10,100,5)\n\n    >>> broadcast_shape((8,1,6,1),(7,1,5,))\n    (8,7,6,5))\n\n    >>> broadcast_shape((2,1),(8,4,3))\n    ValueError\n    \"\"\"\n\n    it = itertools.zip_longest(shape_a[::-1], shape_b[::-1], fillvalue=1)\n    resulting_shape = max(len(shape_a), len(shape_b)) * [None]\n    for i, (a, b) in enumerate(it):\n        if a == 1 or b == 1 or a == b:\n            resulting_shape[i] = max(a, b)\n        else:\n            raise ValueError('operands could not be broadcast, input shapes {} {}'.format(shape_a, shape_b))\n\n    return tuple(resulting_shape[::-1])\n\n\ndef sanitize_axis(shape, axis):\n    \"\"\"\n    Checks conformity of an axis with respect to a given shape. The axis will be converted to its positive equivalent\n    and is checked to be within bounds\n\n    Parameters\n    ----------\n    shape : tuple of ints\n        shape of an array\n    axis : ints\n        the axis to be sanitized\n\n    Returns\n    -------\n    sane_axis : int\n        the sane axis\n\n    Raises\n    -------\n    ValueError\n        if the axis cannot be sanitized, i.e. out of bounds.\n    TypeError\n        if the the axis is not integral.\n\n    Examples\n    -------\n    >>> sanitize_axis((5,4,4),1)\n    1\n\n    >>> sanitize_axis((5,4,4),-1)\n    2\n\n    >>> sanitize_axis((5, 4), (1,))\n    NotImplementedError\n\n    >>> sanitize_axis((5, 4), 1.0)\n    TypeError\n\n    \"\"\"\n\n    if axis is not None:\n        if isinstance(axis, tuple):\n            raise NotImplementedError('Not implemented for axis: tuple of ints')\n        if not isinstance(axis, int):\n            raise TypeError('axis must be None or int, but was {}'.format(type(axis)))\n\n    if axis is None or 0 <= axis < len(shape):\n        return axis\n    elif axis < 0:\n        axis += len(shape)\n\n    if axis < 0 or axis >= len(shape):\n        raise ValueError('axis axis {} is out of bounds for shape {}'.format(axis, shape))\n\n    return axis\n\n\ndef sanitize_shape(shape):\n    \"\"\"\n    Verifies and normalizes the given shape.\n\n    Parameters\n    ----------\n    shape : int or sequence of ints\n        Shape of an array.\n\n    Returns\n    -------\n    sane_shape : tuple of ints\n        The sanitized shape.\n\n    Raises\n    -------\n    ValueError\n        If the shape contains illegal values, e.g. negative numbers.\n    TypeError\n        If the given shape is neither and int or a sequence of ints.\n\n    Examples\n    --------\n    >>> sanitize_shape(3)\n    (3,)\n\n    >>> sanitize_shape([1, 2, 3])\n    (1, 2, 3,)\n\n    >>> sanitize_shape(1.0)\n    TypeError\n    \"\"\"\n    shape = (shape,) if not hasattr(shape, '__iter__') else tuple(shape)\n\n    for dimension in shape:\n        if not isinstance(dimension, int):\n            raise TypeError('expected sequence object with length >= 0 or a single integer')\n        if dimension <= 0:\n            raise ValueError('negative dimensions are not allowed')\n\n    return shape\n", "path": "heat/core/stride_tricks.py"}]}