diff --git a/smop/backend.py b/smop/backend.py index 7a057c58..88f04183 100644 --- a/smop/backend.py +++ b/smop/backend.py @@ -56,7 +56,7 @@ def del elif else except Data Float Int Numeric Oxphys array close float int input - open range type write zeros + open range type write len """.split()) @@ -215,19 +215,17 @@ def _backend(self,level=0): @extend(node.func_stmt) def _backend(self,level=0): - if (self.args and - isinstance(self.args[-1],node.ident) and - self.args[-1].name == "varargin"): - self.args[-1].name = "*varargin" + self.args.append(node.ident("*args")) + self.args.append(node.ident("**kwargs")) + s = """ @function def %s(%s): nargin = sys._getframe(1).f_locals["nargin"] varargin = sys._getframe(1).f_locals["varargin"] - + nargout = sys._getframe(1).f_locals["nargout"] """ % (self.ident._backend(), self.args._backend()) - return s @extend(node.funcall) diff --git a/smop/core.py b/smop/core.py index 0d252d76..a229880b 100644 --- a/smop/core.py +++ b/smop/core.py @@ -693,7 +693,7 @@ def true(*args): return matlabarray(np.ones(args,dtype=bool,order="F")) def version(): - return char('0.26') + return char('0.29') def zeros(*args,**kwargs): if not args: @@ -709,7 +709,9 @@ def print_usage(): raise Exception def function(f): - def helper(*args): + def helper(*args,**kwargs): + nargout = kwargs and kwargs["nargout"] + varargin = cellarray(args) nargin=len(args) return f(*args) return helper diff --git a/smop/fastsolver.m b/smop/fastsolver.m index 2116bc88..196b825e 100644 --- a/smop/fastsolver.m +++ b/smop/fastsolver.m @@ -1,4 +1,4 @@ -function moves=solver(A,B,w0) +function moves=fastsolver(A,B,w0) [moves,optmove,optscore]=cbest(A,B,w0); curscore=sum(w0(moves(:,1))); lots=1; diff --git a/smop/parse.py b/smop/parse.py index de18db46..fe04fc02 100644 --- a/smop/parse.py +++ b/smop/parse.py @@ -435,7 +435,8 @@ def p_ident_init_opt(p): else: p[0] = p[1] if len(p) == 2: - p[0].init = node.ident(name="None") if p[0].name != "varargin" else "" +# p[0].init = node.ident(name="None") if p[0].name != "varargin" else "" + pass else: p[0].init = p[3]