Skip to content

Commit

Permalink
Merge pull request #24161 from sylee957/ShapeError
Browse files Browse the repository at this point in the history
Make ShapeError more readable
  • Loading branch information
oscarbenjamin committed Oct 23, 2022
2 parents bbbbf56 + f28fc1a commit 7a66072
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ Ryan Krauss <[email protected]>
Rémy Léone <[email protected]>
S. Hanko <[email protected]>
S.Y. Lee <[email protected]> (Lazard) S.Y. Lee <[email protected]>
S.Y. Lee <[email protected]> Sangyub Lee <[email protected]>
S.Y. Lee <[email protected]> sylee957 <[email protected]>
Saanidhya vats <[email protected]> Saanidhya <[email protected]>
Saanidhya vats <[email protected]> Saanidhya <[email protected]>
Expand Down
12 changes: 8 additions & 4 deletions sympy/matrices/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def col_insert(self, pos, other):

if self.rows != other.rows:
raise ShapeError(
"`self` and `other` must have the same number of rows.")
"The matrices have incompatible number of rows ({} and {})"
.format(self.rows, other.rows))

return self._eval_col_insert(pos, other)

Expand Down Expand Up @@ -284,7 +285,8 @@ def col_join(self, other):

if self.cols != other.cols:
raise ShapeError(
"`self` and `other` must have the same number of columns.")
"The matrices have incompatible number of columns ({} and {})"
.format(self.cols, other.cols))
return self._eval_col_join(other)

def col(self, j):
Expand Down Expand Up @@ -488,7 +490,8 @@ def row_insert(self, pos, other):

if self.cols != other.cols:
raise ShapeError(
"`self` and `other` must have the same number of columns.")
"The matrices have incompatible number of columns ({} and {})"
.format(self.cols, other.cols))

return self._eval_row_insert(pos, other)

Expand Down Expand Up @@ -519,7 +522,8 @@ def row_join(self, other):

if self.rows != other.rows:
raise ShapeError(
"`self` and `rhs` must have the same number of rows.")
"The matrices have incompatible number of rows ({} and {})"
.format(self.rows, other.rows))
return self._eval_row_join(other)

def diagonal(self, k=0):
Expand Down

0 comments on commit 7a66072

Please sign in to comment.