rok commented on code in PR #38008:
URL: https://github.com/apache/arrow/pull/38008#discussion_r1410029133


##########
python/pyarrow/scalar.pxi:
##########
@@ -1027,6 +1027,31 @@ cdef class ExtensionScalar(Scalar):
         return pyarrow_wrap_scalar(<shared_ptr[CScalar]> sp_scalar)
 
 
+cdef class VariableShapeTensorScalar(ExtensionScalar):
+    """
+    Concrete class for variable shape tensor extension scalar.
+    """
+
+    def to_numpy_ndarray(self):
+        """
+        Convert variable shape tensor extension scalar to a numpy array.
+        """
+        return self.to_tensor().to_numpy()
+
+    def to_tensor(self):
+        """
+        Convert variable shape tensor extension scalar to a pyarrow.Tensor.
+        """
+        cdef:
+            CVariableShapeTensorType* c_type = 
static_pointer_cast[CVariableShapeTensorType, CDataType](
+                self.wrapped.get().type).get()
+            shared_ptr[CExtensionScalar] scalar = 
static_pointer_cast[CExtensionScalar, CScalar](self.wrapped)
+            shared_ptr[CTensor] ctensor
+
+        ctensor = GetResultValue(c_type.GetTensor(scalar))

Review Comment:
   Done.



-- 
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]

Reply via email to