def test_bounds_check(arr): from pybind11_tests.array import index_at, index_at_t, data, data_t, mutate_data, mutate_data_t, at_t, mutate_at_t funcs = (index_at, index_at_t, data, data_t, mutate_data, mutate_data_t, at_t, mutate_at_t) for func in funcs: with pytest.raises(IndexError) as excinfo: index_at(arr, 2, 0) assert str(excinfo.value) == "index 2 is out of bounds for axis 0 with size 2" with pytest.raises(IndexError) as excinfo: index_at(arr, 0, 4) assert str(excinfo.value) == "index 4 is out of bounds for axis 1 with size 3"
def test_bounds_check(arr): from pybind11_tests.array import (index_at, index_at_t, data, data_t, mutate_data, mutate_data_t, at_t, mutate_at_t) funcs = (index_at, index_at_t, data, data_t, mutate_data, mutate_data_t, at_t, mutate_at_t) for func in funcs: with pytest.raises(IndexError) as excinfo: index_at(arr, 2, 0) assert str(excinfo.value) == 'index 2 is out of bounds for axis 0 with size 2' with pytest.raises(IndexError) as excinfo: index_at(arr, 0, 4) assert str(excinfo.value) == 'index 4 is out of bounds for axis 1 with size 3'
def test_index_offset(arr, args, ret): from pybind11_tests.array import index_at, index_at_t, offset_at, offset_at_t assert index_at(arr, *args) == ret assert index_at_t(arr, *args) == ret assert offset_at(arr, *args) == ret * arr.dtype.itemsize assert offset_at_t(arr, *args) == ret * arr.dtype.itemsize
def test_index_offset(arr, args, ret): from pybind11_tests.array import index_at, index_at_t, offset_at, offset_at_t if index_at(arr, *args) != ret: raise AssertionError if index_at_t(arr, *args) != ret: raise AssertionError if offset_at(arr, *args) != ret * arr.dtype.itemsize: raise AssertionError if offset_at_t(arr, *args) != ret * arr.dtype.itemsize: raise AssertionError