MCPcopy Create free account
hub / github.com/numpy/numpy / test_broadcast_shapes_succeeds

Function test_broadcast_shapes_succeeds

numpy/lib/tests/test_stride_tricks.py:296–334  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

294
295
296def test_broadcast_shapes_succeeds():
297 # tests public broadcast_shapes
298 data = [
299 [[], ()],
300 [[()], ()],
301 [[(7,)], (7,)],
302 [[(1, 2), (2,)], (1, 2)],
303 [[(1, 1)], (1, 1)],
304 [[(1, 1), (3, 4)], (3, 4)],
305 [[(6, 7), (5, 6, 1), (7,), (5, 1, 7)], (5, 6, 7)],
306 [[(5, 6, 1)], (5, 6, 1)],
307 [[(1, 3), (3, 1)], (3, 3)],
308 [[(1, 0), (0, 0)], (0, 0)],
309 [[(0, 1), (0, 0)], (0, 0)],
310 [[(1, 0), (0, 1)], (0, 0)],
311 [[(1, 1), (0, 0)], (0, 0)],
312 [[(1, 1), (1, 0)], (1, 0)],
313 [[(1, 1), (0, 1)], (0, 1)],
314 [[(), (0,)], (0,)],
315 [[(0,), (0, 0)], (0, 0)],
316 [[(0,), (0, 1)], (0, 0)],
317 [[(1,), (0, 0)], (0, 0)],
318 [[(), (0, 0)], (0, 0)],
319 [[(1, 1), (0,)], (1, 0)],
320 [[(1,), (0, 1)], (0, 1)],
321 [[(1,), (1, 0)], (1, 0)],
322 [[(), (1, 0)], (1, 0)],
323 [[(), (0, 1)], (0, 1)],
324 [[(1,), (3,)], (3,)],
325 [[2, (3, 2)], (3, 2)],
326 ]
327 for input_shapes, target_shape in data:
328 assert_equal(broadcast_shapes(*input_shapes), target_shape)
329
330 assert_equal(broadcast_shapes(*([(1, 2)] * 32)), (1, 2))
331 assert_equal(broadcast_shapes(*([(1, 2)] * 100)), (1, 2))
332
333 # regression tests for gh-5862
334 assert_equal(broadcast_shapes(*([(2,)] * 32)), (2,))
335
336
337def test_broadcast_shapes_raises():

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
broadcast_shapesFunction · 0.90

Tested by

no test coverage detected