You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Support converting list of multi-dimensional arrays to FixedShapeTensor #49644
When you want to construct a fixed shape tensor array, not from a single contiguous ndarray, but from a list of the individual array elements, this "accidentally" works for 1d arrays (because we support that for ListArray):
AFAIK, the only way to currently do this conversion, is to convert the list of arrays to a single ndarray yourself, and then use pa.FixedShapeTensorArray.from_numpy_ndarray.
And probably worth a separate issue, but also for the conversion the other way around to python, it would be nice to preserve the shape of the ndarrays:
>>>arr=pa.FixedShapeTensorArray.from_numpy_ndarray(np.stack([np.array([[1,2,3], [3,4,5]]), np.array([[2,3,4], [5,6,7]])], axis=1))
# results in an array of 1D arrays>>>arr.to_numpy(zero_copy_only=False)
array([array([1, 2, 3, 2, 3, 4]), array([3, 4, 5, 5, 6, 7])], dtype=object)
# the scalars do have a method to convert to the correct shape>>> [v.to_numpy() forvinarr]
[array([[1, 2, 3],
[2, 3, 4]]),
array([[3, 4, 5],
[5, 6, 7]])]
Activity
jorisvandenbossche commentedon Apr 2, 2026
And probably worth a separate issue, but also for the conversion the other way around to python, it would be nice to preserve the shape of the ndarrays:
rok commentedon Apr 7, 2026
Agreed on both. Let's try to get this into the next release.
apacheGH-49644: [Python] Make fixed_size_list test deterministic and …
apacheGH-49644: [Python] Support converting list of multi-dimensional…
apacheGH-49644: [Python] Make fixed_size_list test deterministic and …
apacheGH-49644: [Python] Only flatten ndim>=2 ndarrays for fixed-size…
apacheGH-49644: [Python] Fix clang-format in AppendNdarray
apacheGH-49644: [Python] Validate tensor shape, reject permuted tenso…
apacheGH-49644: [Python] Trim comments per review
apacheGH-49644: [Python] Keep generic error message for 0-dimensional…
apacheGH-49644: [Python] Validate all sequence inputs, not just list/…
apacheGH-49644: [Python] Address review: allow 0-D arrays, name type …
apacheGH-49644: [Python] Trim test comments per review
apacheGH-49644: [Python] Add a docstring example for building from a …
rok commentedon Jun 29, 2026
@aboderinsamuel please write "take" in a comment below.
aboderinsamuel commentedon Jun 29, 2026
take
GH-49644: [Python] Support converting list of multi-dimensional array…
rok commentedon Jun 29, 2026
Issue resolved by pull request 50203
#50203