MCPcopy Create free account
hub / github.com/apache/arrow / test_tensor_numpy_roundtrip

Function test_tensor_numpy_roundtrip

python/pyarrow/tests/test_tensor.py:87–99  ·  view source on GitHub ↗
(dtype_str, arrow_type)

Source from the content-addressed store, hash-verified

85
86@pytest.mark.parametrize('dtype_str,arrow_type', tensor_type_pairs)
87def test_tensor_numpy_roundtrip(dtype_str, arrow_type):
88 dtype = np.dtype(dtype_str)
89 # Casting np.float64 -> uint32 or uint64 throws a RuntimeWarning
90 with warnings.catch_warnings():
91 warnings.simplefilter("ignore")
92 data = (100 * np.random.randn(10, 4)).astype(dtype)
93 tensor = pa.Tensor.from_numpy(data)
94 assert tensor.type == arrow_type
95
96 repr(tensor)
97
98 result = tensor.to_numpy()
99 assert (data == result).all()
100
101
102def test_tensor_ipc_roundtrip(tmpdir):

Callers

nothing calls this directly

Calls 2

dtypeMethod · 0.80
allMethod · 0.80

Tested by

no test coverage detected