Fix #2015: diag returns ndarray instead of matrix

Fixes #2015.  I also made the two files I edited PEP-8 compliant.