) @pickle_test_parametrize def test_array_pickle(data, typ): # Allocate here so that we don't have any Arrow data allocated. # This is needed to ensure that allocator tests can be reliable. array = pa.array(data, type=typ) for proto in range(0, pickle.HIGHEST_PROTOCOL + 1): result = pickle.loads(pickle.dumps(array, proto)) assert array.equals(result) @h.given( past.arrays( past.all_types, size=st.integers(min_value=0, max_value=10) ) ) def test_pickling(arr): data = pickle.dumps(arr) restored = pickle.loads(data) assert arr.equals(restored) @pickle_test_parametrize def test_array_pickle5(data, typ): # Test zero-copy pickling with protocol 5 (PEP 574) picklemod = pickle5 or pickle if pickle5 is None and picklemod.HIGHEST_PROTOCOL < 5: pytest.skip("need pickle5 package or Python 3.8+")
], pa.struct([pa.field('a', pa.int64()), pa.field('b', pa.string())]))]) @pickle_test_parametrize def test_array_pickle(data, typ): # Allocate here so that we don't have any Arrow data allocated. # This is needed to ensure that allocator tests can be reliable. array = pa.array(data, type=typ) for proto in range(0, pickle.HIGHEST_PROTOCOL + 1): result = pickle.loads(pickle.dumps(array, proto)) assert array.equals(result) @h.given( past.arrays(past.all_types, size=st.integers(min_value=0, max_value=10))) def test_pickling(arr): data = pickle.dumps(arr) restored = pickle.loads(data) assert arr.equals(restored) @pickle_test_parametrize def test_array_pickle5(data, typ): # Test zero-copy pickling with protocol 5 (PEP 574) picklemod = pickle5 or pickle if pickle5 is None and picklemod.HIGHEST_PROTOCOL < 5: pytest.skip("need pickle5 package or Python 3.8+") array = pa.array(data, type=typ) addresses = [
@h.given(past.all_fields) def test_fields(field): assert isinstance(field, pa.lib.Field) @h.given(past.all_schemas) def test_schemas(schema): assert isinstance(schema, pa.lib.Schema) @h.given(past.all_arrays) def test_arrays(array): assert isinstance(array, pa.lib.Array) @h.given(past.arrays(past.primitive_types, nullable=False)) def test_array_nullability(array): assert array.null_count == 0 @h.given(past.all_chunked_arrays) def test_chunked_arrays(chunked_array): assert isinstance(chunked_array, pa.lib.ChunkedArray) @h.given(past.all_record_batches) def test_record_batches(record_bath): assert isinstance(record_bath, pa.lib.RecordBatch) @h.given(past.all_tables)