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

Method test_map_nested

tests/test_arrow_dataset.py:1399–1405  ·  view source on GitHub ↗
(self, in_memory)

Source from the content-addressed store, hash-verified

1397 assert_arrow_metadata_are_synced_with_dataset_features(dset_test_modifying_inputs_inplace)
1398
1399 def test_map_nested(self, in_memory):
1400 with tempfile.TemporaryDirectory() as tmp_dir:
1401 with Dataset.from_dict({"field": ["a", "b"]}) as dset:
1402 with self._to(in_memory, tmp_dir, dset) as dset:
1403 with dset.map(lambda example: {"otherfield": {"capital": example["field"].capitalize()}}) as dset:
1404 with dset.map(lambda example: {"otherfield": {"append_x": example["field"] + "x"}}) as dset:
1405 self.assertEqual(dset[0], {"field": "a", "otherfield": {"append_x": "ax"}})
1406
1407 def test_map_return_example_as_dict_value(self, in_memory):
1408 with tempfile.TemporaryDirectory() as tmp_dir:

Callers

nothing calls this directly

Calls 3

_toMethod · 0.95
from_dictMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected