MCPcopy Create free account
hub / github.com/apache/arrow / test_roundtrip_schema_capsule

Function test_roundtrip_schema_capsule

python/pyarrow/tests/test_cffi.py:545–561  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

543 pa.schema({'foo': pa.int32()})],
544 ids=['type', 'field', 'schema'])
545def test_roundtrip_schema_capsule(obj):
546 gc.collect() # Make sure no Arrow data dangles in a ref cycle
547 old_allocated = pa.total_allocated_bytes()
548
549 capsule = obj.__arrow_c_schema__()
550 assert PyCapsule_IsValid(capsule, b"arrow_schema") == 1
551 assert pa.total_allocated_bytes() > old_allocated
552 obj_out = type(obj)._import_from_c_capsule(capsule)
553 assert obj_out == obj
554
555 assert pa.total_allocated_bytes() == old_allocated
556
557 capsule = obj.__arrow_c_schema__()
558
559 assert pa.total_allocated_bytes() > old_allocated
560 del capsule
561 assert pa.total_allocated_bytes() == old_allocated
562
563
564@pytest.mark.parametrize('arr,schema_accessor,bad_type,good_type', [

Callers

nothing calls this directly

Calls 3

PyCapsule_IsValidFunction · 0.70
typeEnum · 0.50
__arrow_c_schema__Method · 0.45

Tested by

no test coverage detected