MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_reshape_tuple

Function test_reshape_tuple

tests/test_numpy_array.py:547–559  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

545
546
547def test_reshape_tuple():
548 a = np.arange(3 * 7 * 2) + 1
549 x = m.reshape_tuple(a, (3, 7, 2))
550 assert x.shape == (3, 7, 2)
551 assert list(x[1][4]) == [23, 24]
552 y = m.reshape_tuple(x, (x.size,))
553 assert y.shape == (42,)
554 with pytest.raises(ValueError) as excinfo:
555 m.reshape_tuple(a, (3, 7, 1))
556 assert str(excinfo.value) == "cannot reshape array of size 42 into shape (3,7,1)"
557 with pytest.raises(ValueError) as excinfo:
558 m.reshape_tuple(a, ())
559 assert str(excinfo.value) == "cannot reshape array of size 42 into shape ()"
560
561
562def test_index_using_ellipsis():

Callers

nothing calls this directly

Calls 2

listClass · 0.85
strClass · 0.85

Tested by

no test coverage detected