Commit b8e1637ce5501373c3977327295ad2585996c14a

Authored by Jürgen Knödlseder
1 parent 03ebfe59

Change ctool.pars() to ctool.pardict() and cscript.pars() to cscript.pardict()

pyext/ctool.i
@@ -211,14 +211,12 @@ def _init_cscript(self, argv): @@ -211,14 +211,12 @@ def _init_cscript(self, argv):
211 self._log.date(True) 211 self._log.date(True)
212 cscript._init_cscript = _init_cscript 212 cscript._init_cscript = _init_cscript
213 213
214 -# Return or assigns user parameters in form of a dictionary  
215 -#  
216 # This function either returns or assigns user parameters in form of a 214 # This function either returns or assigns user parameters in form of a
217 # dictionary. The assignment function takes a dictionary as argument and 215 # dictionary. The assignment function takes a dictionary as argument and
218 # the function then loops over all keys in that dictionary and assigns 216 # the function then loops over all keys in that dictionary and assigns
219 # the value to the parameter. For example 217 # the value to the parameter. For example
220 # 218 #
221 -# >>> tool.pars({'ra': 83.63, 'dec': 22.01}) 219 +# >>> tool.pardict({'ra': 83.63, 'dec': 22.01})
222 # 220 #
223 # is equivalent to 221 # is equivalent to
224 # 222 #
@@ -230,10 +228,10 @@ cscript._init_cscript = _init_cscript @@ -230,10 +228,10 @@ cscript._init_cscript = _init_cscript
230 # keys and the current values as values. No parameter querying is performed. 228 # keys and the current values as values. No parameter querying is performed.
231 # For example 229 # For example
232 # 230 #
233 -# >>> d = tool.pars() 231 +# >>> d = tool.pardict()
234 # 232 #
235 # puts all parameters in the dictionary d. 233 # puts all parameters in the dictionary d.
236 -def _parameters(self, *args): 234 +def _pardict(self, *args):
237 if len(args) == 0: 235 if len(args) == 0:
238 d = {} 236 d = {}
239 for par in self._pars(): 237 for par in self._pars():
@@ -252,7 +250,7 @@ def _parameters(self, *args): @@ -252,7 +250,7 @@ def _parameters(self, *args):
252 for key in args[0]: 250 for key in args[0]:
253 self[key] = args[0][key] 251 self[key] = args[0][key]
254 else: 252 else:
255 - raise TypeError('pars() takes 0 or 1 arguments (%d given)' % len(args))  
256 -ctool.pars = _parameters  
257 -cscript.pars = _parameters 253 + raise TypeError('pardict() takes 0 or 1 arguments (%d given)' % len(args))
  254 +ctool.pardict = _pardict
  255 +cscript.pardict = _pardict
258 %} 256 %}
test/test_ctbin.py
@@ -237,13 +237,13 @@ class Test(test): @@ -237,13 +237,13 @@ class Test(test):
237 237
238 # And finally go for a fully Pythonic version with all parameters 238 # And finally go for a fully Pythonic version with all parameters
239 # being specified in a dictionary 239 # being specified in a dictionary
240 - dict = {'inobs': self._events, 'ebinalg': 'LOG', 'emin': 0.1, 240 + pars = {'inobs': self._events, 'ebinalg': 'LOG', 'emin': 0.1,
241 'emax': 100.0, 'enumbins': 10, 'nxpix': 40, 'nypix': 40, 241 'emax': 100.0, 'enumbins': 10, 'nxpix': 40, 'nypix': 40,
242 'binsz': 0.1, 'coordsys': 'CEL', 'proj': 'CAR', 242 'binsz': 0.1, 'coordsys': 'CEL', 'proj': 'CAR',
243 'xref': 83.63, 'yref': 22.01, 'outcube': 'ctbin_py4.fits', 243 'xref': 83.63, 'yref': 22.01, 'outcube': 'ctbin_py4.fits',
244 'logfile': 'ctbin_py4.log', 'chatter': 2} 244 'logfile': 'ctbin_py4.log', 'chatter': 2}
245 bin = ctools.ctbin() 245 bin = ctools.ctbin()
246 - bin.pars(dict) 246 + bin.pardict(pars)
247 bin.logFileOpen() 247 bin.logFileOpen()
248 bin.execute() 248 bin.execute()
249 249