-
Notifications
You must be signed in to change notification settings - Fork 45
fix invalid variable usages from wrapper outputs #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5896144
fix invalid variable usages from wrapper outputs
594b3db
delete unused mathematical.pyf
abb9f79
fix math
af8927f
only return complex list when necessary, add unittest for mb05md
93c34db
remove var porm
961f172
fix docstring of mb05md()
6572201
clean up pep8 issues in mb05md
ae14a6b
clean more pep8 issues, fix mb05nd, add unittest for mb05nd
2bac74e
fix CMakeLists, remove stub test_2
2a3c98c
make test_mb.py executable
8bc7a4e
add unittests for mc01td, fix dp constraint
b1205d4
fix typo in test_mb
793625d
Merge branch 'master' into fix-unused-vars
bnavigator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # test_mb.py - test suite for linear algebra commands | ||
| # bnavigator <code@bnavigator.de>, Aug 2019 | ||
|
|
||
| import unittest | ||
| import numpy as np | ||
|
|
||
| from slycot import mb05md, mb05nd | ||
|
|
||
| from numpy.testing import assert_allclose | ||
|
|
||
|
|
||
| class test_mb(unittest.TestCase): | ||
|
|
||
| def test_mb05md(self): | ||
| """ test_mb05md: verify Matrix exponential with slicot doc example | ||
| data from http://slicot.org/objects/software/shared/doc/MB05MD.html | ||
| """ | ||
| A = np.array([[ 0.5, 0., 2.3, -2.6], | ||
| [ 0., 0.5, -1.4, -0.7], | ||
| [ 2.3, -1.4, 0.5, 0.0], | ||
| [-2.6, -0.7, 0.0, 0.5]]) | ||
| delta = 1.0 | ||
| Ar_ref = np.array([[ 26.8551, -3.2824, 18.7409, -19.4430], | ||
| [ -3.2824, 4.3474, -5.1848, 0.2700], | ||
| [ 18.7409, -5.1848, 15.6012, -11.7228], | ||
| [ -19.4430, 0.2700, -11.7228, 15.6012]]) | ||
| Vr_ref = np.array([[-0.7, 0.7, 0.1, -0.1], | ||
| [ 0.1, -0.1, 0.7, -0.7], | ||
| [ 0.5, 0.5, 0.5, 0.5], | ||
| [-0.5, -0.5, 0.5, 0.5]]) | ||
| Yr_ref = np.array([[ -0.0349, 0.0050, 0.0249, -0.0249], | ||
| [ 38.2187, -5.4598, 27.2991, -27.2991], | ||
| [ 0.0368, 0.2575, 0.1839, 0.1839], | ||
| [ -0.7389, -5.1723, 3.6945, 3.6945]]) | ||
| VAL_ref = np.array([-3., 4., -1., 2.]) | ||
| (Ar, Vr, Yr, VAL) = mb05md(A, delta) | ||
|
|
||
| assert_allclose(Ar, Ar_ref, atol=0.0001) | ||
|
|
||
| # Order of eigenvalues is not guaranteed, so we check them one by one. | ||
| for i, e in enumerate(VAL): | ||
| erow = np.ones(VAL.shape)*e | ||
| i_ref = np.isclose(erow, VAL_ref) | ||
| self.assertTrue(any(i_ref), | ||
| msg="eigenvalue {} not expected".format(e)) | ||
| # Eigenvectors can have different scaling. | ||
| vr_ref = Vr_ref[:, i_ref]*Vr[0, i]/Vr_ref[0, i_ref][0] | ||
| assert_allclose(Vr[:, (i,)], vr_ref, atol=0.0001) | ||
|
|
||
| assert_allclose(np.dot(Vr, Yr), np.dot(Vr_ref, Yr_ref), atol=0.0001) | ||
|
|
||
| def test_mb05nd(self): | ||
| """ test_mb05nd: verify Matrix exponential and integral | ||
| data from http://slicot.org/objects/software/shared/doc/MB05ND.html | ||
| """ | ||
| A = np.array([[5.0, 4.0, 3.0, 2.0, 1.0], | ||
| [1.0, 6.0, 0.0, 4.0, 3.0], | ||
| [2.0, 0.0, 7.0, 6.0, 5.0], | ||
| [1.0, 3.0, 1.0, 8.0, 7.0], | ||
| [2.0, 5.0, 7.0, 1.0, 9.0]]) | ||
| delta = 0.1 | ||
| F_ref = np.array([[1.8391, 0.9476, 0.7920, 0.8216, 0.7811], | ||
| [0.3359, 2.2262, 0.4013, 1.0078, 1.0957], | ||
| [0.6335, 0.6776, 2.6933, 1.6155, 1.8502], | ||
| [0.4804, 1.1561, 0.9110, 2.7461, 2.0854], | ||
| [0.7105, 1.4244, 1.8835, 1.0966, 3.4134]]) | ||
| H_ref = np.array([[0.1347, 0.0352, 0.0284, 0.0272, 0.0231], | ||
| [0.0114, 0.1477, 0.0104, 0.0369, 0.0368], | ||
| [0.0218, 0.0178, 0.1624, 0.0580, 0.0619], | ||
| [0.0152, 0.0385, 0.0267, 0.1660, 0.0732], | ||
| [0.0240, 0.0503, 0.0679, 0.0317, 0.1863]]) | ||
|
|
||
| (F, H) = mb05nd(A, delta) | ||
|
|
||
| assert_allclose(F, F_ref, atol=0.0001) | ||
| assert_allclose(H, H_ref, atol=0.0001) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # test_mc.py - test suite for polynomial and rational function manipulation | ||
| # bnavigator <code@bnavigator.de>, Aug 2019 | ||
|
|
||
| import unittest | ||
| import warnings | ||
|
|
||
| from slycot import mc01td | ||
|
|
||
|
|
||
| class test_mc(unittest.TestCase): | ||
|
|
||
| def test_mc01td(self): | ||
| """ test_mc01td: doc example | ||
| data from http://slicot.org/objects/software/shared/doc/MC01TD.html | ||
| """ | ||
| (dp, stable, nz) = mc01td('C', 4, [2, 0, 1, -1, 1]) | ||
| self.assertEqual(dp, 4) | ||
| self.assertEqual(stable, 0) | ||
| self.assertEqual(nz, 2) | ||
|
|
||
| def test_mc01td_D(self): | ||
| """ test_mc01td_D: test discrete option """ | ||
| (dp, stable, nz) = mc01td('D', 3, [1, 2, 3, 4]) | ||
| self.assertEqual(dp, 3) | ||
| self.assertEqual(stable, 1) | ||
| self.assertEqual(nz, 0) | ||
| (dp, stable, nz) = mc01td('D', 3, [4, 3, 2, 1]) | ||
| self.assertEqual(dp, 3) | ||
| self.assertEqual(stable, 0) | ||
| self.assertEqual(nz, 3) | ||
|
|
||
| def test_mc01td_warnings(self): | ||
| """ test_mc01td_warnings: Test warnings """ | ||
| T = [([0, 0], "entry P(x) is the zero polynomial."), | ||
| ([0, 1], "P(x) may have zeros very close to stability boundary."), | ||
| ([1, 0], "The degree of P(x) has been reduced to 0")] | ||
| for P, m in T: | ||
| with warnings.catch_warnings(record=True) as w: | ||
| (dp, stable, nz) = mc01td('C', len(P)-1, P) | ||
| self.assertEqual(str(w[0].message), m) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.