Commit bb6d0a4a authored by Philipp Arras's avatar Philipp Arras
Browse files

Simplification

parent 29b199ce
...@@ -52,10 +52,7 @@ class Model(NiftyMetaBase()): ...@@ -52,10 +52,7 @@ class Model(NiftyMetaBase()):
return Add.make(self, other) return Add.make(self, other)
def __sub__(self, other): def __sub__(self, other):
if not isinstance(other, Model): return self.__add__(self, (-1) * other)
raise TypeError
from .binary_helpers import Add
return Add.make(self, (-1) * other)
def __mul__(self, other): def __mul__(self, other):
if isinstance(other, (float, int)): if isinstance(other, (float, int)):
...@@ -65,14 +62,10 @@ class Model(NiftyMetaBase()): ...@@ -65,14 +62,10 @@ class Model(NiftyMetaBase()):
from .binary_helpers import Mul from .binary_helpers import Mul
return Mul.make(self, other) return Mul.make(self, other)
if isinstance(other, Field): if isinstance(other, Field):
if other.domain == self.value.domain: return DiagonalOperator(other)(self)
from .binary_helpers import Mul
return DiagonalOperator(other)(self)
raise NotImplementedError raise NotImplementedError
def __rmul__(self, other): def __rmul__(self, other):
if isinstance(other, (float, int)): if isinstance(other, (float, int, Field)):
return self.__mul__(other)
if isinstance(other, Field):
return self.__mul__(other) return self.__mul__(other)
raise NotImplementedError raise NotImplementedError
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