|
1 |
| -#!/usr/bin/env python |
2 |
| -# |
3 |
| -# nichols_test.py - test Nichols plot |
4 |
| -# RMM, 31 Mar 2011 |
| 1 | +"""nichols_test.py - test Nichols plot |
5 | 2 |
|
6 |
| -import unittest |
7 |
| -import numpy as np |
8 |
| -from control.matlab import * |
| 3 | +RMM, 31 Mar 2011 |
| 4 | +""" |
9 | 5 |
|
10 |
| -class TestStateSpace(unittest.TestCase): |
11 |
| - """Tests for the Nichols plots.""" |
| 6 | +import pytest |
12 | 7 |
|
13 |
| - def setUp(self): |
14 |
| - """Set up a system to test operations on.""" |
| 8 | +from control import StateSpace, nichols_plot, nichols |
15 | 9 |
|
16 |
| - A = [[-3., 4., 2.], [-1., -3., 0.], [2., 5., 3.]] |
17 |
| - B = [[1.], [-3.], [-2.]] |
18 |
| - C = [[4., 2., -3.]] |
19 |
| - D = [[0.]] |
20 | 10 |
|
21 |
| - self.sys = StateSpace(A, B, C, D) |
| 11 | +@pytest.fixture() |
| 12 | +def tsys(): |
| 13 | + """Set up a system to test operations on.""" |
| 14 | + A = [[-3., 4., 2.], [-1., -3., 0.], [2., 5., 3.]] |
| 15 | + B = [[1.], [-3.], [-2.]] |
| 16 | + C = [[4., 2., -3.]] |
| 17 | + D = [[0.]] |
| 18 | + return StateSpace(A, B, C, D) |
22 | 19 |
|
23 |
| - def testNicholsPlain(self): |
24 |
| - """Generate a Nichols plot.""" |
25 |
| - nichols(self.sys) |
26 | 20 |
|
27 |
| - def testNgrid(self): |
28 |
| - """Generate a Nichols plot.""" |
29 |
| - nichols(self.sys, grid=False) |
30 |
| - ngrid() |
| 21 | +def test_nichols(tsys, mplcleanup): |
| 22 | + """Generate a Nichols plot.""" |
| 23 | + nichols_plot(tsys) |
31 | 24 |
|
32 | 25 |
|
33 |
| -if __name__ == "__main__": |
34 |
| - unittest.main() |
| 26 | +def test_nicholds_alias(tsys, mplcleanup): |
| 27 | + """Test the control.nichols alias and the grid=False parameter""" |
| 28 | + nichols(tsys, grid=False) |
0 commit comments