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/07/31 21:07:02 UTC

[GitHub] [incubator-mxnet] szha commented on a change in pull request #18562: [NumPy] allow mixed array types

szha commented on a change in pull request #18562:
URL: https://github.com/apache/incubator-mxnet/pull/18562#discussion_r463842168



##########
File path: tests/python/unittest/test_numpy_ndarray.py
##########
@@ -1401,3 +1401,23 @@ def test_from_numpy_exception():
     np_array = _np.array([[1, 2], [3, 4], [5, 6]], dtype="float32")
     mx_array = mx.npx.from_numpy(np_array, zero_copy=False)
     np_array[2, 1] = 0 # no error
+
+def test_mixed_array_types():
+    np_array = _np.array([[1, 2], [3, 4], [5, 6]], dtype="float32")
+    mx_array = mx.np.ones((3, 1))
+    assert_almost_equal(mx_array + np_array, 1+np_array)
+
+def test_mixed_array_types_share_memory():
+    np_array = _np.array([[1, 2], [3, 4], [5, 6]], dtype="float32")
+    mx_array = mx.npx.from_numpy(np_array)
+    assert _np.may_share_memory(np_array, mx_array)

Review comment:
       Something like this:
   https://github.com/scikit-learn/scikit-learn/blob/36ae6a06d690b992c21280708ca365fce5beec99/sklearn/utils/validation.py#L662-L663




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