Error using 0.4.8 on code that worked on 0.3.2
![](https://secure.gravatar.com/avatar/dd2c4449c3e06e377f5f1fea0b4b5571.jpg?s=120&d=mm&r=g)
mat=[[1,2,3],[4,5,6],[7,8,9]] import scipy scipy.cov(mat) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/numpy/lib/function_base.py",
Hello everybody, I am almost new to Scipy. I was using the following in my code on 0.3.2 and it worked: line 649, in cov if (m.shape[0] == 1): AttributeError: 'list' object has no attribute 'shape' Now it is necessary to use always an array:
amat = array(mat) Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'array' is not defined amat = scipy.array(mat) scipy.cov(amat) array([[ 9., 9., 9.], [ 9., 9., 9.], [ 9., 9., 9.]])
Is this better? If it is, (by no means I try to critize good work made on scipy) maybe it would be better if 'cov' funtion checked the type before begining, and throw an more meaningfull error. :-? Just a suggestion. Also I had problems because cov function returns an integer if matrix is 1x1. I have used this workarround but I am not sure if this is the best way to work with Scipy. Any suggestions? ----------------------------------------------------------- ... disp1 = scipy.cov(class1) #within class1 scatter matrix disp2 = scipy.cov(class2) #within class2 scatter matrix #We allways want covariance matrices even if they are 1 by 1 if not type(disp1) == type( scipy.array(0) ): disp1 = scipy.array([[disp1]]) if not type(disp2) == type( scipy.array(0) ): disp2 = scipy.array([[disp2]]) aux = scipy.add(disp1,disp2) aux = scipy.divide(aux,2) ... ----------------------------------------------------------- -- Regards, Antonio Arauzo Azofra
participants (1)
-
Antonio Arauzo Azofra