From a58af206760e05b80edeee2712051ee55bc22227 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 9 May 2024 16:31:41 +0200 Subject: Improve error message of matrix multiplication --- polymatrix/expression/mixins/matrixmultexprmixin.py | 6 +++--- 1 file 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, ) ) -- cgit v1.2.1