Commit c89517892ae6c983bacd06e69a0a9c905d0ed8c0
1 parent
3e9290d1
Improve code quality
Showing
2 changed files
with
13 additions
and
9 deletions
cscripts/csspec.py
| ... | ... | @@ -153,9 +153,9 @@ class csspec(ctools.cscript): |
| 153 | 153 | # is 'SLICE' then log a warning that non-CTA observations will be |
| 154 | 154 | # ignored |
| 155 | 155 | if n_cta > 0 and n_other > 0 and self._method == 'SLICE': |
| 156 | - self._log_string(TERSE, '\nWARNING: Only CTA observation can be ' | |
| 157 | - 'handled with the "SLICE" method, all ' | |
| 158 | - 'non-CTA observation will be ignored.') | |
| 156 | + self._log_string(gammalib.TERSE, '\nWARNING: Only CTA observation ' | |
| 157 | + 'can be handled with the "SLICE" method, all ' | |
| 158 | + 'non-CTA observation will be ignored.') | |
| 159 | 159 | |
| 160 | 160 | # If there are only non-CTA observations and the method is 'SLICE' |
| 161 | 161 | # then stop now | ... | ... |
test/test_csphagen.py
| ... | ... | @@ -41,6 +41,8 @@ class Test(test): |
| 41 | 41 | """ |
| 42 | 42 | # Call base class constructor |
| 43 | 43 | test.__init__(self) |
| 44 | + | |
| 45 | + # Set test datasets and parameters | |
| 44 | 46 | self._myevents1 = self._datadir + '/crab_offaxis1.fits' |
| 45 | 47 | self._myevents2 = self._datadir + '/crab_offaxis2.fits' |
| 46 | 48 | self._exclusion = self._datadir + '/crab_exclusion.fits' |
| ... | ... | @@ -213,9 +215,8 @@ class Test(test): |
| 213 | 215 | self._nreg_mul[s]) |
| 214 | 216 | self._check_outobs('csphagen_py3', 2) |
| 215 | 217 | |
| 216 | - # Test with multiple input observations and stacking | |
| 217 | - | |
| 218 | - # Setup csphagen | |
| 218 | + # Setup csphagen for test with multiple input observations and | |
| 219 | + # stacking | |
| 219 | 220 | phagen = cscripts.csphagen(obs) |
| 220 | 221 | phagen['ebinalg'] = 'LOG' |
| 221 | 222 | phagen['emin'] = 0.1 |
| ... | ... | @@ -241,23 +242,26 @@ class Test(test): |
| 241 | 242 | 0, check_regions=False) |
| 242 | 243 | self._check_outobs('csphagen_py4', 1) |
| 243 | 244 | |
| 245 | + # Return | |
| 244 | 246 | return |
| 245 | 247 | |
| 246 | 248 | def _check_ebounds(self, table, bins): |
| 247 | 249 | """ |
| 248 | 250 | Check EBOUNDS table |
| 249 | 251 | """ |
| 252 | + # Expected column names | |
| 250 | 253 | cols = ['E_MIN', 'E_MAX'] |
| 251 | 254 | |
| 252 | - self.test_value(table.ncols(), len(cols), | |
| 253 | - 'Check for %d columns in energy bounds table' % len( | |
| 254 | - cols)) | |
| 255 | + # Check number of columns, rows and column names | |
| 256 | + self.test_value(table.ncols(), len(cols), 'Check for %d columns in ' | |
| 257 | + 'energy bounds table' % len(cols)) | |
| 255 | 258 | self.test_value(table.nrows(), bins, |
| 256 | 259 | 'Check for %d rows in energy bounds table' % bins) |
| 257 | 260 | for col in cols: |
| 258 | 261 | self.test_assert(table.contains(col), |
| 259 | 262 | 'FITS file contains "' + col + '" column') |
| 260 | 263 | |
| 264 | + # Return | |
| 261 | 265 | return |
| 262 | 266 | |
| 263 | 267 | def _check_pha(self, filename, bins): | ... | ... |