rok commented on code in PR #37533: URL: https://github.com/apache/arrow/pull/37533#discussion_r1435214317
########## python/pyarrow/array.pxi: ########## @@ -3519,17 +3519,42 @@ class FixedShapeTensorArray(ExtensionArray): def to_numpy_ndarray(self): Review Comment: `to_numpy` ```python import pyarrow as pa arrow_type = pa.int8() tensor_type = pa.fixed_shape_tensor(arrow_type, [2, 3]) storage = pa.array([[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]], pa.list_(arrow_type, 6)) arr = pa.ExtensionArray.from_storage(tensor_type, storage) arr.to_numpy(zero_copy_only=False) ``` already returns storage arrays: ``` array([array([1, 2, 3, 4, 5, 6], dtype=int8), array([ 7, 8, 9, 10, 11, 12], dtype=int8)], dtype=object) ``` We agreed (with @jorisvandenbossche and @AlenkaF ), in a thread I can't find now, to use `to_numpy_ndarray` for getting tensors from `FixedShapeTensorArray` into numpy. I'd use the same convention for `from_numpy_ndarray` to go from `ndarray` into `FixedShapeTensorArray` ########## python/pyarrow/scalar.pxi: ########## @@ -1027,6 +1027,32 @@ cdef class ExtensionScalar(Scalar): return pyarrow_wrap_scalar(<shared_ptr[CScalar]> sp_scalar) +cdef class FixedShapeTensorScalar(ExtensionScalar): + """ + Concrete class for fixed shape tensor extension scalar. + """ + + def to_numpy_ndarray(self): Review Comment: See above. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org