summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-08 12:10:23 +0200
committerNao Pross <np@0hm.ch>2024-05-08 12:10:23 +0200
commitac9af956910c587b033a4beb756ad2d21697e78c (patch)
treeb7eda89d2687c9ad7a7441e73307f3bd09d15a4e
parentExpose ArchimedeanSet with make_set (diff)
downloadsumofsquares-ac9af956910c587b033a4beb756ad2d21697e78c.tar.gz
sumofsquares-ac9af956910c587b033a4beb756ad2d21697e78c.zip
Make CVXOPInfo behave like a dataclass
-rw-r--r--sumofsquares/cvxopt.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/sumofsquares/cvxopt.py b/sumofsquares/cvxopt.py
index ce7b093..12f8e44 100644
--- a/sumofsquares/cvxopt.py
+++ b/sumofsquares/cvxopt.py
@@ -18,6 +18,13 @@ from .variable import OptVariable
class CVXOPTInfo(SolverInfo, UserDict):
""" Dictionary returned by CVXOPT. """
+ def __getattr__(self, attr):
+ key = " ".join(attr.split("_"))
+ if key not in self.keys():
+ raise KeyError(f"Key {key} was not found")
+ return self[key]
+
+
def solve_sos_cone(prob: Problem, verbose: bool = False, *args, **kwargs) -> tuple[dict[OptVariable, float], CVXOPTInfo]:
r"""