Skip to content

Commit

Permalink
Working out matrix function more
Browse files Browse the repository at this point in the history
  • Loading branch information
peekxc committed Dec 12, 2023
1 parent 34563a7 commit 2b6f8bd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
25 changes: 14 additions & 11 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,29 @@ windows_task:
windows_container:
image: cirrusci/windowsservercore:2019
only_if: changesInclude('.cirrus.yml', '**.{h,cpp,py}')
setup_script: |
setup_python_script: |
choco install -y python311
setup_clang_script: |
choco install -y llvm --params "clang;compiler=clang" --version 17.0.0
clang --version
env:
PATH: '%PATH%;C:\ProgramData\chocolatey\bin;C:\Python311'
dependencies_script: |
bash tools/cibw_windows.sh
before_script: |
PATH: '%PATH%;C:\ProgramData\chocolatey\bin;C:\Python311;C:\Program Files\LLVM\bin;'
CXX: clang++
CC: clang
pip_depends_script: |
python -m pip install --upgrade pip
python -m pip install build pytest pytest-cov pytest-benchmark
build_script: |
build_pkg_script: |
python -m pip install . --verbose
test_script: |
test_pkg_script: |
python -m pytest tests/ --cov=primate --benchmark-skip
uninstall_script: |
uninstall_pkg_script: |
python -m pip uninstall primate -y
wheel_script: |
build_wheel_script: |
python -m build
install_script: |
install_wheel_script: |
python -m pip install dist/primate*.whl
test_post_script: |
test_wheel_script: |
python -m pytest tests/ --cov=primate --benchmark-skip
coverage report -m
Expand Down
26 changes: 22 additions & 4 deletions tests/test_vapprox.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,27 @@ def test_mf_api():
A_sparse = csc_array(symmetric(n, psd = True), dtype=np.float32)
M = matrix_function(A_sparse)
v0 = np.random.normal(size=n)
assert np.max(np.abs(M.matvec(v0) - A_sparse @ v0)) <= 1e-6
assert True
assert np.max(np.abs(M.matvec(v0) - A_sparse @ v0)) <= 1e-6, "MF matvec doesn't match identity"
assert M.dtype == np.float32, "dtype mismatch"

# from scipy.sparse.linalg import LinearOperator
# assert isinstance(M, LinearOperator)
from scipy.sparse.linalg import eigsh
ew_true = eigsh(A_sparse)[0]
ew_test = eigsh(M)[0]
assert np.allclose(ew_true, ew_test, atol=1e-5), "eigenvalues mismatch / operator doesn't register as respecting LO interface"


# class CustomOperator:
# def __init__(self, A):
# self.A = A
# self.dtype = A.dtype
# self.shape = A.shape
# # def _matvec(self, v):
# # return self.A @ v
# def matvec(self, v):
# return self.A @ v
# # def _matmat(self, V):
# # return self.A @ V
# def matmat(self, V):
# return self.A @ V

# A_op = CustomOperator(A_sparse)

0 comments on commit 2b6f8bd

Please sign in to comment.