On Wed, Jan 7, 2015 at 7:35 PM, cjw <cjw@ncf.ca> wrote:
Nathaniel,
Of the two characteristics to which I pointed, I feel that the rectangularity check is the more important. I gave an example of a typo which demonstrated this problem.
The numpy matrix class does require rectangularity; the issue you ran into is more weird than that. It's legal to make a matrix of arbitrary python objects, e.g. np.matrix([["hello", None]]) (this can be useful e.g. if you want to work with extremely large integers using Python's long integer objects). In your case, b/c the lists were not the same length, the matrix constructor guessed that you wanted a matrix containing two Python list objects. This is pretty confusing, and fixing it is bug #5303. But it doesn't indicate any deeper problem with the matrix object. Notice: In [5]: A2 = np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) In [6]: A2.shape Out[6]: (1, 3) In [7]: A2[0, 0] Out[7]: [1, 2, -2]
The error message reported that pinv does not have a conjugate function which, I suggest, is a totally misleading error message.
When working with arrays/matrices of objects, functions like 'pinv' will try to call special methods on the objects. This is a little weird and arguably a bug itself, but it does mean that it's at least possible in theory to have an array of arbitrary python objects and have pinv() work. Of course this requires objects that will cooperate. In this case, though, pinv() has no idea what to do with a matrix whose elements are themselves lists, so it gives an error. -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org