Commit 27f0166ed46629efefb5a0cbac06323b6194426c
1 parent
77a829e9
Fix log file header repetition in some cscripts (#3066)
Showing
6 changed files
with
20 additions
and
18 deletions
ChangeLog
| 1 | -2019-11-14 | |
| 1 | +2019-11-15 | |
| 2 | 2 | |
| 3 | 3 | * Version 1.7.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | + Fix log file header repetition in some cscripts (#3066) | |
| 6 | 7 | Add Moon constraints to csviscube (#3065) |
| 7 | 8 | Remove response cache before source testing in cttsmap (#2973) |
| 8 | 9 | Enabling running of example scripts from objects in memory (#2925) | ... | ... |
NEWS
| 1 | 1 | New Features and Important Changes in ctools 1.7.0 |
| 2 | 2 | |
| 3 | -14 November 2019 | |
| 3 | +15 November 2019 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | Introduction |
| ... | ... | @@ -31,7 +31,12 @@ None |
| 31 | 31 | |
| 32 | 32 | Base classes |
| 33 | 33 | ------------ |
| 34 | -None | |
| 34 | +The headers in the log files created by cscripts that were derived from the | |
| 35 | +ctools.cscript base class were repeated. This repetition was not present in | |
| 36 | +the other base classes due to a reopening of the log file in those classes. | |
| 37 | +The logic was changed so that the cscripts now behave like the ctools. A log | |
| 38 | +file is not written by default in Python, the logFileOpen() method needs to | |
| 39 | +be called for that. And the header is only written once in the log file (#3066). | |
| 35 | 40 | |
| 36 | 41 | |
| 37 | 42 | ctbin - CTA event binning | ... | ... |
doc/source/admin/release_history/1.7.rst
pyext/ctlikelihood.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctlikelihood - Base class for likelihood tools * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2016-2018 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2016-2019 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -187,13 +187,11 @@ def _init_cslikelihood(self, name, version, argv): |
| 187 | 187 | else: |
| 188 | 188 | cslikelihood.__init__(self, name, version) |
| 189 | 189 | # Set logger properties |
| 190 | - self._log_header() | |
| 191 | 190 | self._log.date(True) |
| 192 | 191 | cslikelihood._init_cslikelihood = _init_cslikelihood |
| 193 | 192 | |
| 194 | 193 | # Execute the script |
| 195 | 194 | def _execute(self): |
| 196 | - self.logFileOpen() | |
| 197 | 195 | self._read_ahead(True) |
| 198 | 196 | self.run() |
| 199 | 197 | self.save() | ... | ... |
pyext/ctobservation.i
| ... | ... | @@ -202,7 +202,6 @@ def _init_csobservation(self, name, version, argv): |
| 202 | 202 | else: |
| 203 | 203 | csobservation.__init__(self, name, version) |
| 204 | 204 | # Set logger properties |
| 205 | - self._log_header() | |
| 206 | 205 | self._log.date(True) |
| 207 | 206 | csobservation._init_csobservation = _init_csobservation |
| 208 | 207 | |
| ... | ... | @@ -217,7 +216,6 @@ cscript._unbinned_observations = _unbinned_observations |
| 217 | 216 | |
| 218 | 217 | # Execute the script |
| 219 | 218 | def _execute(self): |
| 220 | - self.logFileOpen() | |
| 221 | 219 | self._read_ahead(True) |
| 222 | 220 | self.run() |
| 223 | 221 | self.save() | ... | ... |
pyext/ctool.i
| ... | ... | @@ -198,7 +198,7 @@ public: |
| 198 | 198 | * handling. |
| 199 | 199 | ***************************************************************************/ |
| 200 | 200 | class cscript : public ctool { |
| 201 | -public: | |
| 201 | +public: | |
| 202 | 202 | // Constructors and destructors |
| 203 | 203 | cscript(const std::string& name, |
| 204 | 204 | const std::string& version); |
| ... | ... | @@ -276,23 +276,21 @@ def _set_input_obs(self, argv): |
| 276 | 276 | if len(argv) > 0 and isinstance(argv[0],gammalib.GObservations): |
| 277 | 277 | obs = argv[0] |
| 278 | 278 | argv = argv[1:] |
| 279 | - else: | |
| 279 | + else: | |
| 280 | 280 | obs = gammalib.GObservations() |
| 281 | 281 | return (obs, argv) |
| 282 | 282 | cscript._set_input_obs = _set_input_obs |
| 283 | 283 | |
| 284 | 284 | # Initialise application by calling the appropriate class constructor |
| 285 | 285 | def _init_cscript(self, name, version, argv): |
| 286 | - if len(argv) == 0: | |
| 287 | - cscript.__init__(self, name, version) | |
| 288 | - elif len(argv) == 1: | |
| 289 | - cscript.__init__(self, name, version, *argv) | |
| 290 | - elif len(argv) == 3: | |
| 291 | - cscript.__init__(self, name, version, argv[2]) | |
| 286 | + if len(argv) > 0: | |
| 287 | + if len(argv) == 3 and argv[0] == name and argv[1] == version: | |
| 288 | + cscript.__init__(self, name, version, argv[2]) | |
| 289 | + else: | |
| 290 | + cscript.__init__(self, name, version, *argv) | |
| 292 | 291 | else: |
| 293 | - raise TypeError('Invalid number of arguments given.') | |
| 292 | + cscript.__init__(self, name, version) | |
| 294 | 293 | # Set logger properties |
| 295 | - self._log_header() | |
| 296 | 294 | self._log.date(True) |
| 297 | 295 | cscript._init_cscript = _init_cscript |
| 298 | 296 | ... | ... |