schmidt-ai opened a new issue, #45531:
URL: https://github.com/apache/arrow/issues/45531

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Goal: create a fixed shape tensor column with `dim_names` from a batch of 
data.
   
   Within `FixedShapeTensorArray.from_numpy_ndarray` 
[here](https://github.com/apache/arrow/blob/main/python/pyarrow/array.pxi#L4537),
 `fixed_shape_tensor` is called. I think `from_numpy_ndarray` should take a 
`dim_names` argument (or `**kwargs`) and pass it to `from_numpy_ndarray`.
   
   Repro:
   
   ```python
   import numpy as np
   import pyarrow as pa
   
   tensor_type = pa.fixed_shape_tensor(value_type=pa.float32(), shape=(5, 6), 
dim_names=("a", "b"))
   schema = pa.schema([("tensor", tensor_type)])
   batch = {"tensor": np.random.rand(10, 5, 6)}
   batch["tensor"] = 
pa.FixedShapeTensorArray.from_numpy_ndarray(batch["tensor"])
   pa.Table.from_pydict(batch, schema=schema)
   ```
   
   Error:
   `pyarrow.lib.ArrowTypeError: Casting from 
'extension<arrow.fixed_shape_tensor[value_type=float, shape=[5,6], 
permutation=[0,1]]>' to different extension type 
'extension<arrow.fixed_shape_tensor[value_type=float, shape=[5,6], 
dim_names=[a,b]]>' not permitted. One can first cast to the storage type, then 
to the extension type.`
   
   > One can first cast to the storage type, then to the extension type.
   It's not clear how exactly to do this. I tried adding `batch["tensor"] = 
batch["tensor"].cast(tensor_type)` to the snippet above but got the same result.
   
   Perhaps I'm missing something?
   
   ### Component(s)
   
   Python


-- 
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: issues-unsubscr...@arrow.apache.org.apache.org

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

Reply via email to