AlenkaF commented on code in PR #37533:
URL: https://github.com/apache/arrow/pull/37533#discussion_r1329679767
##########
python/pyarrow/array.pxi:
##########
@@ -3325,6 +3325,26 @@ cdef class ExtensionArray(Array):
return result
+class FixedShapeTensorScalarType(ExtensionScalar):
+ """
+ Concrete class for fixed shape tensor extension scalar type.
+ """
+
+ def to_numpy_ndarray(self):
+ """
+ Convert fixed shape tensor extension scalar to a numpy array (with
dim).
+
+ Note: ``permutation`` should be trivial (``None`` or ``[0, 1, ...,
len(shape)-1]``).
+ """
+ if self.type.permutation is None or self.type.permutation ==
list(range(len(self.type.shape))):
+ np_flat = np.asarray(self.value.values.to_numpy())
Review Comment:
```suggestion
np_flat = self.value.values.to_numpy()
```
##########
python/pyarrow/types.pxi:
##########
@@ -1629,6 +1629,9 @@ cdef class FixedShapeTensorType(BaseExtensionType):
return fixed_shape_tensor, (self.value_type, self.shape,
self.dim_names, self.permutation)
+ def __arrow_ext_scalar_class__(self):
+ return FixedShapeTensorScalarType
Review Comment:
```suggestion
return FixedShapeTensorScalar
```
##########
python/pyarrow/array.pxi:
##########
@@ -3325,6 +3325,26 @@ cdef class ExtensionArray(Array):
return result
+class FixedShapeTensorScalarType(ExtensionScalar):
+ """
+ Concrete class for fixed shape tensor extension scalar type.
+ """
Review Comment:
```suggestion
class FixedShapeTensorScalar(ExtensionScalar):
"""
Concrete class for fixed shape tensor extension scalar.
"""
```
As this is a subclass of `ExtensionScalar` I would call this
`FixedShapeTensorScalar`.
Also, would this class fit better in `pyarrow/scalar.pxi`?
--
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]