-
Notifications
You must be signed in to change notification settings - Fork 438
BugFix: tf2ss now handles static gains #129
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,6 +184,28 @@ def testConvertMIMO(self): | |
if (not slycot_check()): | ||
self.assertRaises(TypeError, control.tf2ss, tfcn) | ||
|
||
def testTf2ssStaticSiso(self): | ||
"""Regression: tf2ss for SISO static gain""" | ||
import control | ||
gsiso = control.tf2ss(control.tf(23, 46)) | ||
self.assertEqual(0, gsiso.states) | ||
self.assertEqual(1, gsiso.inputs) | ||
self.assertEqual(1, gsiso.outputs) | ||
# in all cases ratios are exactly representable, so assert_array_equal is fine | ||
np.testing.assert_array_equal([[0.5]], gsiso.D) | ||
|
||
def testTf2ssStaticMimo(self): | ||
"""Regression: tf2ss for MIMO static gain""" | ||
import control | ||
# 2x3 TFM | ||
gmimo = control.tf2ss(control.tf([[ [23], [3], [5] ], [ [-1], [0.125], [101.3] ]], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did you select these coefficients? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an arbitrary selection of numbers over a (small) range of magnitudes and signs; in all cases the ratios are exactly representable with low precision (see d just below), so I could use np.assert_array_equal(). |
||
[[ [46], [0.1], [80] ], [ [2], [-0.1], [1] ]])) | ||
self.assertEqual(0, gmimo.states) | ||
self.assertEqual(3, gmimo.inputs) | ||
self.assertEqual(2, gmimo.outputs) | ||
d = np.matrix([[0.5, 30, 0.0625], [-0.5, -1.25, 101.3]]) | ||
np.testing.assert_array_equal(d, gmimo.D) | ||
|
||
|
||
def suite(): | ||
return unittest.TestLoader().loadTestsFromTestCase(TestConvert) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "dimenations" be "dimensions"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't take the credit for this one, the comment was there already ;). Not sure it's applicable anymore: the check that sys.inputs and sys.outputs are both 1 implies that squeeze will bring num and den to 1-D?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. The comment is obsolete after the addition in commit c90a399 of the check that sys.inputs = sys.outputs = 1.
I am planning to review and perform maintenance on documentation and code comments, so I can delete this comment at that time.