summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-06-17 13:06:25 +0200
committerNao Pross <np@0hm.ch>2024-06-17 13:06:25 +0200
commit9446f0b87636527646e31b49f44d8d74d8dc9604 (patch)
tree5b2f86f8dedc350309b1afa5938babe899d329f1
parentFix bug in PolyMatrixAsAffineExpression.monomials_eval_all (diff)
downloadpolymatrix-9446f0b87636527646e31b49f44d8d74d8dc9604.tar.gz
polymatrix-9446f0b87636527646e31b49f44d8d74d8dc9604.zip
Comments
Diffstat (limited to '')
-rw-r--r--polymatrix/expression/expression.py4
-rw-r--r--polymatrix/expression/init.py7
-rw-r--r--polymatrix/polymatrix/index.py2
-rw-r--r--polymatrix/polymatrix/init.py1
4 files changed, 9 insertions, 5 deletions
diff --git a/polymatrix/expression/expression.py b/polymatrix/expression/expression.py
index 2e4d544..e4f2648 100644
--- a/polymatrix/expression/expression.py
+++ b/polymatrix/expression/expression.py
@@ -56,11 +56,11 @@ class Expression(ExpressionBaseMixin, ABC):
else:
return attr
- def __getitem__(self, slice: int | slice | tuple[int | slice, int | slice]) -> Expression:
+ def __getitem__(self, item: int | slice | tuple[int | slice, int | slice]) -> Expression:
return self.copy(
underlying=init.init_slice_expr(
underlying=self.underlying,
- slice=slice
+ slices=item
),
)
diff --git a/polymatrix/expression/init.py b/polymatrix/expression/init.py
index 15557f4..f0c2a0b 100644
--- a/polymatrix/expression/init.py
+++ b/polymatrix/expression/init.py
@@ -392,9 +392,12 @@ def init_shape_expr(underlying: ExpressionBaseMixin):
def init_slice_expr(
underlying: ExpressionBaseMixin,
- slice: tuple[int | slice | range, int | slice | range]
+ slices: int | slice | range | tuple[int | slice | range, int | slice | range]
):
- return polymatrix.expression.impl.SliceExprImpl(underlying, slice)
+ # FIXME: For some reason in older python versions slice is not a hashable
+ # type and this causes crashes when old code uses the cache in the state object
+ # cf. https://stackoverflow.com/questions/29980786/why-are-slice-objects-not-hashable-in-python
+ return polymatrix.expression.impl.SliceExprImpl(underlying, slices)
diff --git a/polymatrix/polymatrix/index.py b/polymatrix/polymatrix/index.py
index e4bd7d1..53c63f1 100644
--- a/polymatrix/polymatrix/index.py
+++ b/polymatrix/polymatrix/index.py
@@ -14,7 +14,7 @@ PolynomialMatrixData = dict[tuple[int, int], PolynomialData]
class VariableIndex(NamedTuple):
- """
+ r"""
Index for a variable raised to an integral power.
`VariableIndex` has a partial order with respect to the variable index. For
diff --git a/polymatrix/polymatrix/init.py b/polymatrix/polymatrix/init.py
index d66a3d0..8b390c4 100644
--- a/polymatrix/polymatrix/init.py
+++ b/polymatrix/polymatrix/init.py
@@ -150,6 +150,7 @@ def to_affine_expression(p: PolyMatrixMixin) -> PolyMatrixAsAffineExpressionMixi
# Generate slices to index sub-matrices
slices = {
+ # TODO: use range directly without tuple
m: tuple(range(i*ncols, (i+1)*ncols))
for i, m in enumerate(monomials)
}