reminisce commented on a change in pull request #15418: [numpy] fix cython
URL: https://github.com/apache/incubator-mxnet/pull/15418#discussion_r299237553
 
 

 ##########
 File path: python/mxnet/cython/ndarray.pyx
 ##########
 @@ -64,21 +64,29 @@ cdef class NDArrayBase:
 
 
 _ndarray_cls = None
+_np_ndarray_cls = None
 
 def _set_ndarray_class(cls):
     global _ndarray_cls
     _ndarray_cls = cls
 
 
-cdef NewArray(NDArrayHandle handle, int stype=-1):
+def _set_np_ndarray_class(cls):
+    global _np_ndarray_cls
+    _np_ndarray_cls = cls
+
+
+cdef NewArray(NDArrayHandle handle, int is_np_op, int stype=-1):
     """Create a new array given handle"""
-    return _ndarray_cls(_ctypes.cast(<unsigned long long>handle, 
_ctypes.c_void_p), stype=stype)
+    if is_np_op:
 
 Review comment:
   These four lines can be simplified into two:
   ```python
   create_array_fn = _np_ndarray_cls if is_np_array else _ndarray_cls
   return create_array_fn(_ctypes.cast(<unsigned long long>handle, 
_ctypes.c_void_p), stype=stype)
   ```

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


With regards,
Apache Git Services

Reply via email to