MCPcopy
hub / github.com/ray-project/ray / test_numpy_roundtrip

Function test_numpy_roundtrip

python/ray/data/tests/datasource/test_numpy.py:82–92  ·  view source on GitHub ↗
(ray_start_regular_shared, tmp_path)

Source from the content-addressed store, hash-verified

80
81
82def test_numpy_roundtrip(ray_start_regular_shared, tmp_path):
83 tensor_type = DataContext.get_current().arrow_fixed_shape_tensor_format.to_type()
84
85 ds = ray.data.range_tensor(10, override_num_blocks=2)
86 ds.write_numpy(tmp_path, column="data")
87 ds = ray.data.read_numpy(tmp_path)
88 assert ds.count() == 10
89 assert ds.schema() == Schema(pa.schema([("data", tensor_type((1,), pa.int64()))]))
90 assert sorted(ds.take_all(), key=lambda row: row["data"]) == [
91 {"data": np.array([i])} for i in range(10)
92 ]
93
94
95def test_numpy_read_x(ray_start_regular_shared, tmp_path):

Callers

nothing calls this directly

Calls 8

SchemaClass · 0.90
to_typeMethod · 0.80
write_numpyMethod · 0.80
take_allMethod · 0.80
rangeFunction · 0.50
get_currentMethod · 0.45
countMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…