-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor all pytest of analysis.py routines
- Loading branch information
1 parent
63caadf
commit a8c3e63
Showing
19 changed files
with
395 additions
and
148 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
""" | ||
Test ab01 wrappers | ||
@author: bnavigator | ||
""" | ||
|
||
from numpy import array | ||
from numpy.testing import assert_allclose, assert_equal | ||
from scipy.linalg.lapack import dorgqr | ||
|
||
from slycot.analysis import ab01nd | ||
|
||
|
||
class Test_ab01nd: | ||
|
||
def test_ab01nd(self): | ||
"""SLICOT doc example | ||
http://slicot.org/objects/software/shared/doc/AB01ND.html""" | ||
|
||
# Example program data | ||
n = 3 | ||
m = 2 | ||
tol = 0.0 | ||
|
||
A = array([[-1., 0., 0.], | ||
[-2., -2., -2.], | ||
[-1., 0., -3.]]) | ||
B = array([[1., 0.], | ||
[0, 2.], | ||
[0., 1.]]) | ||
|
||
for jobz in ['N', 'I', 'F']: | ||
Ac, Bc, ncont, indcon, nblk, Z, tau = ab01nd(n, m, A, B, | ||
jobz=jobz, tol=tol) | ||
|
||
# The transformed state dynamics matrix of a controllable realization | ||
assert_allclose(Ac[:ncont, :ncont], array([[-3.0000, 2.2361], | ||
[ 0.0000, -1.0000]]), | ||
atol=0.0001) | ||
|
||
# and the dimensions of its diagonal blocks are | ||
assert_equal(nblk[:indcon], array([2])) | ||
|
||
# The transformed input/state matrix B of a controllable realization | ||
assert_allclose(Bc[:ncont, :],array([[ 0.0000, -2.2361], | ||
[ 1.0000, 0.0000]]), | ||
atol=0.0001) | ||
|
||
# The controllability index of the transformed system representation | ||
assert indcon == 1 | ||
|
||
if jobz == 'N': | ||
assert Z is None | ||
continue | ||
elif jobz == 'I': | ||
Z_ = Z | ||
elif jobz == 'F': | ||
Z_, _, info = dorgqr(Z, tau) | ||
assert info == 0 | ||
|
||
# The similarity transformation matrix Z | ||
assert_allclose(Z_, array([[ 0.0000, 1.0000, 0.0000], | ||
[-0.8944, 0.0000, -0.4472], | ||
[-0.4472, 0.0000, 0.8944]]), | ||
atol=0.0001) | ||
|
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
|
||
|
||
class Test_ab05md: | ||
|
||
@pytest.mark.skip("not implemented yet, TODO") | ||
def test_ab05md(): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
|
||
from slycot import analysis | ||
from slycot.exceptions import SlycotArithmeticError | ||
|
||
from .test_exceptions import assert_docstring_parse | ||
|
||
|
||
class Test_ab05nd: | ||
|
||
@pytest.mark.parametrize( | ||
'fun, exception_class, erange, checkvars', | ||
((analysis.ab05nd, SlycotArithmeticError, 1, {'p1': 1}),)) | ||
def test_ab_docparse(self, fun, exception_class, erange, checkvars): | ||
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
|
||
|
||
class Test_ab07nd: | ||
|
||
@pytest.mark.skip("not implemented yet, TODO") | ||
def test_ab07nd(): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
|
||
|
||
class Test_ab08nd: | ||
|
||
@pytest.mark.skip("not implemented yet, TODO") | ||
def test_ab08nd(): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
|
||
|
||
class Test_ab08nz: | ||
|
||
@pytest.mark.skip("not implemented yet, TODO") | ||
def test_ab08nz(): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning | ||
|
||
from .test_exceptions import assert_docstring_parse | ||
|
||
|
||
class Test_ab09ad: | ||
|
||
@pytest.mark.parametrize( | ||
'fun, exception_class, erange, checkvars', | ||
((analysis.ab09ad, SlycotArithmeticError, 3, {'dico': 'C'}), | ||
(analysis.ab09ad, SlycotArithmeticError, (2,), {'dico': 'D'}), | ||
(analysis.ab09ad, SlycotResultWarning, ((1, 0), ), {'nr': 3, | ||
'Nr': 2}),)) | ||
def test_ab09ad_docparse(self, fun, exception_class, erange, checkvars): | ||
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars) |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning | ||
|
||
from .test_exceptions import assert_docstring_parse | ||
|
||
|
||
class Test_ab09ax: | ||
|
||
@pytest.mark.parametrize( | ||
'fun, exception_class, erange, checkvars', | ||
((analysis.ab09ax, SlycotArithmeticError, 2, {'dico': 'C'}), | ||
(analysis.ab09ax, SlycotResultWarning, ((1, 0), ), {'nr': 3, 'Nr': 2}),)) | ||
def test_ab09ax_docparse(self, fun, exception_class, erange, checkvars): | ||
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
|
||
|
||
class Test_ab09bd: | ||
|
||
@pytest.mark.skip("not implemented yet, TODO") | ||
def test_ab09bd(): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
|
||
from slycot import analysis | ||
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning | ||
|
||
from .test_exceptions import assert_docstring_parse | ||
|
||
|
||
class Test_ab09md: | ||
|
||
@pytest.mark.parametrize( | ||
'fun, exception_class, erange, checkvars', | ||
((analysis.ab09md, SlycotArithmeticError, 3, {'alpha': -0.1}), | ||
(analysis.ab09md, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3, | ||
'Nr': 2, | ||
'alpha': -0.1}),)) | ||
def test_ab09md_docparse(self, fun, exception_class, erange, checkvars): | ||
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars) |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose, assert_array_equal, assert_equal | ||
from scipy import linalg, signal | ||
|
||
from slycot import analysis | ||
from slycot.exceptions import SlycotArithmeticError, SlycotResultWarning | ||
|
||
from .test_exceptions import assert_docstring_parse | ||
|
||
|
||
class Test_ab09nd: | ||
|
||
@pytest.mark.parametrize( | ||
'fun, exception_class, erange, checkvars', | ||
((analysis.ab09nd, SlycotArithmeticError, 3, {'alpha': -0.1}), | ||
(analysis.ab09nd, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3, | ||
'Nr': 2, | ||
'alpha': -0.1}),)) | ||
def test_ab09nd_docparse(self, fun, exception_class, erange, checkvars): | ||
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars) |
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.