def test_nonunit_stride_to_python(): from pybind11_tests import diagonal, diagonal_1, diagonal_n, block assert np.all(diagonal(ref) == ref.diagonal()) assert np.all(diagonal_1(ref) == ref.diagonal(1)) for i in range(-5, 7): assert np.all(diagonal_n(ref, i) == ref.diagonal(i)), "diagonal_n({})".format(i) assert np.all(block(ref, 2, 1, 3, 3) == ref[2:5, 1:4]) assert np.all(block(ref, 1, 4, 4, 2) == ref[1:, 4:]) assert np.all(block(ref, 1, 4, 3, 2) == ref[1:4, 4:])
def test_nonunit_stride_to_python(): from pybind11_tests import diagonal, diagonal_1, diagonal_n, block if not np.all(diagonal(ref) == ref.diagonal()): raise AssertionError if not np.all(diagonal_1(ref) == ref.diagonal(1)): raise AssertionError for i in range(-5, 7): if not np.all(diagonal_n(ref, i) == ref.diagonal(i)): raise AssertionError("diagonal_n({})".format(i)) if not np.all(block(ref, 2, 1, 3, 3) == ref[2:5, 1:4]): raise AssertionError if not np.all(block(ref, 1, 4, 4, 2) == ref[1:, 4:]): raise AssertionError if not np.all(block(ref, 1, 4, 3, 2) == ref[1:4, 4:]): raise AssertionError