diff options
author | dhuard <dhuard@localhost> | 2008-03-20 13:41:19 +0000 |
---|---|---|
committer | dhuard <dhuard@localhost> | 2008-03-20 13:41:19 +0000 |
commit | bb41c670c9cd289a9d5967a6d239319542565f16 (patch) | |
tree | 1f277d4cecf8ef7ac91e7442fa8d5f4fe502a882 /numpy/lib/twodim_base.py | |
parent | 51a622241b5bdfa3ec88fa0dc41ac1a7558a51e2 (diff) | |
download | numpy-bb41c670c9cd289a9d5967a6d239319542565f16.tar.gz |
added docstring to diagflat.
Diffstat (limited to 'numpy/lib/twodim_base.py')
-rw-r--r-- | numpy/lib/twodim_base.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index 4852097f3..e82053942 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -83,6 +83,22 @@ def diag(v, k=0): raise ValueError, "Input must be 1- or 2-d." def diagflat(v,k=0): + """Return a 2D array whose k'th diagonal is a flattened v and all other + elements are zero. + + Examples + -------- + >>> diagflat([[1,2],[3,4]]]) + array([[1, 0, 0, 0], + [0, 2, 0, 0], + [0, 0, 3, 0], + [0, 0, 0, 4]]) + + >>> diagflat([1,2], 1) + array([[0, 1, 0], + [0, 0, 2], + [0, 0, 0]]) + """ try: wrap = v.__array_wrap__ except AttributeError: |