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 2018/03/04 05:34:09 UTC

[GitHub] reminisce commented on a change in pull request #9981: [fix issue#9976] The assignment problem in NDArray

reminisce commented on a change in pull request #9981: [fix issue#9976] The assignment problem in NDArray
URL: https://github.com/apache/incubator-mxnet/pull/9981#discussion_r172037688
 
 

 ##########
 File path: tests/python/unittest/test_ndarray.py
 ##########
 @@ -1099,6 +1099,39 @@ def test_assign_float_value_to_ndarray():
     b[0] = a[0]
     assert same(a, b.asnumpy())
 
+@with_seed()
+def test_ndarray_assignment():
+    H, W = 10, 10
+    a_np = np.random.random((H, W))
+    a_nd = mx.nd.array(a_np)
+    a_nd_id = id(a_nd)
+
+    # assign directly
+    a_np[0] = a_np[1]
+    a_nd[0] = a_nd[1]
+    assert np.allclose(a_np, a_nd.asnumpy())
+    assert id(a_nd) == a_nd_id
 
 Review comment:
   What's the purpose of this check? This seems always true.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services