raulcd commented on code in PR #46170:
URL: https://github.com/apache/arrow/pull/46170#discussion_r2048956956


##########
python/pyarrow/array.pxi:
##########
@@ -4655,6 +4657,17 @@ cdef class FixedShapeTensorArray(ExtensionArray):
                 "Cannot convert 1D array or scalar to fixed shape tensor 
array")
         if np.prod(obj.shape) == 0:
             raise ValueError("Expected a non-empty ndarray")
+        if dim_names is not None:
+            if not hasattr(dim_names, '__iter__'):

Review Comment:
   This will allow us to pass a generator but `len(din_names)` would fail with:
   ```
   >>> g = (x for x in range(2))
   >>> hasattr(g, '__iter__')
   True
   >>> len(g)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: object of type 'generator' has no len()
   ```
   Should we check for `collections.abc.Sequence` as we do in other places like:
   
https://github.com/apache/arrow/blob/0ae5c860004293d0b81bbc31198931aeae9bc277/python/pyarrow/feather.py#L259-L261



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