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

Function test_eigen_keepalive

tests/test_eigen_matrix.py:416–446  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

414
415@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
416def test_eigen_keepalive():
417 a = m.ReturnTester()
418 cstats = ConstructorStats.get(m.ReturnTester)
419 assert cstats.alive() == 1
420 unsafe = [a.ref(), a.ref_const(), a.block(1, 2, 3, 4)]
421 copies = [
422 a.copy_get(),
423 a.copy_view(),
424 a.copy_ref(),
425 a.copy_ref_const(),
426 a.copy_block(4, 3, 2, 1),
427 ]
428 del a
429 assert cstats.alive() == 0
430 del unsafe
431 del copies
432
433 for meth in [
434 m.ReturnTester.get,
435 m.ReturnTester.get_ptr,
436 m.ReturnTester.view,
437 m.ReturnTester.view_ptr,
438 m.ReturnTester.ref_safe,
439 m.ReturnTester.ref_const_safe,
440 m.ReturnTester.corners,
441 m.ReturnTester.corners_const,
442 ]:
443 assert_keeps_alive(m.ReturnTester, meth)
444
445 for meth in [m.ReturnTester.block_safe, m.ReturnTester.block_const]:
446 assert_keeps_alive(m.ReturnTester, meth, 4, 3, 2, 1)
447
448
449def test_eigen_ref_mutators():

Callers

nothing calls this directly

Calls 6

refMethod · 0.95
blockMethod · 0.95
assert_keeps_aliveFunction · 0.85
ReturnTesterMethod · 0.80
aliveMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected