From: <kk...@us...> - 2011-02-08 22:18:17
|
Revision: 102 http://python-control.svn.sourceforge.net/python-control/?rev=102&view=rev Author: kkchen Date: 2011-02-08 22:18:08 +0000 (Tue, 08 Feb 2011) Log Message: ----------- convertTo{StateSpace,TransferFunction} made 'private'. Kevin K. Chen <kk...@pr...> Modified Paths: -------------- branches/control-0.4a/src/TestXferFcn.py branches/control-0.4a/src/bdalg.py branches/control-0.4a/src/matlab.py branches/control-0.4a/src/statesp.py branches/control-0.4a/src/xferfcn.py Modified: branches/control-0.4a/src/TestXferFcn.py =================================================================== --- branches/control-0.4a/src/TestXferFcn.py 2011-02-08 22:18:03 UTC (rev 101) +++ branches/control-0.4a/src/TestXferFcn.py 2011-02-08 22:18:08 UTC (rev 102) @@ -2,7 +2,7 @@ import numpy as np from statesp import StateSpace -from xferfcn import TransferFunction, convertToTransferFunction +from xferfcn import TransferFunction, _convertToTransferFunction import unittest class TestXferFcn(unittest.TestCase): @@ -417,7 +417,7 @@ D = [[1., 0.], [0., 1.], [1., 0.]] sys = StateSpace(A, B, C, D) - tfsys = convertToTransferFunction(sys) + tfsys = _convertToTransferFunction(sys) num = [[np.array([1., -7., 10.]), np.array([-1., 10.])], [np.array([2., -8.]), np.array([1., -2., -8.])], Modified: branches/control-0.4a/src/bdalg.py =================================================================== --- branches/control-0.4a/src/bdalg.py 2011-02-08 22:18:03 UTC (rev 101) +++ branches/control-0.4a/src/bdalg.py 2011-02-08 22:18:08 UTC (rev 102) @@ -211,11 +211,11 @@ # its feedback member function. if isinstance(sys1, (int, long, float, complex)): if isinstance(sys2, tf.TransferFunction): - sys1 = tf.convertToTransferFunction(sys1) + sys1 = tf._convertToTransferFunction(sys1) elif isinstance(sys2, ss.StateSpace): - sys1 = ss.convertToStateSpace(sys1) + sys1 = ss._convertToStateSpace(sys1) else: # sys2 is a scalar. - sys1 = tf.convertToTransferFunction(sys1) - sys2 = tf.convertToTransferFunction(sys2) + sys1 = tf._convertToTransferFunction(sys1) + sys2 = tf._convertToTransferFunction(sys2) return sys1.feedback(sys2, sign) Modified: branches/control-0.4a/src/matlab.py =================================================================== --- branches/control-0.4a/src/matlab.py 2011-02-08 22:18:03 UTC (rev 101) +++ branches/control-0.4a/src/matlab.py 2011-02-08 22:18:08 UTC (rev 102) @@ -67,8 +67,8 @@ # Control system library import ctrlutil import freqplot -from statesp import StateSpace, _rss_generate, convertToStateSpace -from xferfcn import TransferFunction, convertToTransferFunction +from statesp import StateSpace, _rss_generate, _convertToStateSpace +from xferfcn import TransferFunction, _convertToTransferFunction from exception import ControlArgument # Import MATLAB-like functions that can be used as-is @@ -413,12 +413,12 @@ if len(args) == 4: # Assume we were given the A, B, C, D matrix - return convertToTransferFunction(StateSpace(args[0], args[1], args[2], + return _convertToTransferFunction(StateSpace(args[0], args[1], args[2], args[3])) elif len(args) == 1: sys = args[0] if isinstance(sys, StateSpace): - return convertToTransferFunction(sys) + return _convertToTransferFunction(sys) else: raise TypeError("ss2tf(sys): sys must be a StateSpace object. It \ is %s." % type(sys)) @@ -472,13 +472,13 @@ if len(args) == 2: # Assume we were given the num, den - return convertToStateSpace(TransferFunction(args[0], args[1])) + return _convertToStateSpace(TransferFunction(args[0], args[1])) elif len(args) == 1: sys = args[0] if not isinstance(sys, TransferFunction): raise TypeError("tf2ss(sys): sys must be a TransferFunction \ object.") - return convertToStateSpace(sys) + return _convertToStateSpace(sys) else: raise ValueError("Needs 1 or 2 arguments; received %i." % len(args)) Modified: branches/control-0.4a/src/statesp.py =================================================================== --- branches/control-0.4a/src/statesp.py 2011-02-08 22:18:03 UTC (rev 101) +++ branches/control-0.4a/src/statesp.py 2011-02-08 22:18:08 UTC (rev 102) @@ -27,7 +27,7 @@ StateSpace.zero StateSpace.feedback StateSpace.returnScipySignalLti -convertToStateSpace +_convertToStateSpace _rss_generate """ @@ -197,7 +197,7 @@ A, B, C = self.A, self.B, self.C; D = self.D + other; else: - other = convertToStateSpace(other) + other = _convertToStateSpace(other) # Check to make sure the dimensions are OK if ((self.inputs != other.inputs) or @@ -245,7 +245,7 @@ C = self.C * other D = self.D * other else: - other = convertToStateSpace(other) + other = _convertToStateSpace(other) # Check to make sure the dimensions are OK if self.inputs != other.outputs: @@ -357,7 +357,7 @@ def feedback(self, other, sign=-1): """Feedback interconnection between two LTI systems.""" - other = convertToStateSpace(other) + other = _convertToStateSpace(other) # Check to make sure the dimensions are OK if ((self.inputs != other.outputs) or (self.outputs != other.inputs)): @@ -414,7 +414,7 @@ return out -def convertToStateSpace(sys, **kw): +def _convertToStateSpace(sys, **kw): """Convert a system to state space form (if needed). If sys is already a state space, then it is returned. If sys is a transfer @@ -422,8 +422,8 @@ is a scalar, then the number of inputs and outputs can be specified manually, as in: - >>> sys = convertToStateSpace(3.) # Assumes inputs = outputs = 1 - >>> sys = convertToStateSpace(1., inputs=3, outputs=2) + >>> sys = _convertToStateSpace(3.) # Assumes inputs = outputs = 1 + >>> sys = _convertToStateSpace(1., inputs=3, outputs=2) In the latter example, A = B = C = 0 and D = [[1., 1., 1.] [1., 1., 1.]]. @@ -432,14 +432,14 @@ if isinstance(sys, StateSpace): if len(kw): - raise TypeError("If sys is a StateSpace, convertToStateSpace \ + raise TypeError("If sys is a StateSpace, _convertToStateSpace \ cannot take keywords.") # Already a state space system; just return it return sys elif isinstance(sys, xferfcn.TransferFunction): if len(kw): - raise TypeError("If sys is a TransferFunction, convertToStateSpace \ + raise TypeError("If sys is a TransferFunction, _convertToStateSpace \ cannot take keywords.") # Change the numerator and denominator arrays so that the transfer Modified: branches/control-0.4a/src/xferfcn.py =================================================================== --- branches/control-0.4a/src/xferfcn.py 2011-02-08 22:18:03 UTC (rev 101) +++ branches/control-0.4a/src/xferfcn.py 2011-02-08 22:18:08 UTC (rev 102) @@ -30,7 +30,7 @@ TransferFunction._common_den _tfpolyToString _addSISO -convertToTransferFunction +_convertToTransferFunction """ @@ -261,7 +261,7 @@ # Convert the second argument to a transfer function. if not isinstance(other, TransferFunction): - other = convertToTransferFunction(other, inputs=self.inputs, + other = _convertToTransferFunction(other, inputs=self.inputs, outputs=self.outputs) # Check that the input-output sizes are consistent. @@ -303,10 +303,10 @@ # Convert the second argument to a transfer function. if isinstance(other, (int, float, long, complex)): - other = convertToTransferFunction(other, inputs=self.inputs, + other = _convertToTransferFunction(other, inputs=self.inputs, outputs=self.inputs) else: - other = convertToTransferFunction(other) + other = _convertToTransferFunction(other) # Check that the input-output sizes are consistent. if self.inputs != other.outputs: @@ -350,7 +350,7 @@ implemented only for SISO systems.") # Convert the second argument to a transfer function. - other = convertToTransferFunction(other) + other = _convertToTransferFunction(other) num = polymul(self.num[0][0], other.den[0][0]) den = polymul(self.den[0][0], other.num[0][0]) @@ -435,7 +435,7 @@ def feedback(self, other, sign=-1): """Feedback interconnection between two LTI objects.""" - other = convertToTransferFunction(other) + other = _convertToTransferFunction(other) if (self.inputs > 1 or self.outputs > 1 or other.inputs > 1 or other.outputs > 1): @@ -650,7 +650,7 @@ return num, den -def convertToTransferFunction(sys, **kw): +def _convertToTransferFunction(sys, **kw): """Convert a system to transfer function form (if needed). If sys is already a transfer function, then it is returned. If sys is a @@ -658,8 +658,8 @@ returned. If sys is a scalar, then the number of inputs and outputs can be specified manually, as in: - >>> sys = convertToTransferFunction(3.) # Assumes inputs = outputs = 1 - >>> sys = convertToTransferFunction(1., inputs=3, outputs=2) + >>> sys = _convertToTransferFunction(3.) # Assumes inputs = outputs = 1 + >>> sys = _convertToTransferFunction(1., inputs=3, outputs=2) In the latter example, sys's matrix transfer function is [[1., 1., 1.] [1., 1., 1.]]. @@ -669,12 +669,12 @@ if isinstance(sys, TransferFunction): if len(kw): raise TypeError("If sys is a TransferFunction, \ -convertToTransferFunction cannot take keywords.") +_convertToTransferFunction cannot take keywords.") return sys elif isinstance(sys, statesp.StateSpace): if len(kw): - raise TypeError("If sys is a StateSpace, convertToTransferFunction \ + raise TypeError("If sys is a StateSpace, _convertToTransferFunction \ cannot take keywords.") # Use Slycot to make the transformation. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |