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

Function test_cast_array_xd_to_features_sequence

tests/test_table.py:1337–1348  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1335
1336
1337def test_cast_array_xd_to_features_sequence():
1338 arr = np.random.randint(0, 10, size=(8, 2, 3)).tolist()
1339 arr = Array2DExtensionType(shape=(2, 3), dtype="int64").wrap_array(pa.array(arr, pa.list_(pa.list_(pa.int64()))))
1340 arr = pa.ListArray.from_arrays([0, None, 4, 8], arr)
1341 # Variable size list
1342 casted_array = cast_array_to_feature(arr, List(Array2D(shape=(2, 3), dtype="int32")))
1343 assert casted_array.type == get_nested_type(List(Array2D(shape=(2, 3), dtype="int32")))
1344 assert casted_array.to_pylist() == arr.to_pylist()
1345 # Fixed size list
1346 casted_array = cast_array_to_feature(arr, List(Array2D(shape=(2, 3), dtype="int32"), length=4))
1347 assert casted_array.type == get_nested_type(List(Array2D(shape=(2, 3), dtype="int32"), length=4))
1348 assert casted_array.to_pylist() == arr.to_pylist()
1349
1350
1351def test_embed_array_storage(image_file):

Callers

nothing calls this directly

Calls 7

cast_array_to_featureFunction · 0.90
ListClass · 0.90
Array2DClass · 0.90
get_nested_typeFunction · 0.90
from_arraysMethod · 0.80
to_pylistMethod · 0.45

Tested by

no test coverage detected