summaryrefslogtreecommitdiff
path: root/numpy/lib/twodim_base.py
diff options
context:
space:
mode:
authorDanny Hermes <daniel.j.hermes@gmail.com>2017-11-12 11:17:12 -0800
committerEric Wieser <wieser.eric@gmail.com>2017-11-12 11:17:12 -0800
commita4e47e0205b78eb96248e71918c2558e25a9d3c7 (patch)
tree85f60a4994556e0eaf8e2fd0d4d72e2cf66ea5b7 /numpy/lib/twodim_base.py
parentd87c4197c358a898372c178f6c24f00d54eff745 (diff)
downloadnumpy-a4e47e0205b78eb96248e71918c2558e25a9d3c7.tar.gz
ENH: Add `order=` keyword to `np.eye()` (#9996)
Fixes #9995
Diffstat (limited to 'numpy/lib/twodim_base.py')
-rw-r--r--numpy/lib/twodim_base.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py
index a6259219a..402c18850 100644
--- a/numpy/lib/twodim_base.py
+++ b/numpy/lib/twodim_base.py
@@ -137,7 +137,7 @@ def flipud(m):
return m[::-1, ...]
-def eye(N, M=None, k=0, dtype=float):
+def eye(N, M=None, k=0, dtype=float, order='C'):
"""
Return a 2-D array with ones on the diagonal and zeros elsewhere.
@@ -153,6 +153,11 @@ def eye(N, M=None, k=0, dtype=float):
to a lower diagonal.
dtype : data-type, optional
Data-type of the returned array.
+ order : {'C', 'F'}, optional
+ Whether the output should be stored in row-major (C-style) or
+ column-major (Fortran-style) order in memory.
+
+ .. versionadded:: 1.14.0
Returns
-------
@@ -178,7 +183,7 @@ def eye(N, M=None, k=0, dtype=float):
"""
if M is None:
M = N
- m = zeros((N, M), dtype=dtype)
+ m = zeros((N, M), dtype=dtype, order=order)
if k >= M:
return m
if k >= 0: