summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-06-06 00:14:13 +0200
committerNao Pross <np@0hm.ch>2024-06-06 00:14:13 +0200
commit05a188792a2a3eee0a4ea9a0b69d5dc82b4119fc (patch)
tree74ab95cc2a4e40d2a4cb1b3edd7f4f5ac6a10ac4
parentAllow construction from mixed tuples in from_any (diff)
downloadpolymatrix-05a188792a2a3eee0a4ea9a0b69d5dc82b4119fc.tar.gz
polymatrix-05a188792a2a3eee0a4ea9a0b69d5dc82b4119fc.zip
Fix bug in from_name
Diffstat (limited to '')
-rw-r--r--polymatrix/expression/from_.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/polymatrix/expression/from_.py b/polymatrix/expression/from_.py
index ce35a83..03091c7 100644
--- a/polymatrix/expression/from_.py
+++ b/polymatrix/expression/from_.py
@@ -117,6 +117,16 @@ def from_name(
if isinstance(shape, Expression):
shape = shape.underlying
+ elif isinstance(shape, tuple):
+ nrows, ncols = shape
+ if isinstance(nrows, Expression):
+ nrows = nrows.underlying
+
+ if isinstance(ncols, Expression):
+ ncols = ncols.underlying
+
+ shape = (nrows, ncols)
+
return init_variable_expression(init.init_variable_expr(Symbol(name), shape))