BUG: Closes #2015: diag returns ndarray

If x is a matrix, np.diag(x) and np.diagonal(x) now return matrices
instead of arrays.  Both of these cause x.diagonal() to be called.
That means they return row vectors (just like x.flatten(), x.ravel(),
x.cumprod(), etc.)
Improved PEP-8 compliance
Merge pull request #5358 from Garrett-R/fix_bug_2015

Fix #2015: diag returns ndarray instead of matrix