-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0b3018
commit be9af7f
Showing
11 changed files
with
139 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.coverage | ||
coverage.xml | ||
*.pyc | ||
*.so | ||
build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ clean: | |
rm -rf *.dSYM | ||
|
||
test: | ||
cd ..;nosetests | ||
cd ../..;pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
import unittest | ||
import numpy as np | ||
import pytest | ||
import scipy.sparse as sp | ||
from pymatsolver import Diagonal | ||
|
||
TOL = 1e-12 | ||
|
||
|
||
class TestBasic(unittest.TestCase): | ||
def test_DiagonalSolver(): | ||
|
||
def test_DiagonalSolver(self): | ||
A = sp.identity(5)*2.0 | ||
rhs = np.c_[np.arange(1, 6), np.arange(2, 11, 2)] | ||
X = Diagonal(A) * rhs | ||
x = Diagonal(A) * rhs[:, 0] | ||
|
||
A = sp.identity(5)*2.0 | ||
rhs = np.c_[np.arange(1, 6), np.arange(2, 11, 2)] | ||
X = Diagonal(A) * rhs | ||
x = Diagonal(A) * rhs[:, 0] | ||
sol = rhs/2.0 | ||
|
||
sol = rhs/2.0 | ||
with pytest.raises(TypeError): | ||
Diagonal(A, check_accuracy=np.array([1, 2, 3])) | ||
with pytest.raises(TypeError): | ||
Diagonal(A, accuracy_tol=0) | ||
|
||
with self.assertRaises(TypeError): | ||
Diagonal(A, check_accuracy=np.array([1, 2, 3])) | ||
with self.assertRaises(TypeError): | ||
Diagonal(A, accuracy_tol=0) | ||
|
||
self.assertLess(np.linalg.norm(sol-X, np.inf), TOL) | ||
self.assertLess(np.linalg.norm(sol[:, 0]-x, np.inf), TOL) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
assert np.linalg.norm(sol-X, np.inf) < TOL | ||
assert np.linalg.norm(sol[:, 0]-x, np.inf) < TOL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.