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]> 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 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
|