From 1985a10ddffafc19a29c03f82d3fd17822e70f31 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 4 Sep 2012 13:14:43 +0200 Subject: [PATCH] Add modules for Python unit tests. --- test/test_GApp.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GFits.py | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GLinalg.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GModel.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GNumerics.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GObs.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GOpt.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GSky.py | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GSupport.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GTest.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_GXml.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 1040 insertions(+), 0 deletions(-) create mode 100755 test/test_GApp.py create mode 100755 test/test_GFits.py create mode 100755 test/test_GLinalg.py create mode 100755 test/test_GModel.py create mode 100755 test/test_GNumerics.py create mode 100755 test/test_GObs.py create mode 100755 test/test_GOpt.py create mode 100755 test/test_GSky.py create mode 100755 test/test_GSupport.py create mode 100755 test/test_GTest.py create mode 100755 test/test_GXml.py diff --git a/test/test_GApp.py b/test/test_GApp.py new file mode 100755 index 0000000..bbe3f66 --- /dev/null +++ b/test/test_GApp.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib app module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ================================== # +# Test class for GammaLib app module # +# ================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib app module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("app") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return diff --git a/test/test_GFits.py b/test/test_GFits.py new file mode 100755 index 0000000..d7454ef --- /dev/null +++ b/test/test_GFits.py @@ -0,0 +1,220 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib FITS module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os +import sys + + +# =================================== # +# Test class for GammaLib FITS module # +# =================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib FITS module. + """ + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("fits") + + # Append tests + self.append(self.test_fits, "Test GFits") + + # Return + return + + def test_fits(self): + """ + Test FITS interface. + """ + # Set filenames + file1 = "test_python_fits_v1.fits" + file2 = "test_python_fits_v2.fits" + + # Remove test files + try: + os.remove(file1) + os.remove(file2) + except: + pass + + # Create FITS file + fits = GFits(file1, True) + sys.stdout.write(".") + + # Create images + nx = 10 + ny = 10 + img1 = GFitsImageByte(nx,ny) + img2 = GFitsImageDouble(nx,ny) + img3 = GFitsImageFloat(nx,ny) + img4 = GFitsImageLong(nx,ny) + img5 = GFitsImageLongLong(nx,ny) + img6 = GFitsImageSByte(nx,ny) + img7 = GFitsImageShort(nx,ny) + img8 = GFitsImageULong(nx,ny) + img9 = GFitsImageUShort(nx,ny) + for x in range(nx): + for y in range(ny): + img1[x,y] = x+y*nx + img2[x,y] = x+y*nx + img3[x,y] = x+y*nx + img4[x,y] = x+y*nx + img5[x,y] = x+y*nx + img6[x,y] = x+y*nx + img7[x,y] = x+y*nx + img8[x,y] = x+y*nx + img9[x,y] = x+y*nx + img1.extname("Byte") + img2.extname("Double") + img3.extname("Float") + img4.extname("Long") + img5.extname("LongLong") + img6.extname("SByte") + img7.extname("Short") + img8.extname("ULong") + img9.extname("UShort") + sys.stdout.write(".") + + # Append images to FITS file + fits.append(img1) + fits.append(img2) + fits.append(img3) + fits.append(img4) + fits.append(img5) + #fits.append(img6) # Not supported in older cfitsio + fits.append(img7) + fits.append(img8) + fits.append(img9) + sys.stdout.write(".") + + # Set header keywords + img_byte = fits.image(0) + img_byte.card("test", "test-value", "this is for testing") + img_byte.card("real", 3.1415, "a real value") + img_byte.card("int", 41, "an integer value") + sys.stdout.write(".") + + # Create table columns + nrows = 10 + col1 = GFitsTableBitCol("BIT", nrows) + col2 = GFitsTableBoolCol("BOOLEAN", nrows) + col3 = GFitsTableByteCol("BYTE", nrows) + col4 = GFitsTableDoubleCol("DOUBLE", nrows) + col5 = GFitsTableFloatCol("FLOAT", nrows) + col6 = GFitsTableLongCol("LONG", nrows) + col7 = GFitsTableLongLongCol("LONGLONG", nrows) + col8 = GFitsTableShortCol("SHORT", nrows) + col9 = GFitsTableStringCol("STRING", nrows, 20) + col10 = GFitsTableULongCol("ULONG", nrows) + col11 = GFitsTableUShortCol("USHORT", nrows) + for i in range(nrows): + col1[i] = i % 2 + col2[i] = i % 2 + col3[i] = i + col4[i] = i*0.01 + col5[i] = i*0.01 + col6[i] = i*100 + col7[i] = i*10000 + col8[i] = i*100 + col9[i] = str(i*100) + col10[i] = i*100 + col11[i] = i*100 + sys.stdout.write(".") + + # Set ASCII table + tbl_ascii = GFitsAsciiTable() + #tbl_ascii.append_column(col1) # Need to implement ?/! + #tbl_ascii.append_column(col2) # Need to implement ?/! + tbl_ascii.append_column(col3) + tbl_ascii.append_column(col4) + tbl_ascii.append_column(col5) + tbl_ascii.append_column(col6) + tbl_ascii.append_column(col7) + tbl_ascii.append_column(col8) + tbl_ascii.append_column(col9) + tbl_ascii.append_column(col10) + tbl_ascii.append_column(col11) + tbl_ascii.extname("ASCII table") + fits.append(tbl_ascii) + sys.stdout.write(".") + + # Set binary table + tbl_bin = GFitsBinTable() + tbl_bin.append_column(col1) + tbl_bin.append_column(col2) + tbl_bin.append_column(col3) + tbl_bin.append_column(col4) + tbl_bin.append_column(col5) + tbl_bin.append_column(col6) + tbl_bin.append_column(col7) + tbl_bin.append_column(col8) + tbl_bin.append_column(col9) + tbl_bin.append_column(col10) + tbl_bin.append_column(col11) + tbl_bin.extname("Binary table") + fits.append(tbl_bin) + sys.stdout.write(".") + + # Save FITS file + #sys.stdout.write(fits+"\n") + fits.save() + sys.stdout.write(".") + + # Close FITS file + fits.close() + sys.stdout.write(".") + + # Re-open FITS file + fits = GFits(file1) + sys.stdout.write(".") + + # Get double precision image, take square root of pixel and save in + # another file + img_double = cast_GFitsImageDouble(fits.image("Double")) + for x in range(nx): + for y in range(ny): + img_double[x,y] = sqrt(img_double[x,y]) + #img_byte = cast_GFitsImageByte(fits.image("Double")) + sys.stdout.write(".") + + # Save into another FITS file + fits.saveto(file2) + sys.stdout.write(".") + + # Close FITS file + fits.close() + sys.stdout.write(".") + + # Return + return diff --git a/test/test_GLinalg.py b/test/test_GLinalg.py new file mode 100755 index 0000000..211dd18 --- /dev/null +++ b/test/test_GLinalg.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib linalg module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ===================================== # +# Test class for GammaLib linalg module # +# ===================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib linalg module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("linalg") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return diff --git a/test/test_GModel.py b/test/test_GModel.py new file mode 100755 index 0000000..869a95c --- /dev/null +++ b/test/test_GModel.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib model module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ==================================== # +# Test class for GammaLib model module # +# ==================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib model module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("model") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return diff --git a/test/test_GNumerics.py b/test/test_GNumerics.py new file mode 100755 index 0000000..a8d6b7e --- /dev/null +++ b/test/test_GNumerics.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib numerics module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ======================================= # +# Test class for GammaLib numerics module # +# ======================================= # +class Test(GPythonTestSuite): + """ + Test class for GammaLib numerics module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("numerics") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return diff --git a/test/test_GObs.py b/test/test_GObs.py new file mode 100755 index 0000000..a697c40 --- /dev/null +++ b/test/test_GObs.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib obs module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ================================== # +# Test class for GammaLib obs module # +# ================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib obs module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("obs") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return diff --git a/test/test_GOpt.py b/test/test_GOpt.py new file mode 100755 index 0000000..719dc80 --- /dev/null +++ b/test/test_GOpt.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib opt module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ================================== # +# Test class for GammaLib opt module # +# ================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib opt module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("opt") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return diff --git a/test/test_GSky.py b/test/test_GSky.py new file mode 100755 index 0000000..3c008d4 --- /dev/null +++ b/test/test_GSky.py @@ -0,0 +1,211 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib sky module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ================================== # +# Test class for GammaLib sky module # +# ================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib sky module. + """ + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("sky") + + # Append tests + self.append(self.test_skymap_healpix, "Test HEALPix map") + self.append(self.test_skymap_car, "Test CAR projection map") + self.append(self.test_skymap_tan, "Test TAN projection map") + self.append(self.test_skymap_stg, "Test STG projection map") + self.append(self.test_skymap_azp, "Test AZP projection map") + + # Return + return + + + # Generic skymap pixel transformation test + def test_skymap_pixels(self, pixels, map): + """ + Control coordinate and pixel transformation methods. + """ + # Control pix2dir / dir2pix methods for all pixels + for i in range(pixels.npix()): + dir = pixels.pix2dir(i) + ipix = pixels.dir2pix(dir) + msg = map + " pix2dir/dir2pix check for pixel "+str(i) + err = map + " GSkymap trouble with pixel "+str(i)+" ("+str(ipix)+ \ + "), RA="+str(dir.ra()*180/pi)+", Dec="+str(dir.dec()*180/pi) + self.test_assert(i == ipix, msg, err) + + # Control SkyDir coordinate transformation for all pixels + for i in range(pixels.npix()): + dir = pixels.pix2dir(i) + dir_new = GSkyDir() + dir_new.lb(dir.l(),dir.b()) + dra = abs(dir.ra() - dir_new.ra()) + if (dra >= 5.0): + dra -= 2.0*pi + ddec = abs(dir.dec() - dir_new.dec()) + msg = map + " dir check for pixel "+str(i) + err = map + " GSkymap trouble with pixel "+str(i)+" ("+str(dra)+ \ + ","+str(ddec)+")" + self.test_assert(not (dra > 1.0e-9 or ddec > 1.0e-9), msg, err) + + # Return + return + + + # Generic skymap projection test + def test_skymap_proj(self, proj): + """ + Test skymap projection. + """ + # Set filename + file = "test_python_skymap_"+proj+".fits" + + # Remove test files + try: + os.remove(file) + except: + pass + + # Create skymap + pixels = GSkymap(proj, "CEL", 83.6331, 22.0145, -3.7, 2.6, 5, 5, 20) + for map in range(pixels.nmaps()): + for i in range(pixels.npix()): + pixels[i,map] = i+map*pixels.npix() + pixels.save(file) + + # Test coordinate and pixel transformations + self.test_skymap_pixels(pixels, proj) + + # Return + return + + + # Test HEALPix projection + def test_skymap_healpix(self): + """ + Test HEALPix interface. + """ + # Set filenames + file1 = "test_python_skymap_hpx_v1.fits" + file2 = "test_python_skymap_hpx_v2.fits" + + # Remove test files + try: + os.remove(file1) + os.remove(file2) + except: + pass + + # Create HEALPix skymap + pixels = GSkymap("HPX", "GAL", 2, "RING", 2) + for i in range(pixels.npix()): + pixels[i] = i+1.0 + pixels[i,1] = i+1.0 + 1000.0 + pixels.save(file1) + + # Load HEALPix skymap + pixels = GSkymap(file1) + + # Control coordinate and pixel transformations + self.test_skymap_pixels(pixels, "HEALPix") + + # Save HEALPix skymap twice. The second saving should fail. + try: + pixels.save(file2, True) + pixels.save(file2) + except RuntimeError: + pass + else: + raise RuntimeError("*** TEST ERROR: FITS file overwritten!") + pixels.save(file2, True) + + # Load again HEALPix skymap + pixels = GSkymap(file1) + + # Return + return + + + # Test CAR projection + def test_skymap_car(self): + """ + Test CAR projection. + """ + # Execute generic test + self.test_skymap_proj("CAR") + + # Return + return + + + # Test TAN projection + def test_skymap_tan(self): + """ + Test TAN projection. + """ + # Execute generic test + self.test_skymap_proj("TAN") + + # Return + return + + + # Test STG projection + def test_skymap_stg(self): + """ + Test STG projection. + """ + # Execute generic test + self.test_skymap_proj("STG") + + # Return + return + + + # Test AZP projection + def test_skymap_azp(self): + """ + Test AZP projection. + """ + # Execute generic test + self.test_skymap_proj("AZP") + + # Return + return diff --git a/test/test_GSupport.py b/test/test_GSupport.py new file mode 100755 index 0000000..4c05722 --- /dev/null +++ b/test/test_GSupport.py @@ -0,0 +1,89 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib support module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# =============================== # +# Test class for GammaLib support # +# =============================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib support. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + # Set all test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("support") + + # Append tests + self.append(self.test_node_array, "Test GNodeArray") + + # Return + return + + # Test GNodeArray class + def test_node_array(self): + """ + Test GNodeArray class. + """ + # Set-up vector and data array. Test all vector elements. + vector = GVector(20) + data = GVector(20) + for i in range(20): + vector[i] = 10.0 + i*5.0 + data[i] = sin(0.15*(vector[i]-10.0)) + self.test_value(data[i], sin(0.15*i*5.0)) + + # Set-up node array + array = GNodeArray() + array.nodes(vector) + + # Get values + x_val = [] + y_val = [] + for i in range(100): + x = i-10 + array.set_value(x) + inx_left = array.inx_left() + inx_right = array.inx_right() + wgt_left = array.wgt_left() + wgt_right = array.wgt_right() + y = wgt_left*data[inx_left] + wgt_right*data[inx_right] + x_val.append(x) + y_val.append(y) + + # Return + return diff --git a/test/test_GTest.py b/test/test_GTest.py new file mode 100755 index 0000000..774b517 --- /dev/null +++ b/test/test_GTest.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib test module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# =================================== # +# Test class for GammaLib test module # +# =================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib test module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("test") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return diff --git a/test/test_GXml.py b/test/test_GXml.py new file mode 100755 index 0000000..a9cdf3e --- /dev/null +++ b/test/test_GXml.py @@ -0,0 +1,65 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib xml module. +# +# Copyright (C) 2012 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ================================== # +# Test class for GammaLib xml module # +# ================================== # +class Test(GPythonTestSuite): + """ + Test class for GammaLib xml module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("xml") + + # Append tests + self.append(self.test, "Dummy test") + + # Return + return + + + # Test function + def test(self): + """ + Test function. + """ + # Return + return -- libgit2 0.21.4