Add parameter normalization function
This commit is contained in:
@@ -31,6 +31,25 @@ class Graph(metaclass=ABCMeta):
|
||||
def getPlotPoints(self, mainInput, miscInputs, xSpec, ySpec, fit, tgt):
|
||||
raise NotImplementedError
|
||||
|
||||
_normalizers = {}
|
||||
|
||||
def _normalizeParams(self, mainInput, miscInputs, fit, tgt):
|
||||
if mainInput.unit in self._normalizers:
|
||||
normalizer = self._normalizers[mainInput.unit]
|
||||
newMainInput = [mainInput.handle, tuple(normalizer(v) for v in mainInput.value)]
|
||||
else:
|
||||
newMainInput = [mainInput.handle, mainInput.value]
|
||||
newMiscInputs = []
|
||||
for miscInput in miscInputs:
|
||||
if miscInput.unit in self._normalizers:
|
||||
newMiscInput = [miscInput.handle, self._normalizers[miscInput.unit](miscInput.value)]
|
||||
else:
|
||||
newMiscInput = [miscInput.handle, miscInput.value]
|
||||
newMiscInputs.append(newMiscInput)
|
||||
return newMainInput, newMiscInputs
|
||||
|
||||
### Old stuff
|
||||
|
||||
def getYForX(self, x, miscInputs, xSpec, ySpec, fit, tgt):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -1,18 +1,31 @@
|
||||
import math
|
||||
|
||||
from eos.const import FittingModuleState
|
||||
from .base import SmoothGraph
|
||||
from .base import Graph
|
||||
|
||||
|
||||
AU_METERS = 149597870700
|
||||
|
||||
|
||||
class FitWarpTimeGraph(SmoothGraph):
|
||||
class FitWarpTimeGraph(Graph):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.subwarpSpeed = None
|
||||
|
||||
def getPlotPoints(self, mainInput, miscInputs, xSpec, ySpec, fit, tgt):
|
||||
mainInput, miscInputs = self._normalizeParams(mainInput, miscInputs, fit, tgt)
|
||||
|
||||
# limit all parameters to be within limits (time)
|
||||
# pick getter according to x handle and y handle and run it
|
||||
# un-render returned parameters if passed x is relative
|
||||
return [], []
|
||||
|
||||
_normalizers = {
|
||||
'AU': lambda x: x * AU_METERS,
|
||||
'km': lambda x: x * 1000}
|
||||
|
||||
|
||||
def getYForX(self, fit, extraData, distance):
|
||||
if distance == 0:
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user