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

Created VS configuration.

parent 6d1dd9e4
No related branches found
No related tags found
1 merge request!26Added example for SCS.
Pipeline #131774 passed
......@@ -7,6 +7,7 @@ from extra_data import open_run
import re
import numpy as np
from copy import deepcopy
import json
class VSConfig(object):
"""
......@@ -114,5 +115,40 @@ class VSConfig(object):
if len(diff.gas_active) > 0:
return False
def to_dict(self) -> Dict[str, Union[List[float], float, List[str]]]:
"""
Return as a dictionary.
"""
out = dict(
voltage_mean=self.voltage_mean,
voltage_std=self.voltage_std,
pressure_mean=self.pressure_mean,
pressure_std=self.pressure_std,
gas_active=list(self.gas_active))
return out
@staticmethod
def from_dict(data: Dict[str, Union[List[float], float, List[str]]]) -> 'VSConfig':
"""
Build from dictionary.
"""
out = VSConfig()
out.voltage_mean = data['voltage_mean']
out.voltage_std = data['voltage_std']
out.pressure_mean = data['pressure_mean']
out.pressure_std = data['pressure_std']
out.gas_active = set(data['gas_active'])
return out
def __str__(self) -> str:
"""
Dump as string.
"""
return json.dumps(self.to_dict())
def __repr__(self) -> str:
"""
Dump as string.
"""
return json.dumps(self.to_dict())
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