Commit f894f15c119a5e4c66d2cb826eaba1053aef5572
1 parent
65b8bf7b
Change "from gammalib import *" to "import gammalib"
Showing
12 changed files
with
80 additions
and
94 deletions
ChangeLog
| 1 | -2015-10-16 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 1 | +2015-10-26 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 2 | 2 | |
| 3 | 3 | * Version 0.11.0 released |
| 4 | 4 | ========================= |
| 5 | 5 | |
| 6 | + Add Python unit test function to gammalib module (#1486) | |
| 6 | 7 | Increase CTA IRF integration precision for shell model (#1521) |
| 7 | 8 | Correctly handle MC simulations for unnormalized diffuse maps (#1548) |
| 8 | 9 | Improve precision of shell model in unbinned analysis (#1521) | ... | ... |
NEWS
test/test_GLinalg.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib linalg module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012-2014 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,14 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 20 | +import gammalib | |
| 22 | 21 | import os |
| 23 | 22 | |
| 24 | 23 | |
| 25 | 24 | # ===================================== # |
| 26 | 25 | # Test class for GammaLib linalg module # |
| 27 | 26 | # ===================================== # |
| 28 | -class Test(GPythonTestSuite): | |
| 27 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 28 | """ |
| 30 | 29 | Test class for GammaLib linalg module. |
| 31 | 30 | """ |
| ... | ... | @@ -35,7 +34,7 @@ class Test(GPythonTestSuite): |
| 35 | 34 | Constructor. |
| 36 | 35 | """ |
| 37 | 36 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 37 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 38 | |
| 40 | 39 | # Return |
| 41 | 40 | return |
| ... | ... | @@ -63,7 +62,7 @@ class Test(GPythonTestSuite): |
| 63 | 62 | Test GVector class. |
| 64 | 63 | """ |
| 65 | 64 | # Setup vectors |
| 66 | - vector = GVector(3) | |
| 65 | + vector = gammalib.GVector(3) | |
| 67 | 66 | vector[0] = 1.0 |
| 68 | 67 | vector[1] = 2.0 |
| 69 | 68 | vector[2] = 3.0 |
| ... | ... | @@ -165,7 +164,7 @@ class Test(GPythonTestSuite): |
| 165 | 164 | ncols = 5 |
| 166 | 165 | |
| 167 | 166 | # Allocate matrix |
| 168 | - m = GMatrix(nrows, ncols) | |
| 167 | + m = gammalib.GMatrix(nrows, ncols) | |
| 169 | 168 | |
| 170 | 169 | # Fill elements |
| 171 | 170 | for i in range(nrows): |
| ... | ... | @@ -191,7 +190,7 @@ class Test(GPythonTestSuite): |
| 191 | 190 | ncols = 3 |
| 192 | 191 | |
| 193 | 192 | # Allocate matrix |
| 194 | - m = GMatrixSparse(nrows, ncols) | |
| 193 | + m = gammalib.GMatrixSparse(nrows, ncols) | |
| 195 | 194 | |
| 196 | 195 | # Fill elements |
| 197 | 196 | for i in range(nrows): |
| ... | ... | @@ -217,7 +216,7 @@ class Test(GPythonTestSuite): |
| 217 | 216 | ncols = 3 |
| 218 | 217 | |
| 219 | 218 | # Allocate matrix |
| 220 | - m = GMatrixSymmetric(nrows, ncols) | |
| 219 | + m = gammalib.GMatrixSymmetric(nrows, ncols) | |
| 221 | 220 | |
| 222 | 221 | # Fill elements |
| 223 | 222 | for i in range(nrows): | ... | ... |
test/test_GModel.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib model module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,14 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 20 | +import gammalib | |
| 22 | 21 | import os |
| 23 | 22 | |
| 24 | 23 | |
| 25 | 24 | # ==================================== # |
| 26 | 25 | # Test class for GammaLib model module # |
| 27 | 26 | # ==================================== # |
| 28 | -class Test(GPythonTestSuite): | |
| 27 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 28 | """ |
| 30 | 29 | Test class for GammaLib model module. |
| 31 | 30 | """ |
| ... | ... | @@ -35,7 +34,7 @@ class Test(GPythonTestSuite): |
| 35 | 34 | Constructor. |
| 36 | 35 | """ |
| 37 | 36 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 37 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 38 | |
| 40 | 39 | # Return |
| 41 | 40 | return | ... | ... |
test/test_GNumerics.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib numerics module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,14 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 20 | +import gammalib | |
| 22 | 21 | import os |
| 23 | 22 | |
| 24 | 23 | |
| 25 | 24 | # ======================================= # |
| 26 | 25 | # Test class for GammaLib numerics module # |
| 27 | 26 | # ======================================= # |
| 28 | -class Test(GPythonTestSuite): | |
| 27 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 28 | """ |
| 30 | 29 | Test class for GammaLib numerics module. |
| 31 | 30 | """ |
| ... | ... | @@ -35,7 +34,7 @@ class Test(GPythonTestSuite): |
| 35 | 34 | Constructor. |
| 36 | 35 | """ |
| 37 | 36 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 37 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 38 | |
| 40 | 39 | # Return |
| 41 | 40 | return | ... | ... |
test/test_GOptimizer.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib optimizer module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,14 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 20 | +import gammalib | |
| 22 | 21 | import os |
| 23 | 22 | |
| 24 | 23 | |
| 25 | -# ================================== # | |
| 24 | +# ======================================== # | |
| 26 | 25 | # Test class for GammaLib optimizer module # |
| 27 | -# ================================== # | |
| 28 | -class Test(GPythonTestSuite): | |
| 26 | +# ======================================== # | |
| 27 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 28 | """ |
| 30 | 29 | Test class for GammaLib optimizer module. |
| 31 | 30 | """ |
| ... | ... | @@ -35,7 +34,7 @@ class Test(GPythonTestSuite): |
| 35 | 34 | Constructor. |
| 36 | 35 | """ |
| 37 | 36 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 37 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 38 | |
| 40 | 39 | # Return |
| 41 | 40 | return | ... | ... |
test/test_GSky.py
| ... | ... | @@ -17,9 +17,9 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 20 | +import gammalib | |
| 22 | 21 | import os |
| 22 | +import math | |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | # =========== # |
| ... | ... | @@ -49,7 +49,7 @@ def loadtxt(filename): |
| 49 | 49 | # ================================== # |
| 50 | 50 | # Test class for GammaLib sky module # |
| 51 | 51 | # ================================== # |
| 52 | -class Test(GPythonTestSuite): | |
| 52 | +class Test(gammalib.GPythonTestSuite): | |
| 53 | 53 | """ |
| 54 | 54 | Test class for GammaLib sky module. |
| 55 | 55 | """ |
| ... | ... | @@ -58,7 +58,7 @@ class Test(GPythonTestSuite): |
| 58 | 58 | Constructor. |
| 59 | 59 | """ |
| 60 | 60 | # Call base class constructor |
| 61 | - GPythonTestSuite.__init__(self) | |
| 61 | + gammalib.GPythonTestSuite.__init__(self) | |
| 62 | 62 | |
| 63 | 63 | # Return |
| 64 | 64 | return |
| ... | ... | @@ -82,7 +82,6 @@ class Test(GPythonTestSuite): |
| 82 | 82 | self.append(self.test_fk5_to_galactic, "Test FK5 to Galactic coordinate conversion") |
| 83 | 83 | self.append(self.test_operators, "Test skymap operators") |
| 84 | 84 | |
| 85 | - | |
| 86 | 85 | # Return |
| 87 | 86 | return |
| 88 | 87 | |
| ... | ... | @@ -97,17 +96,17 @@ class Test(GPythonTestSuite): |
| 97 | 96 | inx = pixels.dir2inx(dir) |
| 98 | 97 | msg = map + " inx2dir/dir2inx check for pixel " + str(i) |
| 99 | 98 | err = map + " GSkyMap trouble with pixel " + str(i) + " (" + str(inx) + \ |
| 100 | - "), RA=" + str(dir.ra() * 180 / pi) + ", Dec=" + str(dir.dec() * 180 / pi) | |
| 99 | + "), RA=" + str(dir.ra() * 180 / math.pi) + ", Dec=" + str(dir.dec() * 180 / math.pi) | |
| 101 | 100 | self.test_assert(i == inx, msg, err) |
| 102 | 101 | |
| 103 | 102 | # Control SkyDir coordinate transformation for all pixels |
| 104 | 103 | for i in range(pixels.npix()): |
| 105 | 104 | dir = pixels.inx2dir(i) |
| 106 | - dir_new = GSkyDir() | |
| 105 | + dir_new = gammalib.GSkyDir() | |
| 107 | 106 | dir_new.lb(dir.l(), dir.b()) |
| 108 | 107 | dra = abs(dir.ra() - dir_new.ra()) |
| 109 | 108 | if (dra >= 5.0): |
| 110 | - dra -= 2.0 * pi | |
| 109 | + dra -= 2.0 * math.pi | |
| 111 | 110 | ddec = abs(dir.dec() - dir_new.dec()) |
| 112 | 111 | msg = map + " dir check for pixel " + str(i) |
| 113 | 112 | err = map + " GSkyMap trouble with pixel " + str(i) + " (" + str(dra) + \ |
| ... | ... | @@ -132,7 +131,7 @@ class Test(GPythonTestSuite): |
| 132 | 131 | pass |
| 133 | 132 | |
| 134 | 133 | # Create skymap |
| 135 | - pixels = GSkyMap(proj, "CEL", 83.6331, 22.0145, -3.7, 2.6, 5, 5, 20) | |
| 134 | + pixels = gammalib.GSkyMap(proj, "CEL", 83.6331, 22.0145, -3.7, 2.6, 5, 5, 20) | |
| 136 | 135 | for map in range(pixels.nmaps()): |
| 137 | 136 | for i in range(pixels.npix()): |
| 138 | 137 | pixels[i, map] = i + map * pixels.npix() |
| ... | ... | @@ -161,14 +160,14 @@ class Test(GPythonTestSuite): |
| 161 | 160 | pass |
| 162 | 161 | |
| 163 | 162 | # Create HEALPix skymap |
| 164 | - pixels = GSkyMap("GAL", 2, "RING", 2) | |
| 163 | + pixels = gammalib.GSkyMap("GAL", 2, "RING", 2) | |
| 165 | 164 | for i in range(pixels.npix()): |
| 166 | 165 | pixels[i] = i + 1.0 |
| 167 | 166 | pixels[i, 1] = i + 1.0 + 1000.0 |
| 168 | 167 | pixels.save(file1) |
| 169 | 168 | |
| 170 | 169 | # Load HEALPix skymap |
| 171 | - pixels = GSkyMap(file1) | |
| 170 | + pixels = gammalib.GSkyMap(file1) | |
| 172 | 171 | |
| 173 | 172 | # Control coordinate and pixel transformations |
| 174 | 173 | self.test_skymap_pixels(pixels, "HEALPix") |
| ... | ... | @@ -184,7 +183,7 @@ class Test(GPythonTestSuite): |
| 184 | 183 | pixels.save(file2, True) |
| 185 | 184 | |
| 186 | 185 | # Load again HEALPix skymap |
| 187 | - pixels = GSkyMap(file1) | |
| 186 | + pixels = gammalib.GSkyMap(file1) | |
| 188 | 187 | |
| 189 | 188 | # Return |
| 190 | 189 | return |
| ... | ... | @@ -288,21 +287,21 @@ class Test(GPythonTestSuite): |
| 288 | 287 | for (ra, dec), (glon, glat) in coordinates: |
| 289 | 288 | |
| 290 | 289 | # Create point A in FK5 J2000 coordinates |
| 291 | - input_point = GSkyDir() | |
| 290 | + input_point = gammalib.GSkyDir() | |
| 292 | 291 | input_point.radec_deg(ra, dec) |
| 293 | 292 | |
| 294 | 293 | # Convert point A to Galactic coordinates |
| 295 | 294 | ll, bb = input_point.l_deg(), input_point.b_deg() |
| 296 | - actual_point = GSkyDir() | |
| 295 | + actual_point = gammalib.GSkyDir() | |
| 297 | 296 | actual_point.lb_deg(ll, bb) |
| 298 | 297 | |
| 299 | 298 | # Compute offset to reference result |
| 300 | - reference_point = GSkyDir() | |
| 299 | + reference_point = gammalib.GSkyDir() | |
| 301 | 300 | reference_point.lb_deg(glon, glat) |
| 302 | 301 | |
| 303 | 302 | # Compute distance and remember maximum |
| 304 | 303 | this_dist = actual_point.dist_deg(reference_point) |
| 305 | - max_dist = max(max_dist, this_dist) | |
| 304 | + max_dist = max(max_dist, this_dist) | |
| 306 | 305 | |
| 307 | 306 | # Convert max_dist from deg to milli-arcsec |
| 308 | 307 | max_dist *= 1e3 * 3600 |
| ... | ... | @@ -323,7 +322,7 @@ class Test(GPythonTestSuite): |
| 323 | 322 | Test the skymap operators. |
| 324 | 323 | """ |
| 325 | 324 | # Setup skymaps |
| 326 | - map = GSkyMap("CAR", "CEL", 83.6331, 22.0145, -3.7, 2.6, 2, 2) | |
| 325 | + map = gammalib.GSkyMap("CAR", "CEL", 83.6331, 22.0145, -3.7, 2.6, 2, 2) | |
| 327 | 326 | map[0] = 1.0 |
| 328 | 327 | map[1] = 2.0 |
| 329 | 328 | map[2] = 3.0 | ... | ... |
test/test_GSupport.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib support module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,14 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 22 | -import os | |
| 20 | +import gammalib | |
| 21 | +import math | |
| 23 | 22 | |
| 24 | 23 | |
| 25 | 24 | # =============================== # |
| 26 | 25 | # Test class for GammaLib support # |
| 27 | 26 | # =============================== # |
| 28 | -class Test(GPythonTestSuite): | |
| 27 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 28 | """ |
| 30 | 29 | Test class for GammaLib support. |
| 31 | 30 | """ |
| ... | ... | @@ -35,7 +34,7 @@ class Test(GPythonTestSuite): |
| 35 | 34 | Constructor. |
| 36 | 35 | """ |
| 37 | 36 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 37 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 38 | |
| 40 | 39 | # Return |
| 41 | 40 | return |
| ... | ... | @@ -62,15 +61,15 @@ class Test(GPythonTestSuite): |
| 62 | 61 | Test GNodeArray class. |
| 63 | 62 | """ |
| 64 | 63 | # Set-up vector and data array. Test all vector elements. |
| 65 | - vector = GVector(20) | |
| 66 | - data = GVector(20) | |
| 64 | + vector = gammalib.GVector(20) | |
| 65 | + data = gammalib.GVector(20) | |
| 67 | 66 | for i in range(20): |
| 68 | 67 | vector[i] = 10.0 + i * 5.0 |
| 69 | - data[i] = sin(0.15 * (vector[i] - 10.0)) | |
| 70 | - self.test_value(data[i], sin(0.15 * i * 5.0)) | |
| 68 | + data[i] = math.sin(0.15 * (vector[i] - 10.0)) | |
| 69 | + self.test_value(data[i], math.sin(0.15 * i * 5.0)) | |
| 71 | 70 | |
| 72 | 71 | # Set-up node array |
| 73 | - array = GNodeArray() | |
| 72 | + array = gammalib.GNodeArray() | |
| 74 | 73 | array.nodes(vector) |
| 75 | 74 | |
| 76 | 75 | # Get values |
| ... | ... | @@ -79,9 +78,9 @@ class Test(GPythonTestSuite): |
| 79 | 78 | for i in range(100): |
| 80 | 79 | x = i - 10 |
| 81 | 80 | array.set_value(x) |
| 82 | - inx_left = array.inx_left() | |
| 81 | + inx_left = array.inx_left() | |
| 83 | 82 | inx_right = array.inx_right() |
| 84 | - wgt_left = array.wgt_left() | |
| 83 | + wgt_left = array.wgt_left() | |
| 85 | 84 | wgt_right = array.wgt_right() |
| 86 | 85 | y = wgt_left * data[inx_left] + wgt_right * data[inx_right] |
| 87 | 86 | x_val.append(x) |
| ... | ... | @@ -90,21 +89,20 @@ class Test(GPythonTestSuite): |
| 90 | 89 | # Return |
| 91 | 90 | return |
| 92 | 91 | |
| 93 | - | |
| 94 | 92 | # Test GUrlFile class |
| 95 | 93 | def test_url_file(self): |
| 96 | 94 | """ |
| 97 | 95 | Test GUrlFile class. |
| 98 | 96 | """ |
| 99 | 97 | # Test file writing |
| 100 | - url = GUrlFile("test_url.dat", "w") | |
| 98 | + url = gammalib.GUrlFile("test_url.dat", "w") | |
| 101 | 99 | self.test_value(url.write("abcd", 4), 4) |
| 102 | 100 | url.put_char(ord("e")) |
| 103 | 101 | url.close() |
| 104 | 102 | |
| 105 | 103 | # Test file reading |
| 106 | 104 | buffer = "" |
| 107 | - url = GUrlFile("test_url.dat", "r") | |
| 105 | + url = gammalib.GUrlFile("test_url.dat", "r") | |
| 108 | 106 | buffer = url.read(99) |
| 109 | 107 | self.test_assert(buffer == "abcde", |
| 110 | 108 | "Expected \"abcde\" in file, found \""+ |
| ... | ... | @@ -120,7 +118,7 @@ class Test(GPythonTestSuite): |
| 120 | 118 | Test GUrlString class. |
| 121 | 119 | """ |
| 122 | 120 | # Test writing |
| 123 | - url = GUrlString() | |
| 121 | + url = gammalib.GUrlString() | |
| 124 | 122 | self.test_value(url.write("abcd", 4), 4) |
| 125 | 123 | url.put_char(ord("e")) |
| 126 | 124 | ... | ... |
test/test_GTest.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib test module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,13 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 22 | -import os | |
| 20 | +import gammalib | |
| 23 | 21 | |
| 24 | 22 | |
| 25 | 23 | # =================================== # |
| 26 | 24 | # Test class for GammaLib test module # |
| 27 | 25 | # =================================== # |
| 28 | -class Test(GPythonTestSuite): | |
| 26 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 27 | """ |
| 30 | 28 | Test class for GammaLib test module. |
| 31 | 29 | """ |
| ... | ... | @@ -35,7 +33,7 @@ class Test(GPythonTestSuite): |
| 35 | 33 | Constructor. |
| 36 | 34 | """ |
| 37 | 35 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 36 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 37 | |
| 40 | 38 | # Return |
| 41 | 39 | return | ... | ... |
test/test_GVO.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib vo module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2014 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2014-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,13 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 22 | -import os | |
| 20 | +import gammalib | |
| 23 | 21 | |
| 24 | 22 | |
| 25 | 23 | # ================================= # |
| 26 | 24 | # Test class for GammaLib vo module # |
| 27 | 25 | # ================================= # |
| 28 | -class Test(GPythonTestSuite): | |
| 26 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 27 | """ |
| 30 | 28 | Test class for GammaLib vo module. |
| 31 | 29 | """ |
| ... | ... | @@ -35,7 +33,7 @@ class Test(GPythonTestSuite): |
| 35 | 33 | Constructor. |
| 36 | 34 | """ |
| 37 | 35 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 36 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 37 | |
| 40 | 38 | # Return |
| 41 | 39 | return |
| ... | ... | @@ -60,7 +58,7 @@ class Test(GPythonTestSuite): |
| 60 | 58 | Test GVOClient class. |
| 61 | 59 | """ |
| 62 | 60 | # Allocate GVOClient object |
| 63 | - client = GVOClient() | |
| 61 | + client = gammalib.GVOClient() | |
| 64 | 62 | |
| 65 | 63 | # Return |
| 66 | 64 | return | ... | ... |
test/test_GXml.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib xml module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,13 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 22 | -import os | |
| 20 | +import gammalib | |
| 23 | 21 | |
| 24 | 22 | |
| 25 | 23 | # ================================== # |
| 26 | 24 | # Test class for GammaLib xml module # |
| 27 | 25 | # ================================== # |
| 28 | -class Test(GPythonTestSuite): | |
| 26 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 27 | """ |
| 30 | 28 | Test class for GammaLib xml module. |
| 31 | 29 | """ |
| ... | ... | @@ -35,7 +33,7 @@ class Test(GPythonTestSuite): |
| 35 | 33 | Constructor. |
| 36 | 34 | """ |
| 37 | 35 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 36 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 37 | |
| 40 | 38 | # Return |
| 41 | 39 | return | ... | ... |
test/test_GXspec.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib xspec module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2013 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2013-2015 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -17,15 +17,13 @@ |
| 17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | -from gammalib import * | |
| 21 | -from math import * | |
| 22 | -import os | |
| 20 | +import gammalib | |
| 23 | 21 | |
| 24 | 22 | |
| 25 | 23 | # ==================================== # |
| 26 | 24 | # Test class for GammaLib xspec module # |
| 27 | 25 | # ==================================== # |
| 28 | -class Test(GPythonTestSuite): | |
| 26 | +class Test(gammalib.GPythonTestSuite): | |
| 29 | 27 | """ |
| 30 | 28 | Test class for GammaLib xspec module. |
| 31 | 29 | """ |
| ... | ... | @@ -35,7 +33,7 @@ class Test(GPythonTestSuite): |
| 35 | 33 | Constructor. |
| 36 | 34 | """ |
| 37 | 35 | # Call base class constructor |
| 38 | - GPythonTestSuite.__init__(self) | |
| 36 | + gammalib.GPythonTestSuite.__init__(self) | |
| 39 | 37 | |
| 40 | 38 | # Return |
| 41 | 39 | return |
| ... | ... | @@ -63,8 +61,8 @@ class Test(GPythonTestSuite): |
| 63 | 61 | """ |
| 64 | 62 | # Allocate GPha object and check its size |
| 65 | 63 | nmeasured = 10 |
| 66 | - emeasured = GEbounds(nmeasured, GEnergy(1.0, "TeV"), GEnergy(10.0, "TeV")) | |
| 67 | - pha = GPha(emeasured) | |
| 64 | + emeasured = gammalib.GEbounds(nmeasured, gammalib.GEnergy(1.0, "TeV"), gammalib.GEnergy(10.0, "TeV")) | |
| 65 | + pha = gammalib.GPha(emeasured) | |
| 68 | 66 | self.test_value(pha.size(), nmeasured) |
| 69 | 67 | |
| 70 | 68 | # Set and retrieve a value |
| ... | ... | @@ -82,8 +80,8 @@ class Test(GPythonTestSuite): |
| 82 | 80 | """ |
| 83 | 81 | # Allocate GArf object and check its size |
| 84 | 82 | nmeasured = 10 |
| 85 | - emeasured = GEbounds(nmeasured, GEnergy(1.0, "TeV"), GEnergy(10.0, "TeV")) | |
| 86 | - arf = GArf(emeasured) | |
| 83 | + emeasured = gammalib.GEbounds(nmeasured, gammalib.GEnergy(1.0, "TeV"), gammalib.GEnergy(10.0, "TeV")) | |
| 84 | + arf = gammalib.GArf(emeasured) | |
| 87 | 85 | self.test_value(arf.size(), nmeasured) |
| 88 | 86 | |
| 89 | 87 | # Set and retrieve a value |
| ... | ... | @@ -102,9 +100,9 @@ class Test(GPythonTestSuite): |
| 102 | 100 | # Allocate GRmf object and check its size |
| 103 | 101 | ntrue = 20 |
| 104 | 102 | nmeasured = 10 |
| 105 | - etrue = GEbounds(ntrue, GEnergy(1.0, "TeV"), GEnergy(10.0, "TeV")) | |
| 106 | - emeasured = GEbounds(nmeasured, GEnergy(1.0, "TeV"), GEnergy(10.0, "TeV")) | |
| 107 | - rmf = GRmf(etrue, emeasured) | |
| 103 | + etrue = gammalib.GEbounds(ntrue, gammalib.GEnergy(1.0, "TeV"), gammalib.GEnergy(10.0, "TeV")) | |
| 104 | + emeasured = gammalib.GEbounds(nmeasured, gammalib.GEnergy(1.0, "TeV"), gammalib.GEnergy(10.0, "TeV")) | |
| 105 | + rmf = gammalib.GRmf(etrue, emeasured) | |
| 108 | 106 | self.test_value(rmf.size(), ntrue*nmeasured) |
| 109 | 107 | self.test_value(rmf.ntrue(), ntrue) |
| 110 | 108 | self.test_value(rmf.nmeasured(), nmeasured) | ... | ... |