Skip to content

Commit 60b2dfd

Browse files
author
Kevin Chen
committed
Changed gram back to not needed 'deepcopy' now that slycot sb03md is fixed. Also added a unittest to check that an exception is raised when gram is give something other than StateSpace object.
Lauren Padilla <lpadilla@princeton.edu>
1 parent 44787eb commit 60b2dfd

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line.
55
SPHINXOPTS =
6-
SPHINXBUILD = /Users/steve/CODES/Sphinx-1.0.6/sphinx-build.py
6+
SPHINXBUILD = /Applications/Sphinx-1.0.6/sphinx-build.py
77
PAPER =
88
BUILDDIR = _build
99

src/TestStatefbk.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ def testGramWo2(self):
7373
Wo = gram(sys,'o')
7474
np.testing.assert_array_almost_equal(Wo, Wotrue)
7575

76+
def testGramsys(self):
77+
num =[1.]
78+
den = [1., 1., 1.]
79+
sys = tf(num,den)
80+
self.assertRaises(ValueError, gram, sys, 'o')
81+
self.assertRaises(ValueError, gram, sys, 'c')
7682

7783
if __name__ == '__main__':
7884
unittest.main()

src/statefbk.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import numpy as np
4444
import ctrlutil
4545
from exception import *
46+
import statesp
4647

4748
# Pole placement
4849
def place(A, B, p):
@@ -255,6 +256,7 @@ def gram(sys,type):
255256
Raises
256257
------
257258
ValueError
259+
if system is not instance of StateSpace class
258260
if `type` is not 'c' or 'o'
259261
if system is unstable (sys.A has eigenvalues not in left half plane)
260262
ImportError
@@ -267,10 +269,10 @@ def gram(sys,type):
267269
268270
"""
269271

270-
from copy import deepcopy
271-
272-
#Check for ss system object, need a utility for this?
273-
272+
#Check for ss system object
273+
if not isinstance(sys,statesp.StateSpace):
274+
raise ValueError, "System must be StateSpace!"
275+
274276
#TODO: Check for continous or discrete, only continuous supported right now
275277
# if isCont():
276278
# dico = 'C'
@@ -302,7 +304,7 @@ def gram(sys,type):
302304
raise ControlSlycot("can't find slycot module 'sb03md'")
303305
n = sys.states
304306
U = np.zeros((n,n))
305-
A = deepcopy(sys.A)
307+
A = sys.A
306308
out = sb03md(n, C, A, U, dico, 'X', 'N', trana)
307309
gram = out[0]
308310
return gram

0 commit comments

Comments
 (0)