diff options
-rw-r--r-- | polymatrix/expression/expression.py | 4 | ||||
-rw-r--r-- | polymatrix/expression/init.py | 7 | ||||
-rw-r--r-- | polymatrix/polymatrix/index.py | 2 | ||||
-rw-r--r-- | polymatrix/polymatrix/init.py | 1 |
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) } |