summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-09 16:31:41 +0200
committerNao Pross <np@0hm.ch>2024-05-09 16:31:41 +0200
commita58af206760e05b80edeee2712051ee55bc22227 (patch)
tree0a41ad430bf3e38b36736392a619b43e1ad49ee0
parentAdapt CombinationsExprMixin to work with expression coefficients (diff)
downloadpolymatrix-a58af206760e05b80edeee2712051ee55bc22227.tar.gz
polymatrix-a58af206760e05b80edeee2712051ee55bc22227.zip
Improve error message of matrix multiplication
-rw-r--r--polymatrix/expression/mixins/matrixmultexprmixin.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/polymatrix/expression/mixins/matrixmultexprmixin.py b/polymatrix/expression/mixins/matrixmultexprmixin.py
index 9402a19..2d86619 100644
--- a/polymatrix/expression/mixins/matrixmultexprmixin.py
+++ b/polymatrix/expression/mixins/matrixmultexprmixin.py
@@ -30,12 +30,12 @@ class MatrixMultExprMixin(ExpressionBaseMixin):
state, left = self.left.apply(state=state)
state, right = self.right.apply(state=state)
- # assert left.shape[1] == right.shape[0], f'{left.shape[1]} is not equal to {right.shape[0]}'
-
if not (left.shape[1] == right.shape[0]):
+ msg = f"Cannot multiply matrices {self.left} and {self.right} because their shapes " \
+ f"{left.shape}, and {right.shape} do not match!"
raise AssertionError(
to_operator_exception(
- message=f"{left.shape[1]} is not equal to {right.shape[0]}",
+ message=msg,
stack=self.stack,
)
)