@@ -336,54 +336,48 @@ def __add__(self, other):
336336 other = as_slate (other )
337337 return Add (self , other )
338338 except TypeError :
339- raise NotImplementedError ("Type(s) for + not supported: '%s' '%s'"
340- % (type (self ), type (other )))
339+ return NotImplemented
341340
342341 def __radd__ (self , other ):
343342 # If other cannot be converted into a TensorBase, raise NotImplementedError.
344343 # Otherwise, delegate action to other.
345344 try :
346345 other = as_slate (other )
347- return other . __add__ ( self )
346+ return other + self
348347 except TypeError :
349- raise NotImplementedError ("Type(s) for + not supported: '%s' '%s'"
350- % (type (other ), type (self )))
348+ return NotImplemented
351349
352350 def __sub__ (self , other ):
353351 try :
354352 other = as_slate (other )
355353 return Add (self , Negative (other ))
356354 except TypeError :
357- raise NotImplementedError ("Type(s) for - not supported: '%s' '%s'"
358- % (type (self ), type (other )))
355+ return NotImplemented
359356
360357 def __rsub__ (self , other ):
361358 # If other cannot be converted into a TensorBase, raise NotImplementedError.
362359 # Otherwise, delegate action to other.
363360 try :
364361 other = as_slate (other )
365- return other . __sub__ ( self )
362+ return other - self
366363 except TypeError :
367- raise NotImplementedError ("Type(s) for - not supported: '%s' '%s'"
368- % (type (other ), type (self )))
364+ return NotImplemented
369365
370366 def __mul__ (self , other ):
371367 try :
372368 other = as_slate (other )
373369 return Mul (self , other )
374370 except TypeError :
375- raise NotImplementedError ("Type(s) for * not supported: '%s' '%s'"
376- % (type (self ), type (other )))
371+ return NotImplemented
377372
378373 def __rmul__ (self , other ):
379374 # If other cannot be converted into a TensorBase, raise NotImplementedError.
380375 # Otherwise, delegate action to other.
381376 try :
382377 other = as_slate (other )
383- return other . __mul__ ( self )
378+ return other * self
384379 except TypeError :
385- raise NotImplementedError ("Type(s) for * not supported: '%s' '%s'"
386- % (type (other ), type (self )))
380+ return NotImplemented
387381
388382 def __neg__ (self ):
389383 return Negative (self )
0 commit comments