summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sumofsquares/constraints.py2
-rw-r--r--sumofsquares/variable.py12
2 files changed, 5 insertions, 9 deletions
diff --git a/sumofsquares/constraints.py b/sumofsquares/constraints.py
index 5f5609f..ddd8405 100644
--- a/sumofsquares/constraints.py
+++ b/sumofsquares/constraints.py
@@ -38,7 +38,7 @@ class BasicSemialgebraicSet(Set, Generic[E]):
polynomials: tuple[E, ...]
def __str__(self):
- polynomials = ', '.join(map(str, self.polynomials))
+ polynomials = ', '.join(f"{p} >= 0" for p in self.polynomials)
return f"{self.__class__.__qualname__}({polynomials})"
diff --git a/sumofsquares/variable.py b/sumofsquares/variable.py
index 0e87e74..73d6c8c 100644
--- a/sumofsquares/variable.py
+++ b/sumofsquares/variable.py
@@ -13,8 +13,9 @@ from __future__ import annotations
from typing import Iterable
from polymatrix.expression.expression import Expression, VariableExpression, init_variable_expression
-from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin
+from polymatrix.expression.from_ import from_any
from polymatrix.expression.init import init_variable_expr
+from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin
from polymatrix.symbol import Symbol
@@ -29,13 +30,8 @@ def from_name(name: str, shape: tuple[int, int] | ExpressionBaseMixin = (1, 1))
elif isinstance(shape, tuple):
nrows, ncols = shape
- if isinstance(nrows, Expression):
- nrows = nrows.underlying
-
- if isinstance(ncols, Expression):
- ncols = ncols.underlying
-
- shape = (nrows, ncols)
+ if (not isinstance(nrows, int)) or (not isinstance(ncols, int)):
+ shape = from_any(((nrows,), (ncols,))).underlying
return init_variable_expression(underlying=init_variable_expr(OptSymbol(name), shape))