Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f214fa8

Browse filesBrowse files
committed
MAINT: also remove assert_equal-usage in .../_isolve/tests/test_iterative.py
1 parent 0f73f92 commit f214fa8
Copy full SHA for f214fa8

File tree

1 file changed

+26
-24
lines changed
Filter options

1 file changed

+26
-24
lines changed

‎scipy/sparse/linalg/_isolve/tests/test_iterative.py

Copy file name to clipboardExpand all lines: scipy/sparse/linalg/_isolve/tests/test_iterative.py
+26-24Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import sys
77
import numpy as np
88

9-
from numpy.testing import (assert_equal, assert_array_equal,
10-
assert_allclose, suppress_warnings)
9+
from numpy.testing import (assert_array_equal, assert_allclose,
10+
suppress_warnings)
1111
import pytest
1212

1313

@@ -197,8 +197,8 @@ def callback(x):
197197

198198
x, info = solver(A, b, x0=x0, tol=tol, maxiter=1, callback=callback)
199199

200-
assert_equal(len(residuals), 1)
201-
assert_equal(info, 1)
200+
assert len(residuals) == 1
201+
assert info == 1
202202

203203

204204
def test_maxiter():
@@ -232,7 +232,7 @@ def check_convergence(solver, case):
232232

233233
assert_array_equal(x0, 0 * b) # ensure that x0 is not overwritten
234234
if solver not in case.nonconvergence:
235-
assert_equal(info, 0)
235+
assert info == 0
236236
assert_normclose(A @ x, b, tol=tol)
237237
else:
238238
assert info != 0
@@ -274,15 +274,15 @@ def identity(b, which=None):
274274
x, info = solver(A, b, M1=precond, M2=precond, x0=x0, tol=tol)
275275
else:
276276
x, info = solver(A, b, M=precond, x0=x0, tol=tol)
277-
assert_equal(info, 0)
277+
assert info == 0
278278
assert_normclose(A @ x, b, tol)
279279

280280
A = aslinearoperator(A)
281281
A.psolve = identity
282282
A.rpsolve = identity
283283

284284
x, info = solver(A, b, x0=x0, tol=tol)
285-
assert_equal(info, 0)
285+
assert info == 0
286286
assert_normclose(A @ x, b, tol=tol)
287287

288288

@@ -333,7 +333,7 @@ def rmatvec(b):
333333
matvec_count = [0]
334334
x, info = solver(A, b, M=precond, x0=x0, tol=tol)
335335

336-
assert_equal(info, 0)
336+
assert info == 0
337337
assert_normclose(case.A @ x, b, tol)
338338

339339
# Solution should be nearly instant
@@ -365,7 +365,7 @@ def _check_reentrancy(solver, is_reentrant):
365365
def matvec(x):
366366
A = np.array([[1.0, 0, 0], [0, 2.0, 0], [0, 0, 3.0]])
367367
y, info = solver(A, x)
368-
assert_equal(info, 0)
368+
assert info == 0
369369
return y
370370
b = np.array([1, 1. / 2, 1. / 3])
371371
op = LinearOperator((3, 3), matvec=matvec, rmatvec=matvec,
@@ -375,7 +375,7 @@ def matvec(x):
375375
pytest.raises(RuntimeError, solver, op, b)
376376
else:
377377
y, info = solver(op, b)
378-
assert_equal(info, 0)
378+
assert info == 0
379379
assert_allclose(y, [1, 1, 1])
380380

381381

@@ -411,8 +411,8 @@ def test_atol(solver):
411411
x, info = solver(A, b, M1=M, M2=M2, tol=tol, atol=atol)
412412
else:
413413
x, info = solver(A, b, M=M, tol=tol, atol=atol)
414-
assert_equal(info, 0)
415414

415+
assert info == 0
416416
residual = A @ x - b
417417
err = np.linalg.norm(residual)
418418
atol2 = tol * b_norm
@@ -436,11 +436,11 @@ def test_zero_rhs(solver):
436436
sup.filter(DeprecationWarning, ".*called without specifying.*")
437437

438438
x, info = solver(A, b, tol=tol)
439-
assert_equal(info, 0)
439+
assert info == 0
440440
assert_allclose(x, 0., atol=1e-15)
441441

442442
x, info = solver(A, b, tol=tol, x0=ones(10))
443-
assert_equal(info, 0)
443+
assert info == 0
444444
assert_allclose(x, 0., atol=tol)
445445

446446
if solver is not minres:
@@ -449,11 +449,11 @@ def test_zero_rhs(solver):
449449
assert_allclose(x, 0)
450450

451451
x, info = solver(A, b, tol=tol, atol=tol)
452-
assert_equal(info, 0)
452+
assert info == 0
453453
assert_allclose(x, 0, atol=1e-300)
454454

455455
x, info = solver(A, b, tol=tol, atol=0)
456-
assert_equal(info, 0)
456+
assert info == 0
457457
assert_allclose(x, 0, atol=1e-300)
458458

459459

@@ -516,11 +516,11 @@ def test_x0_working(solver):
516516
kw = dict(atol=0, tol=1e-6)
517517

518518
x, info = solver(A, b, **kw)
519-
assert_equal(info, 0)
519+
assert info == 0
520520
assert np.linalg.norm(A @ x - b) <= 1e-6 * np.linalg.norm(b)
521521

522522
x, info = solver(A, b, x0=x0, **kw)
523-
assert_equal(info, 0)
523+
assert info == 0
524524
assert np.linalg.norm(A @ x - b) <= 2e-6 * np.linalg.norm(b)
525525

526526

@@ -539,7 +539,7 @@ def test_x0_equals_Mb(solver):
539539
x, info = solver(A, b, x0=x0, tol=tol)
540540

541541
assert_array_equal(x0, 'Mb') # ensure that x0 is not overwritten
542-
assert_equal(info, 0)
542+
assert info == 0
543543
assert_normclose(A @ x, b, tol=tol)
544544

545545

@@ -556,12 +556,14 @@ def cb(x):
556556
x, info = solver(A, b, callback=cb, show=True)
557557
out, err = capsys.readouterr()
558558
if i == 20: # Asymmetric and Positive Definite
559-
assert_equal(out, f"{solverstring}: Linear solve not converged "
560-
f"due to reach MAXIT iterations {count[0]}\n")
559+
exp = (f"{solverstring}: Linear solve not converged "
560+
f"due to reach MAXIT iterations {count[0]}\n")
561+
assert out == exp
561562
else: # 1-D Poisson equations
562-
assert_equal(out, f"{solverstring}: Linear solve converged due to "
563-
f"reach TOL iterations {count[0]}\n")
564-
assert_equal(err, '')
563+
exp = (f"{solverstring}: Linear solve converged due to "
564+
f"reach TOL iterations {count[0]}\n")
565+
assert out == exp
566+
assert err == ""
565567

566568

567569
# -----------------------------------------------------------------------------
@@ -607,7 +609,7 @@ def UT_solve(b):
607609
sup.filter(DeprecationWarning, ".*called without specifying.*")
608610
x, info = qmr(A, b, tol=1e-8, maxiter=15, M1=M1, M2=M2)
609611

610-
assert_equal(info, 0)
612+
assert info == 0
611613
assert_normclose(A @ x, b, tol=1e-8)
612614

613615

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.