Commit 6b9d5cb4 authored by Philipp Arras's avatar Philipp Arras
Browse files

Cosmetics

parent 8d1d3793
......@@ -131,24 +131,24 @@ class Energy(NiftyMetaBase()):
def __mul__(self, factor):
from .energy_sum import EnergySum
if not isinstance(factor, (float, int)):
raise TypeError("Factor must be a real-valued scalar")
return EnergySum.make([self], [factor])
if isinstance(factor, (float, int)):
return EnergySum.make([self], [factor])
return NotImplemented
def __rmul__(self, factor):
return self.__mul__(factor)
def __add__(self, other):
from .energy_sum import EnergySum
if not isinstance(other, Energy):
raise TypeError("can only add Energies to Energies")
return EnergySum.make([self, other])
if isinstance(other, Energy):
return EnergySum.make([self, other])
return NotImplemented
def __sub__(self, other):
from .energy_sum import EnergySum
if not isinstance(other, Energy):
raise TypeError("can only subtract Energies from Energies")
return EnergySum.make([self, other], [1., -1.])
if isinstance(other, Energy):
return EnergySum.make([self, other], [1., -1.])
return NotImplemented
def __neg__(self):
from .energy_sum import EnergySum
......
......@@ -16,8 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from .energy import Energy
from ..utilities import memo
from .energy import Energy
class EnergySum(Energy):
......
......@@ -16,11 +16,12 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
import nifty5 as ift
import numpy as np
import unittest
from itertools import product
from test.common import expand
import nifty5 as ift
import numpy as np
from numpy.testing import assert_allclose, assert_raises
......
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