irt-service/app/models/target.py
2022-03-16 02:51:39 +00:00

23 lines
567 B
Python

from pydantic import BaseModel
from typing import Optional
class Target(BaseModel):
theta: float
value: float
result: Optional[float]
drift: float = 0.0
@classmethod
def max_drift(cls):
return 120 # let it drift...
@classmethod
def max_drift_increment(cls):
return 10 # 10%
def minimum(self, drift_percent = 0.0) -> float:
return round(self.value - (self.value * drift_percent), 2)
def maximum(self, drift_percent = 0.0) -> float:
return round(self.value + (self.value * drift_percent), 2)