haojin2 commented on a change in pull request #17452: Fix indexing with zero 
dim array
URL: https://github.com/apache/incubator-mxnet/pull/17452#discussion_r372225674
 
 

 ##########
 File path: python/mxnet/ndarray/ndarray.py
 ##########
 @@ -3055,6 +3060,8 @@ def get_indexing_dispatch_code(key):
                 return _NDARRAY_EMPTY_TUPLE_INDEXING
             if getattr(idx, 'dtype', None) == np.bool_:
                 num_bools += 1
+            if getattr(idx, 'ndim', None) == 0:  # zero-dim array as index 
treated as integer
 
 Review comment:
   Currently we don's support either:
   ```
   >>> from mxnet import np, npx
   >>> npx.set_np()
   >>> a = np.ones((2, 2))
   >>> b = np.array(1.0)
   >>> a[b]
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/home/ubuntu/4-mxnet/python/mxnet/numpy/multiarray.py", line 675, in 
__getitem__
       indexing_dispatch_code = get_indexing_dispatch_code(key)
     File "/home/ubuntu/4-mxnet/python/mxnet/ndarray/ndarray.py", line 3064, in 
get_indexing_dispatch_code
       ''.format(idx, type(idx))
   ValueError: NDArray does not support slicing with key 1.0 of type <class 
'float'>.
   ```
   Do you have some existing use case where the indices could be float types? 
If so we could try to add support for that.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to