victorlei / smop

Small Matlab to Python compiler
MIT License
1.09k stars 410 forks source link

"cos()" inside function block converted to cos_ #67

Open adriaanph opened 9 years ago

adriaanph commented 9 years ago

this has a bearing on #33

using 0.26.2 i've just noticed that built-in functions such as cos() get converted to "cos_()" if it's encountered inside a function block. that doesn't seem correct. for example test.m below converts to test.py.

t = (0:1/8000:0.1)'; x = cos(2_pi_60*t); y = atan(x); function [p,q] = getp(StopTime,Fc) t = (0:1/8000:0.1)'; p = cos(2_pi_60*t); q = atan(p); end from **future** import division try: from runtime import * except ImportError: from smop.runtime import * t=(arange_(0,0.1,1 / 8000)).T x=cos(2 \* pi \* 60 \* t) y=atan(x) def getp_(StopTime=None,Fc=None,_args,_*kwargs): varargin = cellarray(args) nargin = 2-[StopTime,Fc].count(None)+len(args) ``` t=(arange_(0,0.1,1 / 8000)).T p=cos_(2 * pi * 60 * t) q=atan_(p) return p,q ```