(type)
| 324 | |
| 325 | @pytest.mark.parametrize("type", ["pybind11", "numpy"]) |
| 326 | def test_discontiguous_to_pybuffer(type): |
| 327 | if type == "pybind11": |
| 328 | mat = m.DiscontiguousMatrix(5, 4, 2, 3) |
| 329 | elif type == "numpy": |
| 330 | mat = np.empty((5 * 2, 4 * 3), dtype=np.float32)[::2, ::3] |
| 331 | else: |
| 332 | raise ValueError(f"Unknown parametrization {type}") |
| 333 | |
| 334 | info = m.get_py_buffer(mat, m.PyBUF_STRIDES) |
| 335 | assert info.itemsize == ctypes.sizeof(ctypes.c_float) |
| 336 | assert info.len == 5 * 4 * info.itemsize |
| 337 | assert info.ndim == 2 |
| 338 | assert info.shape == [5, 4] |
| 339 | assert info.strides == [2 * 4 * 3 * info.itemsize, 3 * info.itemsize] |
| 340 | assert info.suboffsets is None |
| 341 | assert not info.readonly |
| 342 | |
| 343 | |
| 344 | @pytest.mark.parametrize("type", ["pybind11", "numpy"]) |
nothing calls this directly
no test coverage detected