From: <mur...@us...> - 2013-07-16 05:14:26
|
Revision: 290 http://sourceforge.net/p/python-control/code/290 Author: murrayrm Date: 2013-07-16 05:14:17 +0000 (Tue, 16 Jul 2013) Log Message: ----------- updated division operators for FRD and TransferFunction to be python3 compatible Modified Paths: -------------- trunk/ChangeLog trunk/src/frdata.py trunk/src/xferfcn.py Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2013-07-15 04:39:59 UTC (rev 289) +++ trunk/ChangeLog 2013-07-16 05:14:17 UTC (rev 290) @@ -1,3 +1,8 @@ +2013-07-15 Richard Murray <murray@altura-2.local> + + * src/frdata.py, src/xferfcn.py: updated to use __truediv__ and + __rtruediv__ for compatibility with python3 + 2013-07-14 Richard Murray <murray@altura-2.local> * src/dtime.py (sample_system): added check to make sure Modified: trunk/src/frdata.py =================================================================== --- trunk/src/frdata.py 2013-07-15 04:39:59 UTC (rev 289) +++ trunk/src/frdata.py 2013-07-16 05:14:17 UTC (rev 290) @@ -1,3 +1,4 @@ +from __future__ import division """frdata.py Frequency response data representation and functions. @@ -17,8 +18,8 @@ FRD.__rsub__ FRD.__mul__ FRD.__rmul__ -FRD.__div__ -FRD.__rdiv__ +FRD.__truediv__ +FRD.__rtruediv__ FRD.evalfr FRD.freqresp FRD.pole @@ -289,7 +290,7 @@ return FRD(fresp, self.omega) # TODO: Division of MIMO transfer function objects is not written yet. - def __div__(self, other): + def __truediv__(self, other): """Divide two LTI objects.""" if isinstance(other, (int, float, complex)): @@ -301,12 +302,12 @@ if (self.inputs > 1 or self.outputs > 1 or other.inputs > 1 or other.outputs > 1): raise NotImplementedError( - "FRD.__div__ is currently implemented only for SISO systems.") + "FRD.__truediv__ is currently implemented only for SISO systems.") return FRD(self.fresp/other.fresp, self.omega) # TODO: Division of MIMO transfer function objects is not written yet. - def __rdiv__(self, other): + def __rtruediv__(self, other): """Right divide two LTI objects.""" if isinstance(other, (int, float, complex)): return FRD(other / self.fresp, self.omega) @@ -316,7 +317,7 @@ if (self.inputs > 1 or self.outputs > 1 or other.inputs > 1 or other.outputs > 1): raise NotImplementedError( - "FRD.__rdiv__ is currently implemented only for SISO systems.") + "FRD.__rtruediv__ is currently implemented only for SISO systems.") return other / self Modified: trunk/src/xferfcn.py =================================================================== --- trunk/src/xferfcn.py 2013-07-15 04:39:59 UTC (rev 289) +++ trunk/src/xferfcn.py 2013-07-16 05:14:17 UTC (rev 290) @@ -37,6 +37,7 @@ # Python 3 compatability (needs to go here) from __future__ import print_function +from __future__ import division """Copyright (c) 2010 by California Institute of Technology All rights reserved. @@ -470,7 +471,7 @@ return TransferFunction(num, den, dt) # TODO: Division of MIMO transfer function objects is not written yet. - def __div__(self, other): + def __truediv__(self, other): """Divide two LTI objects.""" if isinstance(other, (int, float, complex)): @@ -482,7 +483,7 @@ if (self.inputs > 1 or self.outputs > 1 or other.inputs > 1 or other.outputs > 1): - raise NotImplementedError("TransferFunction.__div__ is currently \ + raise NotImplementedError("TransferFunction.__truediv__ is currently \ implemented only for SISO systems.") # Figure out the sampling time to use @@ -499,7 +500,7 @@ return TransferFunction(num, den, dt) # TODO: Division of MIMO transfer function objects is not written yet. - def __rdiv__(self, other): + def __rtruediv__(self, other): """Right divide two LTI objects.""" if isinstance(other, (int, float, complex)): other = _convertToTransferFunction(other, inputs=self.inputs, @@ -509,7 +510,7 @@ if (self.inputs > 1 or self.outputs > 1 or other.inputs > 1 or other.outputs > 1): - raise NotImplementedError("TransferFunction.__rdiv__ is currently \ + raise NotImplementedError("TransferFunction.__rtruediv__ is currently \ implemented only for SISO systems.") return other / self |