Skip to content

Commit 1942d78

Browse files
committed
chore: update is_diagonal
1 parent efc22df commit 1942d78

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mpqp/tools/maths.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def is_unitary(matrix: Matrix) -> bool:
133133

134134

135135
@typechecked
136-
def is_diagonal(matrix: Matrix):
136+
def is_diagonal(matrix: Union[Matrix, np.ndarray]):
137137
"""Checks whether the square matrix in parameter is diagonal.
138138
139139
Args:
@@ -154,7 +154,11 @@ def is_diagonal(matrix: Matrix):
154154
i, j = matrix.shape
155155
if i != j:
156156
raise ValueError(
157-
"The input matrix is not square. Dimensions = (" + i + ", " + j + ")."
157+
"The input matrix is not square. Dimensions = ("
158+
+ str(i)
159+
+ ", "
160+
+ str(j)
161+
+ ")."
158162
)
159163
test = matrix.reshape(-1)[:-1].reshape(i - 1, j + 1)
160164
return not np.any(test[:, 1:])

0 commit comments

Comments
 (0)