Commit b8e1637ce5501373c3977327295ad2585996c14a
1 parent
03ebfe59
Change ctool.pars() to ctool.pardict() and cscript.pars() to cscript.pardict()
Showing
2 changed files
with
8 additions
and
10 deletions
pyext/ctool.i
| ... | ... | @@ -211,14 +211,12 @@ def _init_cscript(self, argv): |
| 211 | 211 | self._log.date(True) |
| 212 | 212 | cscript._init_cscript = _init_cscript |
| 213 | 213 | |
| 214 | -# Return or assigns user parameters in form of a dictionary | |
| 215 | -# | |
| 216 | 214 | # This function either returns or assigns user parameters in form of a |
| 217 | 215 | # dictionary. The assignment function takes a dictionary as argument and |
| 218 | 216 | # the function then loops over all keys in that dictionary and assigns |
| 219 | 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 | 221 | # is equivalent to |
| 224 | 222 | # |
| ... | ... | @@ -230,10 +228,10 @@ cscript._init_cscript = _init_cscript |
| 230 | 228 | # keys and the current values as values. No parameter querying is performed. |
| 231 | 229 | # For example |
| 232 | 230 | # |
| 233 | -# >>> d = tool.pars() | |
| 231 | +# >>> d = tool.pardict() | |
| 234 | 232 | # |
| 235 | 233 | # puts all parameters in the dictionary d. |
| 236 | -def _parameters(self, *args): | |
| 234 | +def _pardict(self, *args): | |
| 237 | 235 | if len(args) == 0: |
| 238 | 236 | d = {} |
| 239 | 237 | for par in self._pars(): |
| ... | ... | @@ -252,7 +250,7 @@ def _parameters(self, *args): |
| 252 | 250 | for key in args[0]: |
| 253 | 251 | self[key] = args[0][key] |
| 254 | 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 | 237 | |
| 238 | 238 | # And finally go for a fully Pythonic version with all parameters |
| 239 | 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 | 241 | 'emax': 100.0, 'enumbins': 10, 'nxpix': 40, 'nypix': 40, |
| 242 | 242 | 'binsz': 0.1, 'coordsys': 'CEL', 'proj': 'CAR', |
| 243 | 243 | 'xref': 83.63, 'yref': 22.01, 'outcube': 'ctbin_py4.fits', |
| 244 | 244 | 'logfile': 'ctbin_py4.log', 'chatter': 2} |
| 245 | 245 | bin = ctools.ctbin() |
| 246 | - bin.pars(dict) | |
| 246 | + bin.pardict(pars) | |
| 247 | 247 | bin.logFileOpen() |
| 248 | 248 | bin.execute() |
| 249 | 249 | ... | ... |