tadeja commented on PR #50203:
URL: https://github.com/apache/arrow/pull/50203#issuecomment-4778555275
Hi all. I'd add two points for further review of current PR changes (thanks
@aboderinsamuel !)
Example of wrong shape and example of permuted tensor currently produce
results but might need to return errors instead:
```python
import numpy as np
import pytest
import pyarrow as pa
np_dtype = np.dtype("int8")
tensor_type = pa.fixed_shape_tensor(pa.from_numpy_dtype(np_dtype), (2, 3))
pa.array([np.arange(6, dtype=np_dtype).reshape(3, 2)], type=tensor_type)
# As (3, 2) has the right number of elements (6), but the wrong shape for a
(2, 3) tensor,
# shouldn't we get an error?
```
Currently returns:
```
<pyarrow.lib.FixedShapeTensorArray object at 0x12524ec20>
[
[
0,
1,
2,
3,
4,
5
]
]
```
```python
np_dtype2 = np.dtype("float32")
elements = [
np.arange(6, dtype=np_dtype2).reshape(2, 3),
np.arange(6, 12, dtype=np_dtype2).reshape(2, 3),
]
permuted_type = pa.fixed_shape_tensor(pa.from_numpy_dtype(np_dtype2), (2, 3),
permutation=[1, 0])
pa.array(elements, type=permuted_type)
# For permuted tensor types built from multi-dim ndarrays, doesn't this
store the wrong layout?
```
Currently returns:
```
<pyarrow.lib.FixedShapeTensorArray object at 0x104597ac0>
[
[
0,
1,
2,
3,
4,
5
],
[
6,
7,
8,
9,
10,
11
]
]
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]