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

Function test_nonunit_stride_to_python

tests/test_eigen_matrix.py:230–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

228
229
230def test_nonunit_stride_to_python():
231 assert np.all(m.diagonal(ref) == ref.diagonal())
232 assert np.all(m.diagonal_1(ref) == ref.diagonal(1))
233 for i in range(-5, 7):
234 assert np.all(m.diagonal_n(ref, i) == ref.diagonal(i)), f"m.diagonal_n({i})"
235
236 # Must be order="F", otherwise the type_caster will make a copy and
237 # m.block() will return a dangling reference (heap-use-after-free).
238 rof = np.asarray(ref, order="F")
239 assert np.all(m.block(rof, 2, 1, 3, 3) == rof[2:5, 1:4])
240 assert np.all(m.block(rof, 1, 4, 4, 2) == rof[1:, 4:])
241 assert np.all(m.block(rof, 1, 4, 3, 2) == rof[1:4, 4:])
242
243
244def test_eigen_ref_to_python():

Callers

nothing calls this directly

Calls 1

blockMethod · 0.80

Tested by

no test coverage detected