OMPC- m-script to python script convertor
gopal mishra
gopalm at infotechsw.com
Tue Mar 17 00:59:54 EDT 2009
Hi,
I am trying to convert Matlab script to python script using OMPC.(
http://ompc.juricap.com/ )
My matlab code is (.m file)
Npts=100;
R=0.5;
X=[0:1/Npts:1]';
Y=[0:0.01:1]';
for i=1:Npts+1
if(X(i) <= .5)
Ytop(i)=1.0;
Ybot(i)=0.0;
else
Z=sqrt(R^2-(X(i)-R)^2)-R;
Ytop(i)=2*R+Z;
Ybot(i)=-Z;
end
end
OMPC convert it to (.pym) file
from ompc import *
Npts = 100
R = 0.5
X = mcat([mslice[0:1 / Npts:1]]).cT
Y = mcat([mslice[0:0.01:1]]).cT
for i in mslice[1:Npts + 1]:
if (X(i) <= .5):
Ytop(i).lvalue = 1.0
Ybot(i).lvalue = 0.0
else:
Z = sqrt(R ** 2 - (X(i) - R) ** 2) - R
Ytop(i).lvalue = 2 * R + Z
Ybot(i).lvalue = -Z
end
end
while executing pym file it gives memory error at line no 5 i.e.(X =
mcat([mslice[0:1 / Npts:1]]).cT)
I also tryied out in IDE, it gives error on,
>>> mslice[0:1 / Npts:1]
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\site-packages\ompc\ompclib\ompclib_numpy.py", line
1056, in __getitem__
s.init_data()
File "C:\Python25\lib\site-packages\ompc\ompclib\ompclib_numpy.py", line
910, in init_data
self._a = np.array(list(self), dtype='f8').reshape(self.msize[::-1])
MemoryError
Is there any updated OMPC version, which has solved this issue.
How this can be solved.
Thanks,
Gopal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090317/33b5c791/attachment.html>
More information about the Python-list
mailing list