MCPcopy
hub / github.com/huggingface/datasets / test_write_file

Function test_write_file

tests/test_arrow_writer.py:206–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

204
205
206def test_write_file():
207 with tempfile.TemporaryDirectory() as tmp_dir:
208 fields = {"col_1": pa.string(), "col_2": pa.int64()}
209 output = os.path.join(tmp_dir, "test.arrow")
210 with ArrowWriter(path=output, schema=pa.schema(fields)) as writer:
211 writer.write_batch({"col_1": ["foo", "bar"], "col_2": [1, 2]})
212 num_examples, num_bytes = writer.finalize()
213 assert num_examples == 2
214 assert num_bytes > 0
215 assert writer._schema == pa.schema(fields, metadata=writer._schema.metadata)
216 _check_output(output, 1)
217
218
219def get_base_dtype(arr_type):

Callers

nothing calls this directly

Calls 5

ArrowWriterClass · 0.90
_check_outputFunction · 0.85
write_batchMethod · 0.80
finalizeMethod · 0.80
schemaMethod · 0.45

Tested by

no test coverage detected