[Numpy-discussion] Matrix Class

Sebastian Berg sebastian at sipsolutions.net
Wed Feb 11 10:47:54 EST 2015


On Di, 2015-02-10 at 15:07 -0700, cjw wrote:
> It seems to be agreed that there are weaknesses in the existing Numpy Matrix
> Class.
> 
> Some problems are illustrated below.
> 

Not to delve deeply into a discussion, but unfortunately, there seem far
more fundamental problems because of the always 2-D thing and the simple
fact that matrix is more of a second class citizen in numpy (or in other
words a lot of this is just the general fact that it is an ndarray
subclass).

I think some of these issues were summarized in the discussion about the
@ operator. I am not saying that a matrix class separate from numpy
cannot solve these, but within numpy it seems hard.


> 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 list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150211/9403ceaa/attachment.sig>


More information about the NumPy-Discussion mailing list