You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/11/09 20:54:29 UTC

[GitHub] [incubator-mxnet] barry-jin commented on a change in pull request #19457: [Numpy] Update fallback.py

barry-jin commented on a change in pull request #19457:
URL: https://github.com/apache/incubator-mxnet/pull/19457#discussion_r520113628



##########
File path: python/mxnet/numpy/multiarray.py
##########
@@ -11382,7 +11382,12 @@ def atleast_1d(*arys):
     >>> np.atleast_1d(np.array(1), np.array([3, 4]))
     [array([1.]), array([3., 4.])]
     """
-    return _mx_nd_np.atleast_1d(*arys)
+    res = []
+    for ary in arys:
+        ary, _ = _as_onp_array(ary)
+        ary = _np.asanyarray(ary)
+        res.append(_as_mx_np_array(ary))

Review comment:
       Previously, atleast_nd can't deal with float/int input and also list/tuple of arrays. These changes are made for converting a list/tuple of arrays into MXNet numpy array, so that the test cast in [test_numpy_interoperability.py](https://github.com/apache/incubator-mxnet/blob/564c6d307e3439c1e5bb9bbd7e82d6744bea6a83/tests/python/unittest/test_numpy_interoperability.py#L1137) can get the expected output. 
   ```
   >>> from mxnet import np
   >>> a_2 = np.array([[1, 2], [1, 2]])
   >>> b_2 = np.array([[2, 3], [2, 3]])
   >>> a_3 = [a_2, a_2]
   >>> b_3 = [b_2, b_2]
   >>> np.atleast_1d(a_3, b_3)
   [array([[[1., 2.],
           [1., 2.]],
   
          [[1., 2.],
           [1., 2.]]]), array([[[2., 3.],
           [2., 3.]],
   
          [[2., 3.],
           [2., 3.]]])]
   ```




----------------------------------------------------------------
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:
users@infra.apache.org