Skip to content

Commit

Permalink
Cleaning up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peekxc committed Dec 21, 2023
1 parent 1015637 commit 7969574
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions tests/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,25 @@ def test_trace_mf():
tr_est = hutch(A, fun="identity", maxiter=100, num_threads=1, seed = 5)
tr_true = A.trace()
assert np.isclose(tr_est, tr_true, atol=tr_true*0.05)

## TODO
tr_est, info = hutch(A, fun=lambda x: x, maxiter=100, seed=5, num_threads=1, info=True)
assert np.isclose(tr_est, tr_true, atol=tr_true*0.05)
for s in range(15000):
est, info = hutch(A, fun="identity", deg=2, maxiter=200, num_threads=1, seed=591, info=True)
assert not np.isnan(est)
for s in range(15000):
est, info = hutch(A, fun="identity", deg=20, maxiter=200, num_threads=8, seed=-1, info=True)
assert not np.isnan(est)

from primate.operator import matrix_function
M = matrix_function(A, fun="identity", deg=20)
for s in range(15000):
v0 = np.random.choice([-1, 1], size=M.shape[0])
assert not np.isnan(M.quad(v0))
M.krylov_basis
M.ncv
M.deg
M._alpha
M._beta
M.matvec(-v0)

## TODO
# tr_est, info = hutch(A, fun=lambda x: x, maxiter=100, seed=5, num_threads=1, info=True)
# assert np.isclose(tr_est, tr_true, atol=tr_true*0.05)
# for s in range(15000):
# est, info = hutch(A, fun="identity", deg=2, maxiter=200, num_threads=1, seed=591, info=True)
# assert not np.isnan(est)
# for s in range(15000):
# est, info = hutch(A, fun="identity", deg=20, maxiter=200, num_threads=8, seed=-1, info=True)
# assert not np.isnan(est)

# from primate.operator import matrix_function
# M = matrix_function(A, fun="identity", deg=20)
# for s in range(15000):
# v0 = np.random.choice([-1, 1], size=M.shape[0])
# assert not np.isnan(M.quad(v0))


# from primate.diagonalize import lanczos
# lanczos(A, v0=v0, rtol=M.rtol, deg=M.deg, orth=M.orth)
Expand Down

0 comments on commit 7969574

Please sign in to comment.