Commit 1b1590b5 by Ziheng Jiang Committed by Tianqi Chen

add rpow & fix 'Number' to 'Number_' (#76)

parent 7b36a19b
......@@ -43,13 +43,13 @@ class Symbol(SymbolBase):
def __sub__(self, other):
if isinstance(other, Symbol):
return _internal.__sub_symbol__(self, other)
if isinstance(other, Number):
if isinstance(other, _Number):
return _internal.__sub_scalar__(self, scalar=other)
else:
raise TypeError('type %s not supported' % str(type(other)))
def __rsub__(self, other):
if isinstance(other, Number):
if isinstance(other, _Number):
return _internal.__rsub_scalar__(self, scalar=other)
else:
raise TypeError('type %s not supported' % str(type(other)))
......@@ -68,13 +68,13 @@ class Symbol(SymbolBase):
def __div__(self, other):
if isinstance(other, Symbol):
return _internal.__div_symbol__(self, other)
if isinstance(other, Number):
if isinstance(other, _Number):
return _internal.__div_scalar__(self, scalar=other)
else:
raise TypeError('type %s not supported' % str(type(other)))
def __rdiv__(self, other):
if isinstance(other, Number):
if isinstance(other, _Number):
return _internal.__rdiv_scalar__(self, scalar=other)
else:
raise TypeError('type %s not supported' % str(type(other)))
......@@ -88,11 +88,17 @@ class Symbol(SymbolBase):
def __pow__(self, other):
if isinstance(other, Symbol):
return _internal.__pow_symbol__(self, other)
if isinstance(other, Number):
if isinstance(other, _Number):
return _internal.__pow_scalar__(self, scalar=other)
else:
raise TypeError('type %s not supported' % str(type(other)))
def __rpow__(self, other):
if isinstance(other, _Number):
return _internal.__rpow_scalar__(self, scalar=other)
else:
raise TypeError('type %s not supported' % str(type(other)))
def __neg__(self):
return self.__mul__(-1.0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment