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


##########
python/pyarrow/tests/test_extension_type.py:
##########
@@ -1319,38 +1319,65 @@ def test_tensor_type():
 
 
 def test_tensor_class_methods():
+    from numpy.lib.stride_tricks import as_strided
+
+    values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
+    np_arr = np.array(values, dtype=np.int8)

Review Comment:
   Indeed. I parameterized the test so these are no longer static.



##########
python/pyarrow/scalar.pxi:
##########
@@ -1027,6 +1027,32 @@ cdef class ExtensionScalar(Scalar):
         return pyarrow_wrap_scalar(<shared_ptr[CScalar]> sp_scalar)
 
 
+cdef class FixedShapeTensorScalar(ExtensionScalar):
+    """
+    Concrete class for fixed shape tensor extension scalar.
+    """
+
+    def to_numpy_ndarray(self):
+        """
+        Convert fixed shape tensor extension scalar to a numpy.ndarray with 
zero copy.
+        """
+        return self.to_tensor().to_numpy()
+
+    def to_tensor(self):
+        """
+        Convert fixed shape tensor extension scalar to a pyarrow.Tensor.

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