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

Function test_fixed_shape_tensor_scalar_dlpack

python/pyarrow/tests/test_dlpack.py:196–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

194@requires_numpy_version("2.1.0")
195@check_bytes_allocated
196def test_fixed_shape_tensor_scalar_dlpack():
197 np_arr = np.arange(12, dtype=np.int32).reshape(3, 2, 2)
198 arr = pa.FixedShapeTensorArray.from_numpy_ndarray(np_arr)
199
200 scalar = arr[1]
201 assert isinstance(scalar, pa.FixedShapeTensorScalar)
202 # __dlpack_device__ reads the storage array's device, without building a Tensor.
203 assert scalar.__dlpack_device__() == (1, 0)
204
205 result = np.from_dlpack(DLPackForwarder(scalar, max_version=(1, 0)))
206 np.testing.assert_array_equal(result, np_arr[1], strict=True)
207
208
209def multidim_arrays_with_nulls():

Callers

nothing calls this directly

Calls 2

DLPackForwarderClass · 0.85
__dlpack_device__Method · 0.45

Tested by

no test coverage detected