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

Function test_csv_cast_image

tests/packaged_modules/test_csv.py:119–129  ·  view source on GitHub ↗
(csv_file_with_image)

Source from the content-addressed store, hash-verified

117
118@require_pil
119def test_csv_cast_image(csv_file_with_image):
120 with open(csv_file_with_image, encoding="utf-8") as f:
121 image_file = f.read().splitlines()[1]
122 csv = Csv(encoding="utf-8", features=Features({"image": Image()}))
123 base_files = [csv_file_with_image]
124 files_iterables = [[file] for file in base_files]
125 generator = csv._generate_tables(base_files=base_files, files_iterables=files_iterables)
126 pa_table = pa.concat_tables([table for _, table in generator])
127 assert pa_table.schema.field("image").type == Image()()
128 generated_content = pa_table.to_pydict()["image"]
129 assert generated_content == [{"path": image_file, "bytes": None}]
130
131
132def test_csv_cast_label(csv_file_with_label):

Callers

nothing calls this directly

Calls 7

_generate_tablesMethod · 0.95
CsvClass · 0.90
FeaturesClass · 0.90
ImageClass · 0.90
fieldMethod · 0.80
to_pydictMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected