Skip to content

Commit 31cdae6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3b02399 commit 31cdae6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

linear_algebra/src/power_iteration.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Tuple, Union
33
import numpy.typing as npt
44

5+
56
def power_iteration(
67
input_matrix: npt.NDArray[Union[np.float64, np.complex128]],
78
vector: npt.NDArray[Union[np.float64, np.complex128]],
@@ -42,12 +43,16 @@ def power_iteration(
4243
# Ensure proper dimensionality.
4344
assert N == np.shape(vector)[0], "Vector must be compatible with matrix dimensions."
4445
# Ensure inputs are either both complex or both real
45-
assert np.iscomplexobj(input_matrix) == np.iscomplexobj(vector), "Both inputs must be either real or complex."
46-
46+
assert np.iscomplexobj(input_matrix) == np.iscomplexobj(
47+
vector
48+
), "Both inputs must be either real or complex."
49+
4750
is_complex = np.iscomplexobj(input_matrix)
4851
if is_complex:
4952
# Ensure complex input_matrix is Hermitian (A == A*)
50-
assert np.array_equal(input_matrix, input_matrix.conj().T), "Input matrix must be Hermitian if complex."
53+
assert np.array_equal(
54+
input_matrix, input_matrix.conj().T
55+
), "Input matrix must be Hermitian if complex."
5156

5257
convergence = False
5358
lambda_previous = 0.0

0 commit comments

Comments
 (0)