You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alanhdu (via GitHub)" <gi...@apache.org> on 2023/05/18 13:06:38 UTC

[GitHub] [arrow] alanhdu commented on issue #35647: [Python] Convert multidimensional arrays into FixedShapeTensorArrays automatically in `pyarrow.array`

alanhdu commented on issue #35647:
URL: https://github.com/apache/arrow/issues/35647#issuecomment-1553029560

   Sure! I haven't fully groked the codebase, but I think there would be (potentially) two parts:
   
   * I think the easiest thing would be to directly update https://github.com/apache/arrow/blob/3e4eaa917fa9b09a923d255adee520aa68a4e78c/python/pyarrow/array.pxi#L119 to call into `FixedShapeTensorArray.from_numpy_ndarray` when necessary. I think that basically means inserting another branch at https://github.com/apache/arrow/blob/3e4eaa917fa9b09a923d255adee520aa68a4e78c/python/pyarrow/array.pxi#L323 to check if `values.ndim > 1`.
   * I could potentially update https://github.com/apache/arrow/blob/3e4eaa917fa9b09a923d255adee520aa68a4e78c/python/pyarrow/src/arrow/python/numpy_to_arrow.cc#L312 to return an ExtensionArray with the FixedShapeTensor if `ndim > 1`, but it's not clear to me how to go from the CExtensionArray to the Python type without modifying the Cython wrapper (and if we do thta, it's not clear there are advantages to not just doing it all in the Cython wrapper).


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org