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

Function test_recordbatch_c_array_interface

python/pyarrow/tests/test_table.py:560–578  ·  view source on GitHub ↗
(wrapper_class)

Source from the content-addressed store, hash-verified

558
559@pytest.mark.parametrize("wrapper_class", [BatchWrapper, BatchDeviceWrapper])
560def test_recordbatch_c_array_interface(wrapper_class):
561 data = pa.record_batch([
562 pa.array([1, 2, 3], type=pa.int64())
563 ], names=['a'])
564 wrapper = wrapper_class(data)
565
566 # Can roundtrip through the wrapper.
567 result = pa.record_batch(wrapper)
568 assert result == data
569
570 # Can also import with a schema that implementer can cast to.
571 castable_schema = pa.schema([
572 pa.field('a', pa.int32())
573 ])
574 result = pa.record_batch(wrapper, schema=castable_schema)
575 expected = pa.record_batch([
576 pa.array([1, 2, 3], type=pa.int32())
577 ], names=['a'])
578 assert result == expected
579
580
581def test_recordbatch_c_array_interface_device_unsupported_keyword():

Callers

nothing calls this directly

Calls 3

arrayMethod · 0.45
schemaMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected