Commit 6859d6f1e2bd14aba5f70fccd57c89ea1931cf2c
1 parent
b422a227
Improve coverage of cscript test
Showing
1 changed file
with
39 additions
and
3 deletions
test/test_cscript.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the cscript base classes. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016-2018 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2019 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -56,12 +56,14 @@ class cscript_test(ctools.cscript): |
| 56 | 56 | |
| 57 | 57 | # Check create_ebounds() method |
| 58 | 58 | def check_create_ebounds(self, filename): |
| 59 | - self.pars()['ebinfile'].value(filename) | |
| 59 | + if filename is not '': | |
| 60 | + self.pars()['ebinfile'].value(filename) | |
| 60 | 61 | return self._create_ebounds() |
| 61 | 62 | |
| 62 | 63 | # Check create_energies() method |
| 63 | 64 | def check_create_energies(self, filename): |
| 64 | - self.pars()['ebinfile'].value(filename) | |
| 65 | + if filename is not '': | |
| 66 | + self.pars()['ebinfile'].value(filename) | |
| 65 | 67 | return self._create_energies() |
| 66 | 68 | |
| 67 | 69 | # Check require_inobs() method |
| ... | ... | @@ -468,6 +470,23 @@ class Test(test): |
| 468 | 470 | except ValueError: |
| 469 | 471 | self.test_try_success() |
| 470 | 472 | |
| 473 | + # Test create_ebounds() method for "LIN" and "LOG" methods | |
| 474 | + cls, pars, cpy_pars = self._setup_cscript() | |
| 475 | + pars.append(gammalib.GApplicationPar('ebinalg','s','h','LIN','','','')) | |
| 476 | + pars.append(gammalib.GApplicationPar('ebinfile','f','h','NONE','','','')) | |
| 477 | + pars.append(gammalib.GApplicationPar('enumbins','i','h','1','','','')) | |
| 478 | + pars.append(gammalib.GApplicationPar('emin','r','h','1.0','','','')) | |
| 479 | + pars.append(gammalib.GApplicationPar('emax','r','h','10.0','','','')) | |
| 480 | + ebounds = cls.check_create_ebounds('') | |
| 481 | + self.test_value(ebounds.size(), 1, 'Check number of energy boundaries') | |
| 482 | + self.test_value(ebounds.emin().TeV(), 1.0, 'Check minimum energy') | |
| 483 | + self.test_value(ebounds.emax().TeV(), 10.0, 'Check maximum energy') | |
| 484 | + ebounds = cls.check_create_ebounds('') | |
| 485 | + self.test_value(ebounds.size(), 1, 'Check number of energy boundaries') | |
| 486 | + self.test_value(ebounds.emin().TeV(), 1.0, 'Check minimum energy') | |
| 487 | + self.test_value(ebounds.emax().TeV(), 10.0, 'Check maximum energy') | |
| 488 | + cls.pars(cpy_pars) | |
| 489 | + | |
| 471 | 490 | # Test create_energies() method for "EBOUNDS" extension |
| 472 | 491 | energies = empty.check_create_energies('test_ebinfile_ebounds.fits') |
| 473 | 492 | self.test_value(energies.size(), 2, 'Check number of energies') |
| ... | ... | @@ -514,6 +533,23 @@ class Test(test): |
| 514 | 533 | except ValueError: |
| 515 | 534 | self.test_try_success() |
| 516 | 535 | |
| 536 | + # Test create_energies() method for "LIN" and "LOG" methods | |
| 537 | + cls, pars, cpy_pars = self._setup_cscript() | |
| 538 | + pars.append(gammalib.GApplicationPar('ebinalg','s','h','LIN','','','')) | |
| 539 | + pars.append(gammalib.GApplicationPar('ebinfile','f','h','NONE','','','')) | |
| 540 | + pars.append(gammalib.GApplicationPar('enumbins','i','h','2','','','')) | |
| 541 | + pars.append(gammalib.GApplicationPar('emin','r','h','1.0','','','')) | |
| 542 | + pars.append(gammalib.GApplicationPar('emax','r','h','10.0','','','')) | |
| 543 | + energies = cls.check_create_energies('') | |
| 544 | + self.test_value(energies.size(), 2, 'Check number of energies') | |
| 545 | + self.test_value(energies[0].TeV(), 1.0, 'Check first energy') | |
| 546 | + self.test_value(energies[1].TeV(), 10.0, 'Check second energy') | |
| 547 | + energies = cls.check_create_energies('') | |
| 548 | + self.test_value(energies.size(), 2, 'Check number of energies') | |
| 549 | + self.test_value(energies[0].TeV(), 1.0, 'Check first energy') | |
| 550 | + self.test_value(energies[1].TeV(), 10.0, 'Check second energy') | |
| 551 | + cls.pars(cpy_pars) | |
| 552 | + | |
| 517 | 553 | # Test create_map() method |
| 518 | 554 | # TODO: implement |
| 519 | 555 | ... | ... |