Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Oct 13, 2014
1 parent f9fb017 commit e44b5c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 5 additions & 5 deletions smop/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def _backend(self,level=0):
return "arange_(%s)" % self.args._backend()

if self.op == "end":
if self.args:
return "%s.shape[%s]" % (self.args[0]._backend(),
self.args[1]._backend())
else:
return "end"
# if self.args:
# return "%s.shape[%s]" % (self.args[0]._backend(),
# self.args[1]._backend())
# else:
return "end()"
if self.op == ".":
return "%s%s" % (self.args[0]._backend(),
self.args[1]._backend())
Expand Down
8 changes: 4 additions & 4 deletions smop/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ def resolve(t, symtab=None, fp=None, func_name=None):
for i,v in enumerate(u.args):
if v.__class__ is node.expr and v.op == ":":
v.op = "::"
for w in node.postorder(v):
if w.__class__ is node.expr and w.op == "end":
w.args[0] = u.func_expr
w.args[1] = node.number(i)
# for w in node.postorder(v):
# if w.__class__ is node.expr and w.op == "end":
# w.args[0] = u.func_expr
# w.args[1] = node.number(i)

for u in node.postorder(t):
if u.__class__ is node.let:
Expand Down
11 changes: 10 additions & 1 deletion smop/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def compute_indices(self,index):
raise IndexError
indices = []
for i,ix in enumerate(index):
if ix.__class__ is slice:
if ix.__class__ is end:
indices.append(self.shape[i]-1+ix.n)
elif ix.__class__ is slice:
if self.size == 0 and ix.stop is None:
raise IndexError
if len(index) == 1:
Expand Down Expand Up @@ -246,6 +248,13 @@ def __add__(self,other):
def __neg__(self):
return matlabarray(np.asarray(self).__neg__())

class end(object):
def __add__(self,n):
self.n = n
return self
def __sub__(self,n):
self.n = -n
return self
####
class cellarray(matlabarray):
"""
Expand Down

0 comments on commit e44b5c1

Please sign in to comment.