4242# External packages and modules
4343import numpy as np
4444import scipy as sp
45- import warnings
4645from . import statesp
46+ from .config import get_ss_return_type
4747from .exception import ControlSlycot , ControlArgument , ControlDimension
4848
4949__all__ = ['ctrb' , 'obsv' , 'gram' , 'place' , 'place_varga' , 'lqr' , 'acker' ]
@@ -220,7 +220,7 @@ def place_varga(A, B, p, dtime=False, alpha=None):
220220 return - F
221221
222222# Contributed by Roberto Bucher <roberto.bucher@supsi.ch>
223- def acker (A , B , poles , return_type = np . matrix ):
223+ def acker (A , B , poles , return_type = None ):
224224 """Pole placement using Ackermann method
225225
226226 Call:
@@ -239,12 +239,6 @@ def acker(A, B, poles, return_type=np.matrix):
239239 Gains such that A - B K has given eigenvalues
240240
241241 """
242- # If return_type is np.matrix, issue a pending deprecation warning
243- if (return_type is np .matrix ):
244- warnings .warn ("Returning numpy.matrix, soon to be deprecated; "
245- "make sure calling code can handle nparray." ,
246- stacklevel = 2 )
247-
248242 # Convert the inputs to matrices (arrays)
249243 a = statesp .ssmatrix (A )
250244 b = statesp .ssmatrix (B )
@@ -265,7 +259,7 @@ def acker(A, B, poles, return_type=np.matrix):
265259 K = np .linalg .solve (ct , pmat )
266260
267261 K = K [- 1 ][:] # Extract the last row
268- return K .view (type = return_type )
262+ return K .view (type = get_ss_return_type ( return_type ) )
269263
270264def lqr (* args , ** keywords ):
271265 """lqr(A, B, Q, R[, N])
@@ -375,7 +369,7 @@ def lqr(*args, **keywords):
375369
376370 return K , S , E
377371
378- def ctrb (A , B , return_type = np . matrix ):
372+ def ctrb (A , B , return_type = None ):
379373 """Controllabilty matrix
380374
381375 Parameters
@@ -396,12 +390,6 @@ def ctrb(A, B, return_type=np.matrix):
396390 >>> C = ctrb(A, B)
397391
398392 """
399- # If return_type is np.matrix, issue a pending deprecation warning
400- if (return_type is np .matrix ):
401- warnings .warn ("Returning numpy.matrix, soon to be deprecated; "
402- "make sure calling code can handle nparray." ,
403- stacklevel = 2 )
404-
405393 # Convert input parameters to matrices (if they aren't already)
406394 amat = statesp .ssmatrix (A )
407395 bmat = statesp .ssmatrix (B )
@@ -412,10 +400,10 @@ def ctrb(A, B, return_type=np.matrix):
412400 for i in range (1 , n )])
413401
414402 # Return the observability matrix in the desired type
415- return ctrb .view (type = return_type )
403+ return ctrb .view (type = get_ss_return_type ( return_type ) )
416404
417405
418- def obsv (A , C , return_type = np . matrix ):
406+ def obsv (A , C , return_type = None ):
419407 """Observability matrix
420408
421409 Parameters
@@ -436,12 +424,6 @@ def obsv(A, C, return_type=np.matrix):
436424 >>> O = obsv(A, C)
437425
438426 """
439- # If return_type is np.matrix, issue a pending deprecation warning
440- if (return_type is np .matrix ):
441- warnings .warn ("Returning numpy.matrix, soon to be deprecated; "
442- "make sure calling code can handle nparray." ,
443- stacklevel = 2 )
444-
445427 # Convert input parameters to matrices (if they aren't already)
446428 amat = statesp .ssmatrix (A )
447429 cmat = statesp .ssmatrix (C )
@@ -452,10 +434,10 @@ def obsv(A, C, return_type=np.matrix):
452434 for i in range (1 , n )])
453435
454436 # Return the observability matrix in the desired type
455- return obsv .view (type = return_type )
437+ return obsv .view (type = get_ss_return_type ( return_type ) )
456438
457439
458- def gram (sys , type , return_type = np . matrix ):
440+ def gram (sys , type , return_type = None ):
459441 """Gramian (controllability or observability)
460442
461443 Parameters
@@ -492,12 +474,6 @@ def gram(sys, type, return_type=np.matrix):
492474 >>> Ro = gram(sys,'of'), where Wo=Ro'*Ro
493475
494476 """
495- # If return_type is np.matrix, issue a pending deprecation warning
496- if (return_type is np .matrix ):
497- warnings .warn ("Returning numpy.matrix, soon to be deprecated; "
498- "make sure calling code can handle nparray." ,
499- stacklevel = 2 )
500-
501477 #Check for ss system object
502478 if not isinstance (sys ,statesp .StateSpace ):
503479 raise ValueError ("System must be StateSpace!" )
@@ -535,7 +511,7 @@ def gram(sys, type, return_type=np.matrix):
535511 A = np .array (sys .A ) # convert to NumPy array for slycot
536512 X ,scale ,sep ,ferr ,w = sb03md (n , C , A , U , dico , job = 'X' , fact = 'N' , trana = tra )
537513 gram = X
538- return gram .view (type = return_type )
514+ return gram .view (type = get_ss_return_type ( return_type ) )
539515
540516 elif type == 'cf' or type == 'of' :
541517 #Compute cholesky factored gramian from slycot routine sb03od
@@ -558,4 +534,4 @@ def gram(sys, type, return_type=np.matrix):
558534 C [0 :n ,0 :m ] = sys .C .transpose ()
559535 X ,scale ,w = sb03od (n , m , A , Q , C .transpose (), dico , fact = 'N' , trans = tra )
560536 gram = X
561- return gram .view (type = return_type )
537+ return gram .view (type = get_ss_return_type ( return_type ) )
0 commit comments