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

Function check_strides

tests/test_buffers.py:346–353  ·  view source on GitHub ↗
(mat)

Source from the content-addressed store, hash-verified

344@pytest.mark.parametrize("type", ["pybind11", "numpy"])
345def test_to_pybuffer_contiguity(type):
346 def check_strides(mat):
347 # The full block is memset to 0, so fill it with non-zero in real spots.
348 expected = np.arange(1, 5 * 4 + 1).reshape((5, 4))
349 for i in range(5):
350 for j in range(4):
351 mat[i, j] = expected[i, j]
352 # If all strides are correct, the exposed buffer should match the input.
353 np.testing.assert_array_equal(np.array(mat), expected)
354
355 if type == "pybind11":
356 cmat = m.Matrix(5, 4) # C contiguous.

Callers 1

Calls 2

reshapeMethod · 0.80
arrayMethod · 0.80

Tested by

no test coverage detected