Skip to content

Commit 0f10466

Browse files
committed
reformat with black
1 parent 97080e3 commit 0f10466

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

krypy/deflation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ def estimate_time(self, nsteps, ndefl, deflweight=1.0):
213213
"M": ndefl,
214214
"Ml": ndefl,
215215
"Mr": ndefl,
216-
"ip_B": (
217-
ndefl * (ndefl + 1) / 2 + ndefl ** 2 + 2 * ndefl * solver_ops["Ml"]
218-
),
216+
"ip_B": (ndefl * (ndefl + 1) / 2 + ndefl**2 + 2 * ndefl * solver_ops["Ml"]),
219217
"axpy": (
220218
ndefl * (ndefl + 1) / 2
221219
+ ndefl * ndefl
@@ -670,7 +668,7 @@ def _auto():
670668
)[0:-1]
671669

672670
def compute_pseudo(delta_log):
673-
delta = 10 ** delta_log
671+
delta = 10**delta_log
674672
if ls_small.self_adjoint:
675673
# pseudospectrum are intervals
676674
pseudo_intervals = utils.Intervals(

krypy/linsys.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ def operations(nsteps):
510510
)
511511

512512
def _solve(self):
513-
"""Abstract method that solves the linear system.
514-
"""
513+
"""Abstract method that solves the linear system."""
515514
raise NotImplementedError(
516515
"_solve has to be overridden by " "the derived solver class."
517516
)
@@ -597,7 +596,7 @@ def _solve(self):
597596
yk = numpy.zeros((N, 1), dtype=self.dtype)
598597

599598
# square of the old residual norm
600-
self.rhos = rhos = [self.MMlr0_norm ** 2]
599+
self.rhos = rhos = [self.MMlr0_norm**2]
601600

602601
# will be updated by _compute_rkn if explicit_residual is True
603602
self.Mlrk = self.Mlr0.copy()
@@ -662,7 +661,7 @@ def _solve(self):
662661

663662
# compute norm and rho_new
664663
MMlrk_norm = utils.norm(self.Mlrk, self.MMlrk, ip_B=self.linear_system.ip_B)
665-
rhos.append(MMlrk_norm ** 2)
664+
rhos.append(MMlrk_norm**2)
666665

667666
# compute Lanczos vector + new subdiagonal element
668667
if self.store_arnoldi:
@@ -680,7 +679,7 @@ def _solve(self):
680679
# update rho_new if it was updated in _compute_norms
681680
if rkn is not None:
682681
# new rho
683-
rhos[-1] = rkn ** 2
682+
rhos[-1] = rkn**2
684683

685684
self.iter += 1
686685

krypy/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def __init__(self, x):
359359
alpha = 1 if gamma == 0 else gamma / xnorm
360360
else:
361361
sigma = numpy.linalg.norm(v[1:], 2)
362-
xnorm = numpy.sqrt(numpy.abs(gamma) ** 2 + sigma ** 2)
362+
xnorm = numpy.sqrt(numpy.abs(gamma) ** 2 + sigma**2)
363363

364364
# is x the multiple of first unit vector?
365365
if sigma == 0:
@@ -376,7 +376,7 @@ def __init__(self, x):
376376
alpha = -gamma / numpy.abs(gamma)
377377

378378
self.xnorm = xnorm
379-
self.v = v / numpy.sqrt(numpy.abs(v[0]) ** 2 + sigma ** 2)
379+
self.v = v / numpy.sqrt(numpy.abs(v[0]) ** 2 + sigma**2)
380380
self.alpha = alpha
381381
self.beta = beta
382382

@@ -771,7 +771,7 @@ def angles(F, G, ip_B=None, compute_vectors=False):
771771
else:
772772
Y, s, Z = scipy.linalg.svd(inner(QF, QG, ip_B=ip_B))
773773
Vcos = numpy.dot(QG, Z.T.conj())
774-
n_large = numpy.flatnonzero((s ** 2) < 0.5).shape[0]
774+
n_large = numpy.flatnonzero((s**2) < 0.5).shape[0]
775775
n_small = s.shape[0] - n_large
776776
theta = numpy.hstack(
777777
[
@@ -1913,7 +1913,7 @@ def __init__(self, evals, exclude_zeros=False):
19131913

19141914
def eval_step(self, step):
19151915
"""Evaluate bound for given step."""
1916-
return 2 * self.base ** step
1916+
return 2 * self.base**step
19171917

19181918
def get_step(self, tol):
19191919
"""Return step at which bound falls below tolerance."""
@@ -2003,7 +2003,7 @@ def eval_step(self, step):
20032003
return 2 * self.base ** numpy.floor(step / 2.0)
20042004

20052005
def get_step(self, tol):
2006-
"""Return step at which bound falls below tolerance. """
2006+
"""Return step at which bound falls below tolerance."""
20072007
return 2 * numpy.log(tol / 2.0) / numpy.log(self.base)
20082008

20092009

test/test_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def assert_arnoldi(
504504
arnoldi_res = MAV - numpy.dot(V, H)
505505
arnoldi_resn = krypy.utils.norm(arnoldi_res, ip_B=ip_B)
506506
# inequality (2.3) in [1]
507-
arnoldi_tol = arnoldi_const * k * (N ** 1.5) * eps * An
507+
arnoldi_tol = arnoldi_const * k * (N**1.5) * eps * An
508508
assert arnoldi_resn <= arnoldi_tol
509509

510510
# check orthogonality by measuring \| I - <V,V> \|_2
@@ -514,7 +514,7 @@ def assert_arnoldi(
514514
ortho_res = numpy.eye(V.shape[1]) - krypy.utils.inner(V, V, ip_B=ip_B)
515515
ortho_resn = numpy.linalg.norm(ortho_res, 2)
516516
if ortho == "house":
517-
ortho_tol = ortho_const * (k ** 1.5) * N * eps # inequality (2.4) in [1]
517+
ortho_tol = ortho_const * (k**1.5) * N * eps # inequality (2.4) in [1]
518518
else:
519519
vAV_singvals = scipy.linalg.svd(
520520
numpy.column_stack([V[:, [0]], (MAV[:, :-1] if invariant else MAV)]),
@@ -525,7 +525,7 @@ def assert_arnoldi(
525525
else:
526526
# inequality (2.5) in [1]
527527
ortho_tol = (
528-
ortho_const * (k ** 2) * N * eps * vAV_singvals[0] / vAV_singvals[-1]
528+
ortho_const * (k**2) * N * eps * vAV_singvals[0] / vAV_singvals[-1]
529529
)
530530
# mgs or lanczos is not able to detect an invariant subspace reliably
531531
if (ortho != "mgs" or N != k) and ortho != "lanczos":

0 commit comments

Comments
 (0)