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:561–579  ·  view source on GitHub ↗
(wrapper_class)

Source from the content-addressed store, hash-verified

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