From: Bruce S. <Bru...@nc...> - 2009-09-05 15:18:29
|
The issue isn't how to find a workaround; this is a real bug. Thanks, Aaron, for reporting it. Many similar problems were solved, but we missed this one. The problem is that when the old Numeric module was replaced by numpy, many operations that used to return ordinary types suddenly now returned things like numpy.float64, and some fancy footwork was required to get around problems of the kind you found. Bruce Sherwood Symion wrote: > Aaron Miller wrote: >> Hi VPython folks, >> >> I was attempting to run the contributed script >> http://vpython.org/contributed/bodies.py and I get an error... I have >> tracked it down to the fact that the dot product dot(a,b) between two >> vectors returns a type of numpy.float64 and when I multiply this by a >> vector I get back an array instead of a vector. >> >> A simple example that generates an error for me: >> >> from visual import * >> a=vector(1,0,0) >> b=dot(a,a)*a >> b.mag >> >> Here is the error: >> Traceback (most recent call last): >> File "Untitled", line 4 >> b.mag >> AttributeError: 'numpy.ndarray' object has no attribute 'mag' >> >> Of course, by assigning b as vector(dot(a,a)*a) we fix this, but it >> seems this should not be needed. Is this a bug? >> >> Thanks, >> Aaron >> Python 2.6.2 with VPython 5.12 >> >> ------------------------------------------------------ >> Aaron J. Miller, Ph.D. >> Department of Physics >> 328 Palenske Hall >> Albion College, Albion, MI 49224 >> ------------------------------------------------------------------------ >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users >> > > Try this. > > from visual import * > a=vector(1,0,0) > b=vector(dot(a,a)*a) > b.mag > > Symion |