Commit 254f39d245e5d9a35eef11bc01795567f565f6ac

Authored by Jürgen Knödlseder
1 parent 79b33a66

Make Python 3 compatible.

Showing 1 changed file with 31 additions and 12 deletions
inst/lat/test/test_python.py
1 1 #! /usr/bin/env python
  2 +# ==========================================================================
  3 +# This script tests the Fermi-LAT analysis.
  4 +#
  5 +# Requires:
  6 +# - matplotlib
  7 +# - numpy
  8 +#
  9 +# Copyright (C) 2012 Jurgen Knodlseder
  10 +#
  11 +# This program is free software: you can redistribute it and/or modify
  12 +# it under the terms of the GNU General Public License as published by
  13 +# the Free Software Foundation, either version 3 of the License, or
  14 +# (at your option) any later version.
  15 +#
  16 +# This program is distributed in the hope that it will be useful,
  17 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  18 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19 +# GNU General Public License for more details.
  20 +#
  21 +# You should have received a copy of the GNU General Public License
  22 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  23 +#
  24 +# ==========================================================================
2 25  
3 26 from gammalib import *
4 27 from math import *
... ... @@ -44,7 +67,7 @@ def analyse_unbinned(xmlname):
44 67 # Perform optimization
45 68 opt = GOptimizerLM()
46 69 obs.optimize(opt)
47   - print obs
  70 + print(obs)
48 71  
49 72  
50 73 # =================== #
... ... @@ -74,14 +97,14 @@ def analyse_binned(xmlname):
74 97 log.cout(True)
75 98 opt = GOptimizerLM(log)
76 99 obs.optimize(opt)
77   - print obs
78   - print opt
  100 + print(obs)
  101 + print(opt)
79 102  
80 103 # Plot residuals
81 104 try:
82 105 plot_residuals(obs)
83 106 except ImportError:
84   - print "Matplotlib is not (correctly) installed on your system."
  107 + print("Matplotlib is not (correctly) installed on your system.")
85 108  
86 109  
87 110 # ============= #
... ... @@ -161,14 +184,10 @@ if __name__ == &#39;__main__&#39;:
161 184 Perform testing.
162 185 """
163 186 # Dump result
164   - print
165   - print "**************************************"
166   - print "* Fermi-LAT Python interface testing *"
167   - print "**************************************"
168   -
169   - # Initialise success counter
170   - tests = 0
171   - success = 0
  187 + print("")
  188 + print("**************************************")
  189 + print("* Fermi-LAT Python interface testing *")
  190 + print("**************************************")
172 191  
173 192 # Analyse data
174 193 # analyse_unbinned("data/p7v6/crab_model.xml")
... ...