From bb41c670c9cd289a9d5967a6d239319542565f16 Mon Sep 17 00:00:00 2001 From: dhuard Date: Thu, 20 Mar 2008 13:41:19 +0000 Subject: added docstring to diagflat. --- numpy/lib/twodim_base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'numpy/lib') 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: -- cgit v1.2.1