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


##########
python/pyarrow/array.pxi:
##########
@@ -3573,17 +3595,20 @@ class FixedShapeTensorArray(ExtensionArray):
           ]
         ]
         """
-        if not obj.flags["C_CONTIGUOUS"]:
-            raise ValueError('The data in the numpy array need to be in a 
single, '
-                             'C-style contiguous segment.')
+
+        permutation = (-np.array(obj.strides)).argsort()
+        if not permutation[0] == 0:
+            raise ValueError('First stride needs to be largest to ensure that '
+                             'individual tensor data is contiguous in memory.')
 
         arrow_type = from_numpy_dtype(obj.dtype)
-        shape = obj.shape[1:]
-        size = obj.size / obj.shape[0]
+        shape = np.take(obj.shape, permutation)
+        values = np.lib.stride_tricks.as_strided(
+            obj, shape=(obj.size,), strides=(obj.dtype.itemsize,))

Review Comment:
   I've not seen zero-copy specifically promised for `order="K"`, but it seem 
it's meant for that. Changed to `ravel`.



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

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

Reply via email to