<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thanks Sebastian,<br>
<br>
This would appear to make a case for considering not having Matrix
as a sub-class of an np array.<br>
<br>
On the other hand, so much work has gone into np, and there is some
commonality between the needs of Matrix and Array.<br>
<br>
Colin W.<br>
<br>
<div class="moz-cite-prefix">On 11-Feb-15 12:19 PM, Sebastian Berg
wrote:<br>
</div>
<blockquote cite="mid:1423675165.13462.3.camel@sipsolutions.net"
type="cite">
<pre wrap="">On Mi, 2015-02-11 at 11:38 -0500, cjw wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
On 11-Feb-15 10:47 AM, Sebastian Berg wrote:
</pre>
<blockquote type="cite">
<pre wrap="">On Di, 2015-02-10 at 15:07 -0700, cjw wrote:
</pre>
<blockquote type="cite">
<pre wrap="">It seems to be agreed that there are weaknesses in the existing Numpy Matrix
Class.
Some problems are illustrated below.
</pre>
</blockquote>
<pre wrap="">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).
</pre>
</blockquote>
<pre wrap="">Thanks Sebastian,
We'll have to see what comes out of the discussion.
I would be grateful if you could expand on the "always 2D thing". Is
there a need for a collection of matrices, where a function is applied
to each component of the collection?
</pre>
</blockquote>
<pre wrap="">
No, I just mean the fact that a matrix is always 2D. This makes some
things like some indexing operations awkward and some functions that
expect a numpy array (but think they can handle subclasses fine) may
just plain brake. And then ndarray subclasses are just a bit
problematic....
In short, you cannot generally expect a function which works great with
arrays to also work great with matrices, I believe. this is true for
some things within numpy and certainly for third party libraries I am
sure.
- Sebastian
</pre>
<blockquote type="cite">
<pre wrap="">Colin W.
</pre>
<blockquote type="cite">
<pre wrap="">
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.
</pre>
<blockquote type="cite">
<pre wrap="">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: <a class="moz-txt-link-freetext" href="http://numpy-discussion.10968.n7.nabble.com/Matrix-Class-tp39719.html">http://numpy-discussion.10968.n7.nabble.com/Matrix-Class-tp39719.html</a>
Sent from the Numpy-discussion mailing list archive at Nabble.com.
_______________________________________________
NumPy-Discussion mailing list
<a class="moz-txt-link-abbreviated" href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a>
</pre>
</blockquote>
<pre wrap="">
_______________________________________________
NumPy-Discussion mailing list
<a class="moz-txt-link-abbreviated" href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a>
</pre>
</blockquote>
<pre wrap="">
_______________________________________________
NumPy-Discussion mailing list
<a class="moz-txt-link-abbreviated" href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
NumPy-Discussion mailing list
<a class="moz-txt-link-abbreviated" href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a>
</pre>
</blockquote>
<br>
</body>
</html>