1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Update dirtydelta to handle None

This commit is contained in:
Steffo 2019-03-01 17:45:23 +01:00
parent da4af8cbea
commit 94c84d9b36

View file

@ -16,8 +16,20 @@ class Dirty:
class DirtyDelta(Dirty):
@property
def delta(self):
return self.value - self.initial_value
if self.initial_value is None:
initial_value = 0
else:
initial_value = self.initial_value
if self.value is None:
value = 0
else:
value = self.value
return value - initial_value
@delta.setter
def delta(self, value):
self.value = self.initial_value + value
if self.initial_value is None:
initial_value = 0
else:
initial_value = self.initial_value
self.value = initial_value + value