Christopher Barker wrote: > Keith Goodman wrote: >> diag(NxN matrix) should return a Nx1 matrix >> diag(Nx1 or 1xN matrix) should return a NxN matrix > > This is the key problem: extracting the diagonal of a matrix and > creating a matrix from a diagonal are two different operations: > overloading one function to do both was a bad idea to begin with. > > Maybe we should just keep diag() as is is for backward compatibility > (deprecated), and make: > > get_diag() and make_diag() instead. > > Then it would be unambiguous what you wanted with: > > make_diag(<Nx1array>) > > You can call them something else, but you get the idea.
As .diagonal() is a method on both arrays and matrices, we don't need a separate get_diag(). In the abstract, I heartily approve. However, I'm not sure that deprecation in favor of a clumsier name is going to be effective in practice. diag([a, b, c]) is just too tempting and will remain an attractive nuisance. It matches mathematical notation ever so nicely. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion