Add algorithm property
This commit is contained in:
parent
def7074a23
commit
71347327ab
@ -15,6 +15,8 @@ REFLECTION_PRINTER_FORMATS = (
|
|||||||
"oksana",
|
"oksana",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ALGORITHMS = ("adaptivemaxcog", "adaptivedynamic")
|
||||||
|
|
||||||
|
|
||||||
def anatric(config_file):
|
def anatric(config_file):
|
||||||
subprocess.run(["anatric", config_file], check=True)
|
subprocess.run(["anatric", config_file], check=True)
|
||||||
@ -30,7 +32,6 @@ class AnatricConfig:
|
|||||||
self._tree = tree
|
self._tree = tree
|
||||||
|
|
||||||
alg_elem = tree.find("Algorithm")
|
alg_elem = tree.find("Algorithm")
|
||||||
self.algorithm = alg_elem.attrib["implementation"]
|
|
||||||
if self.algorithm == "adaptivemaxcog":
|
if self.algorithm == "adaptivemaxcog":
|
||||||
self.threshold = float(alg_elem.find("threshold").attrib["value"])
|
self.threshold = float(alg_elem.find("threshold").attrib["value"])
|
||||||
self.shell = float(alg_elem.find("shell").attrib["value"])
|
self.shell = float(alg_elem.find("shell").attrib["value"])
|
||||||
@ -212,5 +213,16 @@ class AnatricConfig:
|
|||||||
|
|
||||||
self._tree.find("ReflectionPrinter").attrib["format"] = value
|
self._tree.find("ReflectionPrinter").attrib["format"] = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def algorithm(self):
|
||||||
|
return self._tree.find("Algorithm").attrib["implementation"]
|
||||||
|
|
||||||
|
@algorithm.setter
|
||||||
|
def algorithm(self, value):
|
||||||
|
if value not in ALGORITHMS:
|
||||||
|
raise ValueError("Unknown algorithm.")
|
||||||
|
|
||||||
|
self._tree.find("Algorithm").attrib["implementation"] = value
|
||||||
|
|
||||||
def save_as(self, filename):
|
def save_as(self, filename):
|
||||||
self._tree.write(filename)
|
self._tree.write(filename)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user