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

Function test_tensor_to_np

python/pyarrow/tests/test_without_numpy.py:48–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46
47
48def test_tensor_to_np():
49 tensor_type = pa.fixed_shape_tensor(pa.int32(), [2, 2])
50 arr = [[1, 2, 3, 4], [10, 20, 30, 40], [100, 200, 300, 400]]
51 storage = pa.array(arr, pa.list_(pa.int32(), 4))
52 tensor_array = pa.ExtensionArray.from_storage(tensor_type, storage)
53
54 tensor = tensor_array.to_tensor()
55 msg = "Cannot return a numpy.ndarray if NumPy is not present"
56
57 with pytest.raises(ImportError, match=msg):
58 tensor.to_numpy()

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected