8000 switching to having both __div__ and __truediv__ defined for the · basicmachines/python-control@0ba67cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ba67cc

Browse files
committed
switching to having both __div__ and __truediv__ defined for the
python 2->3 transition period
1 parent 39dc8c9 commit 0ba67cc

File tree

7 files changed

+20
-5
lines changed

7 files changed

+20
-5
lines changed

src/frdata.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
FRD.__rsub__
1919
FRD.__mul__
2020
FRD.__rmul__
21+
FRD.__div__
22+
FRD.__rdiv__
2123
FRD.__truediv__
2224
FRD.__rtruediv__
2325
FRD.evalfr
@@ -305,6 +307,10 @@ def __truediv__(self, other):
305307
"FRD.__truediv__ is currently implemented only for SISO systems.")
306308

307309
return FRD(self.fresp/other.fresp, self.omega)
310+
311+
# TODO: Remove when transition to python3 complete
312+
def __div__(self, other):
313+
return self.__truediv__(other)
308314

309315
# TODO: Division of MIMO transfer function objects is not written yet.
310316
def __rtruediv__(self, other):
@@ -321,6 +327,9 @@ def __rtruediv__(self, other):
321327

322328
return other / self
323329

330+
# TODO: Remove when transition to python3 complete
331+
def __rdiv__(self, other):
332+
return self.__rtruediv__(other)
324333

325334
def __pow__(self,other):
326335
if not type(other) == int:

src/xferfcn.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
TransferFunction.__rmul__
2222
TransferFunction.__div__
2323
TransferFunction.__rdiv__
24+
TransferFunction.__truediv__
25+
TransferFunction.__rtruediv__
2426
TransferFunction.evalfr
2527
TransferFunction.freqresp
2628
TransferFunction.pole
@@ -498,6 +500,10 @@ def __truediv__(self, other):
498500
den = polymul(self.den[0][0], other.num[0][0])
499501

500502
return TransferFunction(num, den, dt)
503+
504+
# TODO: Remove when transition to python3 complete
505+
def __div__(self, other):
506+
return TransferFunction.__truediv__(self, other)
501507

502508
# TODO: Division of MIMO transfer function objects is not written yet.
503509
def __rtruediv__(self, other):
@@ -515,6 +521,10 @@ def __rtruediv__(self, other):
515521

516522
return other / self
517523

524+
# TODO: Remove when transition to python3 complete
525+
def __rdiv__(self, other):
526+
return TransferFunction.__rtruediv__(self, other)
527+
518528
def __pow__(self,other):
519529
if not type(other) == int:
520530
raise ValueError("Exponent must be an integer")

tests/frd_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# RvP, 4 Oct 2012
55

66

7-
from __future__ import division
87
import unittest
98
import numpy as np
109
from control.statesp import StateSpace

tests/matlab_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# nothing crashes. It doesn't test actual functionality; the module
99
# specific unit tests will do that.
1010

11-
from __future__ import print_function, division
11+
from __future__ import print_function
1212
import unittest
1313
import numpy as np
1414
from scipy.linalg import eigvals

tests/minreal_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# minreal_test.py - test state space class
44
# Rvp, 13 Jun 2013
55

6-
from __future__ import division
76
import unittest
87
import numpy as np
98
from scipy.linalg import eigvals

tests/statesp_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# statesp_test.py - test state space class
44
# RMM, 30 Mar 2011 (based on TestStateSp from v0.4a)
55

6-
from __future__ import division
76
import unittest
87
import numpy as np
98
from scipy.linalg import eigvals

tests/xferfcn_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# xferfcn_test.py - test TransferFunction class
44
# RMM, 30 Mar 2011 (based on TestXferFcn from v0.4a)
55

6-
from __future__ import division
76
import unittest
87
import numpy as np
98
from control.statesp import StateSpace, _convertToStateSpace

0 commit comments

Comments
 (0)
0