haojin2 commented on a change in pull request #15282: Numpy compatible eye
URL: https://github.com/apache/incubator-mxnet/pull/15282#discussion_r296125987
 
 

 ##########
 File path: python/mxnet/ndarray/numpy/_op.py
 ##########
 @@ -690,3 +690,34 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
         return (_npi.linspace(start=start, stop=stop, num=num, 
endpoint=endpoint, ctx=ctx, dtype=dtype), step)
     else:
         return _npi.linspace(start=start, stop=stop, num=num, 
endpoint=endpoint, ctx=ctx, dtype=dtype)
+
+
+@set_module('mxnet.ndarray.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+    """
+    Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+    Parameters
+    ----------
+    N : int
+        Number of rows in the output.
+    M : int, optional
+        Number of columns in the output. If None, defaults to N.
+    k : int, optional
+        Index of the diagonal: 0 (the default) refers to the main diagonal,
+        a positive value refers to an upper diagonal,
+        and a negative value to a lower diagonal.
+    dtype : data-type, optional
+        Data-type of the returned array.
+
+    Returns
+    -------
+    I : ndarray of shape (N,M)
+        An array where all elements are equal to zero,
+        except for the k-th diagonal, whose values are equal to one.
+    """
 
 Review comment:
   nit: one more blank line below.

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