Colin, I currently use Py3.4 and Numpy 1.9.1. However, I built a quick test conda environment with Python2.7 and Numpy 1.7.0, and I get the same:
############ Python 2.7.9 |Continuum Analytics, Inc.| (default, Dec 18 2014, 16:57:52) [MSC v .1500 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 2.3.1 -- An enhanced Interactive Python. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://binstar.org ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: import numpy as np In [2]: np.__version__ Out[2]: '1.7.0' In [3]: np.mat([4,'5',6]) Out[3]: matrix([['4', '5', '6']], dtype='|S1') In [4]: np.mat([4,'5',6], dtype=int) Out[4]: matrix([[4, 5, 6]]) ############### As to your comment about coordinating with Statsmodels, you should see the links in the thread that Alan posted: http://permalink.gmane.org/gmane.comp.python.numeric.general/56516 http://permalink.gmane.org/gmane.comp.python.numeric.general/56517 Josef's comments at the time seem to echo the issues the devs (and others) have with the matrix class. Maybe things have changed with Statsmodels. I know I mentioned Sage and SageMathCloud before. I'll just point out that there are folks that use this for real research problems, not just as a pedagogical tool. They have a Matrix/vector/column_matrix class that do what you were expecting from your problems posted above. Indeed below is a (truncated) cut and past from a Sage Worksheet. (See http://www.sagemath.org/doc/tutorial/tour_linalg.html) ########## In : Matrix([1,'2',3]) Error in lines 1-1 Traceback (most recent call last): TypeError: unable to find a common ring for all elements In : Matrix([[1,2,3],[4,5]]) ValueError: List of rows is not valid (rows are wrong types or lengths) In : vector([1,2,3]) (1, 2, 3) In : column_matrix([1,2,3]) [1] [2] [3] ########## Large portions of the custom code and wrappers in Sage are written in Python. I don't think their Matrix object is a subclass of ndarray, so perhaps you could strip out the Matrix stuff from here to make a separate project with just the Matrix stuff, if you don't want to go through the Sage interface. On Wed, Feb 11, 2015 at 11:54 AM, cjw <[email protected]> wrote: > > On 11-Feb-15 10:21 AM, Ryan Nelson wrote: > > So: > > In [2]: np.mat([4,'5',6]) > Out[2]: > matrix([['4', '5', '6']], dtype='<U11') > > In [3]: np.mat([4,'5',6], dtype=int) > Out[3]: matrix([[4, 5, 6]]) > > > Thanks Ryan, > > We are not singing from the same hymn book. > > Using PyScripter, I get: > > *** Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit > (AMD64)] on win32. *** > >>> import numpy as np > >>> print('Numpy version: ', np.__version__) > ('Numpy version: ', '1.9.0') > >>> > > Could you say which version you are using please? > > Colin W > > > On Tue, Feb 10, 2015 at 5:07 PM, cjw <[email protected]> <[email protected]> wrote: > > > It seems to be agreed that there are weaknesses in the existing Numpy > Matrix > Class. > > Some problems are illustrated below. > > I'll try to put some suggestions over the coming weeks and would appreciate > comments. > > Colin W. > > Test Script: > > if __name__ == '__main__': > a= mat([4, 5, 6]) # Good > print('a: ', a) > b= mat([4, '5', 6]) # Not the expected result > print('b: ', b) > c= mat([[4, 5, 6], [7, 8]]) # Wrongly accepted as rectangular > print('c: ', c) > d= mat([[1, 2, 3]]) > try: > d[0, 1]= 'b' # Correctly flagged, not numeric > except ValueError: > print("d[0, 1]= 'b' # Correctly flagged, not numeric", > ' > ValueError') > print('d: ', d) > > Result: > > *** Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit > (AMD64)] on win32. *** > > a: [[4 5 6]] > b: [['4' '5' '6']] > c: [[[4, 5, 6] [7, 8]]] > d[0, 1]= 'b' # Correctly flagged, not numeric ValueError > d: [[1 2 3]] > > > > > > -- > View this message in > context:http://numpy-discussion.10968.n7.nabble.com/Matrix-Class-tp39719.html > Sent from the Numpy-discussion mailing list archive at Nabble.com. > _______________________________________________ > NumPy-Discussion mailing > [email protected]http://mail.scipy.org/mailman/listinfo/numpy-discussion > > > > _______________________________________________ > NumPy-Discussion mailing > [email protected]http://mail.scipy.org/mailman/listinfo/numpy-discussion > > > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
