updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / python3-pydde / 2to3.diff
blob91ffda8c1c707ed86c84dccfb2167d155a985862
1 --- ./PyDDE/__init__.py
2 +++ ./PyDDE/__init__.py (refactored)
3 @@ -1,2 +1,2 @@
4 __all__ = ["pydde"]
5 -print "Loaded package PyDDE, Version 0.2.2."
6 +print("Loaded package PyDDE, Version 0.2.2.")
7 --- ./PyDDE/pydde.py
8 +++ ./PyDDE/pydde.py (refactored)
9 @@ -27,6 +27,7 @@
11 import copy
12 import sys
13 +import collections
15 try:
16 from Numeric import array, zeros, concatenate
17 @@ -34,16 +35,16 @@
18 try:
19 from numpy import array, zeros, concatenate
20 except ImportError:
21 - print "Error: could not import either Numeric or SciPy."
22 - print "Please check that at least one of these is installed before using PyDDE."
23 - raise ImportError, 'PyDDE.pydde'
24 + print("Error: could not import either Numeric or SciPy.")
25 + print("Please check that at least one of these is installed before using PyDDE.")
26 + raise ImportError('PyDDE.pydde')
28 try:
29 import PyDDE.ddesolve as _ddesolve
30 except ImportError:
31 - print "Error: could not import the ddesolve integration routines! The solver is non-functional."
32 + print("Error: could not import the ddesolve integration routines! The solver is non-functional.")
33 _ddesolve = None
34 - raise ImportError, 'PyDDE.pydde'
35 + raise ImportError('PyDDE.pydde')
38 class dde:
39 @@ -58,7 +59,7 @@
40 self.PROB = None
41 self.SOLVER = None
42 except:
43 - print "DDE Warning: something went wrong during initialisation."
44 + print("DDE Warning: something went wrong during initialisation.")
45 raise
48 @@ -100,29 +101,29 @@
50 # Check that the supplied functions are callable.
51 try:
52 - if not(callable(grad)):
53 - raise(TypeError,"grad")
54 - if not(callable(switchfunctions)):
55 - raise(TypeError,"switchfunctions")
56 - if not(callable(maps)):
57 - raise(TypeError,"maps")
58 - if not(callable(storehistory)):
59 - raise(TypeError,"storehistory")
60 - except TypeError, errstr:
61 - print "DDE Error: User supplied function not callable:", errstr
62 - print "DDE Error: Problem initialisation failed!"
63 + if not(isinstance(grad, collections.Callable)):
64 + raise TypeError
65 + if not(isinstance(switchfunctions, collections.Callable)):
66 + raise TypeError
67 + if not(isinstance(maps, collections.Callable)):
68 + raise TypeError
69 + if not(isinstance(storehistory, collections.Callable)):
70 + raise TypeError
71 + except TypeError as errstr:
72 + print("DDE Error: User supplied function not callable:", errstr)
73 + print("DDE Error: Problem initialisation failed!")
74 return 0
76 # Check that the number of constants and variables are reasonable.
77 try:
78 if not(no_vars > 0):
79 - raise(TypeError, "no_vars")
80 - except TypeError, errstr:
81 - print "DDE Error: Number of state variables not positive:", errstr
82 + raise TypeError
83 + except TypeError as errstr:
84 + print("DDE Error: Number of state variables not positive:", errstr)
85 return 0
87 if (no_cons != len(c)):
88 - print "DDE Warning: Number of constants no_cons reset to agree with length of constants array c."
89 + print("DDE Warning: Number of constants no_cons reset to agree with length of constants array c.")
90 no_cons = len(c)
92 # check that the state scale is of the appropriate length
93 @@ -140,29 +141,29 @@
94 try:
95 g = grad(initstate,c,t0)
96 if (len(g) != no_vars):
97 - raise(IndexError,"grad")
98 + raise IndexError
99 if (nsw > 0):
100 sw = switchfunctions(initstate,c,t0)
101 if (len(sw) != nsw):
102 - raise(IndexError,"switchfunctions")
103 + raise IndexError
104 for i in range(nsw):
105 ms,mc = maps(initstate,c,t0,i)
106 if ((len(ms) != no_vars) or (len(mc) != no_cons)):
107 - raise(IndexError,"maps")
108 - except IndexError, errstr:
109 - print "DDE Error: Output of user supplied function incorrect:", errstr
110 - print "DDE Error: Problem initialisation failed!"
111 + raise IndexError
112 + except IndexError as errstr:
113 + print("DDE Error: Output of user supplied function incorrect:", errstr)
114 + print("DDE Error: Problem initialisation failed!")
115 return 0
117 try:
118 self.PROB = (int(no_vars), int(no_cons), # number of variables and constants
119 int(no_vars), int(nlag), int(nsw), int(len(otimes)),
120 float(t0), float(t1),
121 - array(map(float,initstate)), array(map(float,c)), array(map(float,otimes)),
122 + array(list(map(float,initstate))), array(list(map(float,c))), array(list(map(float,otimes))),
123 grad, switchfunctions, maps, storehistory)
124 except:
125 - print "DDE Error: Something is wrong: perhaps one of the supplied variables has the wrong type?"
126 - print "DDE Error: Problem initialisation failed!"
127 + print("DDE Error: Something is wrong: perhaps one of the supplied variables has the wrong type?")
128 + print("DDE Error: Problem initialisation failed!")
129 return 0
131 # all went well
132 @@ -207,10 +208,10 @@
133 try:
134 self.SOLVER = (float(tol), int(hbsize),
135 float(dt), # output and integration timesteps
136 - array(map(float,statescale)))
137 + array(list(map(float,statescale))))
138 except:
139 - print "DDE Error: Something is wrong: perhaps one of the supplied variables has the wrong type?"
140 - print "DDE Error: Solver initialisation failed!"
141 + print("DDE Error: Something is wrong: perhaps one of the supplied variables has the wrong type?")
142 + print("DDE Error: Solver initialisation failed!")
143 return 0
145 # all went well
146 @@ -237,16 +238,16 @@
147 #clean(1)
149 else:
150 - print self._solved
151 - print again
152 - print "DDE Error: Solver thinks the solution is already given in the <instance>.data.\n \
153 - To force the solver to run again, use <instance>.solve(again=1)"
154 + print(self._solved)
155 + print(again)
156 + print("DDE Error: Solver thinks the solution is already given in the <instance>.data.\n \
157 + To force the solver to run again, use <instance>.solve(again=1)")
159 except AssertionError:
160 - print "DDE Error: The DDE has not been properly initialised!"
161 + print("DDE Error: The DDE has not been properly initialised!")
162 self._solved = 0
163 except:
164 - print "DDE Error: Solution failed!"
165 + print("DDE Error: Solution failed!")
166 self._solved = 0
167 raise
169 @@ -293,7 +294,7 @@
170 try:
171 assert(_ddesolve.clean(wipe))
172 except AssertionError:
173 - print "DDE Error: Problem cleaning up after the solver."
174 + print("DDE Error: Problem cleaning up after the solver.")
175 return 0
176 except:
177 return 0
178 --- ./PyDDE/test/test.py
179 +++ ./PyDDE/test/test.py (refactored)
180 @@ -23,20 +23,20 @@
181 try:
182 from Numeric import *
183 except:
184 - print "Could not import Numeric, numpy and scipy. Test cannot run."
185 - raise StandardError, "PyDDE test script."
186 + print("Could not import Numeric, numpy and scipy. Test cannot run.")
187 + raise Exception("PyDDE test script.")
189 try:
190 import PyDDE.pydde as p
191 except ImportError:
192 - print "Could not import PyDDE.pydde. Test cannot run."
193 - raise StandardError, "PyDDE test script."
194 + print("Could not import PyDDE.pydde. Test cannot run.")
195 + raise Exception("PyDDE test script.")
197 try:
198 import timing
199 timeit = 1
200 except ImportError:
201 - print "Could not import timing module. No timing of tests will occur."
202 + print("Could not import timing module. No timing of tests will occur.")
203 timeit = 0
206 @@ -51,7 +51,7 @@
207 try:
208 del ode_eg
209 except:
210 - print "DDE Test: Running for the first time..."
211 + print("DDE Test: Running for the first time...")
213 ode_eg = p.dde()
215 @@ -85,7 +85,7 @@
216 try:
217 del dde_eg
218 except:
219 - print "DDE Test: Running for the first time..."
220 + print("DDE Test: Running for the first time...")
222 dde_eg = p.dde()
224 @@ -115,7 +115,7 @@
225 try:
226 del sdde_eg
227 except:
228 - print "DDE Test: Running for the first time..."
229 + print("DDE Test: Running for the first time...")
231 sdde_eg = p.dde()
233 @@ -160,7 +160,7 @@
235 if timeit:
236 timing.finish()
237 - print str(timing.seconds())+"."+str(timing.milli())+" seconds"
238 + print(str(timing.seconds())+"."+str(timing.milli())+" seconds")
241 try:
242 @@ -248,7 +248,7 @@
243 sddepp.writeEPSfile("../test/sdde_eg.eps")
245 except ImportError:
246 - print "DDE Test: Could not import PyX! Cannot print output from examples."
247 -except:
248 - print "DDE Test: An error occured during attempt to plot data."
249 + print("DDE Test: Could not import PyX! Cannot print output from examples.")
250 +except:
251 + print("DDE Test: An error occured during attempt to plot data.")
252 raise