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:
parent
da4af8cbea
commit
94c84d9b36
1 changed files with 14 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue