Skip to content
Snippets Groups Projects
Commit cc84e420 authored by Danilo Ferreira de Lima's avatar Danilo Ferreira de Lima
Browse files

Fixes several points found by Cammille.

parent 22f1d63b
No related branches found
No related tags found
1 merge request!26Added example for SCS.
Pipeline #132017 passed
......@@ -23,13 +23,15 @@ class VSConfig(object):
"SA3_XTD10_PES/DCTRL/V30330S_XENON",
]
def __init__(self, other=None):
def __init__(self, other: object=None):
self.voltage: Dict[str, float] = dict()
self.voltage_tol: Dict[str, float] = dict()
self.pressure: float = np.nan
self.pressure_tol: float = np.nan
self.gas: Set[str] = set()
if other is not None:
if not isinstance(other, VSConfig):
raise ValueError("The argument given in the constructor must be another class of type VSConfig.")
self.voltage = deepcopy(other.voltage)
self.voltage_tol = deepcopy(other.voltage_tol)
self.pressure = deepcopy(other.pressure)
......@@ -92,16 +94,18 @@ class VSConfig(object):
errors += [f"Multiple gas active during the data: {self.gas}."]
return errors
def __sub__(self, other: 'VSConfig') -> 'VSConfig':
def __sub__(self, other: object) -> 'VSConfig':
"""
Take difference between two configuratons.
"""
if not isinstance(other, VSConfig):
raise ValueError("I can only subtract with another VSConfig object.")
diff = VSConfig(self)
diff.voltage = {k: self.voltage[k] - other.voltage[k]
for k in self.voltage}
diff.voltage = {k: v - other.voltage[k]
for k, v in self.voltage.items()}
diff.pressure = self.pressure - other.pressure
diff.voltage_tol = {k: np.sqrt(self.voltage_tol[k]**2 + other.voltage_tol[k]**2)
for k in self.voltage_tol}
diff.voltage_tol = {k: np.sqrt(v**2 + other.voltage_tol[k]**2)
for k in self.voltage_tol.items()}
diff.pressure_tol = np.sqrt(self.pressure_tol**2 + other.pressure_tol**2)
diff.gas = set(self.gas).difference(set(other.gas))
return diff
......@@ -113,7 +117,7 @@ class VSConfig(object):
if not isinstance(other, VSConfig):
raise ValueError("I can only check equality with another VSConfig object.")
diff = self - other
for k, v in diff.voltage.items():
for v in diff.voltage.values():
if np.fabs(v) > 0.1:
return False
if np.fabs(diff.pressure) > diff.pressure_tol:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment