Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Sep 14, 2014
1 parent 2e43a92 commit bf26a5b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions smop/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def isvector(a):
class matlabarray(np.ndarray):
"""
>>> matlabarray()
array([], shape=(0, 0), dtype=float64)
matlabarray([], shape=(0, 0), dtype=float64)
"""

def __new__(cls,a=[],dtype="float64"):
Expand Down Expand Up @@ -227,12 +227,13 @@ def __setitem__(self,index,value):
np.asarray(self).__setitem__(indices,value)

def __repr__(self):
return repr(np.asarray(self))
return self.__class__.__name__ + repr(np.asarray(self))[5:]

def __str__(self):
return str(np.asarray(self))

def __add__(self,other):
return np.asarray(self)+np.asarray(other)
return np.ndarray.__add__(self,other)

def __neg__(self):
Expand Down Expand Up @@ -286,7 +287,7 @@ class cellstr(matlabarray):
"""
>>> s=cellstr(char('helloworldkitty').reshape(3,5))
>>> s
array([['hello', 'world', 'kitty']], dtype=object)
cellstr([['hello', 'world', 'kitty']], dtype=object)
>>> print s
hello
world
Expand Down Expand Up @@ -365,7 +366,7 @@ def arange_(start,stop,step=1,**kwargs):
"""
>>> a=arange_(1,10) # 1:10
>>> size_(a)
array([[ 1., 10.]])
matlabarray([[ 1., 10.]])
"""
return matlabarray(np.arange(start,
stop+1,
Expand Down

0 comments on commit bf26a5b

Please sign in to comment.