Skip to content

Commit

Permalink
funcall works 919/996
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Aug 30, 2016
1 parent ad25956 commit ef206e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
12 changes: 5 additions & 7 deletions smop/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions smop/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion smop/fastsolver.m
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion smop/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit ef206e4

Please sign in to comment.