()
| 188 | |
| 189 | |
| 190 | def test_same_as_ufunc(): |
| 191 | # Check that the data layout is the same as if a ufunc did the operation. |
| 192 | |
| 193 | data = [ |
| 194 | [[(1,), (3,)], (3,)], |
| 195 | [[(1, 3), (3, 3)], (3, 3)], |
| 196 | [[(3, 1), (3, 3)], (3, 3)], |
| 197 | [[(1, 3), (3, 1)], (3, 3)], |
| 198 | [[(1, 1), (3, 3)], (3, 3)], |
| 199 | [[(1, 1), (1, 3)], (1, 3)], |
| 200 | [[(1, 1), (3, 1)], (3, 1)], |
| 201 | [[(1, 0), (0, 0)], (0, 0)], |
| 202 | [[(0, 1), (0, 0)], (0, 0)], |
| 203 | [[(1, 0), (0, 1)], (0, 0)], |
| 204 | [[(1, 1), (0, 0)], (0, 0)], |
| 205 | [[(1, 1), (1, 0)], (1, 0)], |
| 206 | [[(1, 1), (0, 1)], (0, 1)], |
| 207 | [[(), (3,)], (3,)], |
| 208 | [[(3,), (3, 3)], (3, 3)], |
| 209 | [[(3,), (3, 1)], (3, 3)], |
| 210 | [[(1,), (3, 3)], (3, 3)], |
| 211 | [[(), (3, 3)], (3, 3)], |
| 212 | [[(1, 1), (3,)], (1, 3)], |
| 213 | [[(1,), (3, 1)], (3, 1)], |
| 214 | [[(1,), (1, 3)], (1, 3)], |
| 215 | [[(), (1, 3)], (1, 3)], |
| 216 | [[(), (3, 1)], (3, 1)], |
| 217 | [[(), (0,)], (0,)], |
| 218 | [[(0,), (0, 0)], (0, 0)], |
| 219 | [[(0,), (0, 1)], (0, 0)], |
| 220 | [[(1,), (0, 0)], (0, 0)], |
| 221 | [[(), (0, 0)], (0, 0)], |
| 222 | [[(1, 1), (0,)], (1, 0)], |
| 223 | [[(1,), (0, 1)], (0, 1)], |
| 224 | [[(1,), (1, 0)], (1, 0)], |
| 225 | [[(), (1, 0)], (1, 0)], |
| 226 | [[(), (0, 1)], (0, 1)], |
| 227 | ] |
| 228 | for input_shapes, expected_shape in data: |
| 229 | assert_same_as_ufunc(input_shapes[0], input_shapes[1], |
| 230 | f"Shapes: {input_shapes[0]} {input_shapes[1]}") |
| 231 | # Reverse the input shapes since broadcasting should be symmetric. |
| 232 | assert_same_as_ufunc(input_shapes[1], input_shapes[0]) |
| 233 | # Try them transposed, too. |
| 234 | assert_same_as_ufunc(input_shapes[0], input_shapes[1], True) |
| 235 | # ... and flipped for non-rank-0 inputs in order to test negative |
| 236 | # strides. |
| 237 | if () not in input_shapes: |
| 238 | assert_same_as_ufunc(input_shapes[0], input_shapes[1], False, True) |
| 239 | assert_same_as_ufunc(input_shapes[0], input_shapes[1], True, True) |
| 240 | |
| 241 | |
| 242 | def test_broadcast_to_succeeds(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…