diff --git a/ChangeLog b/ChangeLog index 1fa0f60..d50d41b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2018-10-18 +2018-11-03 * Version 1.6.0 released ======================== + Add code generator (#2709) Add csbkgmodel script (#2694) Compute DETX and DETY in ctmodel if they are not available (#2694) Do no longer set missing boundaries in ctool::get_observations and diff --git a/NEWS b/NEWS index 54343c5..44d5d2a 100755 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.6.0 -18 October 2018 +3 November 2018 Introduction @@ -11,6 +11,12 @@ ctools release with respect to the precedent release. Configuration ------------- +A Code Generator was added to the development directory that can be started +using dev/codegen.py and that requires GammaLib to be installed. The code +generator allows adding ctools and cscripts, including unit tests and code +documentation, that are fully functional. The developer then only needs to +fill the skeleton with the relevant code (#2709). + Keep existing library path in installation script on Mac OS X (#2420). diff --git a/cscripts/csspec.py b/cscripts/csspec.py index 1790122..a0fb9cc 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -61,7 +61,7 @@ class csspec(ctools.csobservation): # Return return - # State methods por pickling + # State methods for pickling def __getstate__(self): """ Extend ctools.csobservation getstate method to include some members diff --git a/dev/codegen.py b/dev/codegen.py index 2ff9dba..c5f8dc9 100755 --- a/dev/codegen.py +++ b/dev/codegen.py @@ -143,13 +143,13 @@ def add_file(infile, outfile, tokens): # If we have a header line than format the line if is_header_ast: - text = line.strip(' *\n') + text = line.strip(' *\n')+' ' if n_header == 2: line = ' *'+gammalib.centre(text,73)+'*\n' elif n_header == 4: line = ' *'+gammalib.left(' '+text,73)+'*\n' if is_header_hash: - text = line.strip('#\n') + text = line.strip('#\n')+' ' line = '#'+text[0:75]+'#\n' # Write out line @@ -162,12 +162,12 @@ def add_file(infile, outfile, tokens): return -# ========== # -# Set tokens # -# ========== # -def set_tokens(classname, author, what, basename): +# ================ # +# Set ctool tokens # +# ================ # +def set_ctool_tokens(classname, basename, what, author, email, affiliation): """ - Set replacement tokens for a ctool or cscript + Set replacement tokens for a ctool """ # Get current year year = str(date.today().year) @@ -180,6 +180,34 @@ def set_tokens(classname, author, what, basename): {'pattern': '[WHAT]', 'string': what}, {'pattern': '[what]', 'string': what.lower()}, {'pattern': '[AUTHOR]', 'string': author}, + {'pattern': '[EMAIL]', 'string': email}, + {'pattern': '[AFFILIATION]', 'string': affiliation}, + {'pattern': '[YEAR]', 'string': year}] + + # Return tokens + return tokens + + +# ================== # +# Set cscript tokens # +# ================== # +def set_cscript_tokens(classname, basename, what, author, email, affiliation): + """ + Set replacement tokens for a cscript + """ + # Get current year + year = str(date.today().year) + + # Set tokens + tokens = [{'pattern': 'cscript_%s' % basename, 'string': classname}, + {'pattern': 'CSCRIPT_%s' % basename.upper(), 'string': classname.upper()}, + {'pattern': 'xxx', 'string': classname}, + {'pattern': 'XXX', 'string': classname.upper()}, + {'pattern': '[WHAT]', 'string': what}, + {'pattern': '[what]', 'string': what.lower()}, + {'pattern': '[AUTHOR]', 'string': author}, + {'pattern': '[EMAIL]', 'string': email}, + {'pattern': '[AFFILIATION]', 'string': affiliation}, {'pattern': '[YEAR]', 'string': year}] # Return tokens @@ -191,12 +219,12 @@ def set_tokens(classname, author, what, basename): # ========= # def add_ctool(name, tokens, baseclass): """ - Add an instrument class + Add a ctool Parameters ---------- name : str - ctool or script name + ctool name tokens : str Tokens for replacement baseclass : str @@ -285,12 +313,87 @@ def add_ctool(name, tokens, baseclass): return -# ============ # -# Manage ctool # -# ============ # +# =========== # +# Add cscript # +# =========== # +def add_cscript(name, tokens, baseclass): + """ + Add a cscript + + Parameters + ---------- + name : str + cscript name + tokens : str + Tokens for replacement + baseclass : str + Baseclass + """ + # Set template file names + pytemp = 'src/template/cscript_%s.py' % (baseclass) + partemp = 'src/template/cscript.par' + testtemp = 'src/template/cscript_test.py' + doctemp = 'src/template/cscript.rst' + + # Set destination file names + pyfile = 'cscripts/%s.py' % (name) + parfile = 'cscripts/%s.par' % (name) + testfile = 'test/test_%s.py' % (name) + docfile = 'doc/source/users/reference_manual/%s.rst' % (name) + + # Add files + add_file(pytemp, pyfile, tokens) + add_file(partemp, parfile, tokens) + add_file(testtemp, testfile, tokens) + add_file(doctemp, docfile, tokens) + + # Set file permissions + os.chmod(pyfile, 0o755) + + # Update cscripts/__init__.py.in file + for line in fileinput.FileInput('cscripts/__init__.py.in',inplace=1): + if '"csworkflow",' in line: + print(' "%s",' % (name)) + elif 'from cscripts.csworkflow import csworkflow' in line: + print('from cscripts.%s import %s' % (name, name)) + print line, + + # Update cscripts/Makefile.am file + for line in fileinput.FileInput('cscripts/Makefile.am',inplace=1): + if '$(srcdir)/csworkflow.py' in line: + print(' $(srcdir)/%s.py \\' % (name)) + elif '$(srcdir)/csworkflow.par' in line: + print(' $(srcdir)/%s.par \\' % (name)) + elif 'csworkflow \\' in line: + print(' %s \\' % (name)) + elif '$(top_srcdir)/test/test_csworkflow.py' in line: + print(' $(top_srcdir)/test/test_%s.py \\' % (name)) + print line, + + # Update test/test_python_cscripts.py file + for line in fileinput.FileInput('test/test_python_cscripts.py',inplace=1): + if 'import test_csworkflow' in line: + print('import test_%s' % (name)) + elif 'test_csworkflow.Test()' in line: + print(' test_%s.Test(),' % (name)) + print line, + + # Update reference manual index file + for line in fileinput.FileInput('doc/source/users/reference_manual/index.rst',inplace=1): + if 'csbkgmodel --- Generates background model for 3D analysis ' in line: + print(' %s --- ToDo: Describe what script is doing <%s>' % (name, name)) + print line, + + # Return + return + + +# ========== # +# ctool menu # +# ========== # def ctool_menu(): """ - Manage ctool + ctool menu """ # Annonce actions print("") @@ -300,10 +403,8 @@ def ctool_menu(): # Stay in loop until there is a final confirmation while True: - # Enter information + # Enter tool name ctoolname = response('Please enter a ctool name (e.g. "ctpntsim")') - what = response('Please say what the tool is for (e.g. "Pointing simulation")') - author = response('Please enter your name (e.g. "Joe Public")') # Enter baseclass print('From which baseclass should the ctool derive?') @@ -326,17 +427,25 @@ def ctool_menu(): basename = 'like' baseclass = 'ctlikelihood' + # Enter further information + what = response('Please say what the tool is for (e.g. "Pointing simulation")') + author = response('Please enter your name (e.g. "Joe Public")') + email = response('Please enter your e-mail (e.g. "joe.public@dot.com")') + affiliation = response('Please enter your affiliation (e.g. "ESA")') + # Ask to confirm module summary print('\nAll right. Have now:') - print('ctool name ......: "%s"' % ctoolname) - print('Tools descriptor : "%s"' % what) - print('Your name .......: "%s"' % author) - print('Base class ......: "%s"' % baseclass) + print('ctool name .......: "%s"' % ctoolname) + print('Base class .......: "%s"' % baseclass) + print('Tools descriptor .: "%s"' % what) + print('Your name ........: "%s"' % author) + print('Your e-mail ......: "%s"' % email) + print('Your affiliation .: "%s"' % affiliation) if confirm('Is this correct?'): break # Set tokens - tokens = set_tokens(ctoolname, author, what, basename) + tokens = set_ctool_tokens(ctoolname, basename, what, author, email, affiliation) # Add ctool add_ctool(ctoolname, tokens, basename) @@ -345,6 +454,72 @@ def ctool_menu(): return +# ============ # +# cscript menu # +# ============ # +def cscript_menu(): + """ + cscript menu + """ + # Annonce actions + print("") + print("Add cscript") + print("-----------") + + # Stay in loop until there is a final confirmation + while True: + + # Enter tool name + cscriptname = response('Please enter a cscript name (e.g. "cspntsim")') + + # Enter baseclass + print('From which baseclass should the cscript derive?') + print('[1] cscript') + print('[2] csobservation') + print('[3] cslikelihood') + waiting = True + choice = 1 + while waiting: + choice = str(raw_input('Enter your choice: ')) + if choice == '1' or choice == '2' or choice == '3': + waiting = False + if choice == '1': + basename = 'base' + baseclass = 'cscript' + elif choice == '2': + basename = 'obs' + baseclass = 'csobservation' + elif choice == '3': + basename = 'like' + baseclass = 'cslikelihood' + + # Enter further information + what = response('Please say what the script is for (e.g. "Pointing simulation")') + author = response('Please enter your name (e.g. "Joe Public")') + email = response('Please enter your e-mail (e.g. "joe.public@dot.com")') + affiliation = response('Please enter your affiliation (e.g. "ESA")') + + # Ask to confirm module summary + print('\nAll right. Have now:') + print('cscript name .....: "%s"' % cscriptname) + print('Base class .......: "%s"' % baseclass) + print('Script descriptor : "%s"' % what) + print('Your name ........: "%s"' % author) + print('Your e-mail ......: "%s"' % email) + print('Your affiliation .: "%s"' % affiliation) + if confirm('Is this correct?'): + break + + # Set tokens + tokens = set_cscript_tokens(cscriptname, basename, what, author, email, affiliation) + + # Add cscript + add_cscript(cscriptname, tokens, basename) + + # Return + return + + # ================ # # Manage main menu # # ================ # diff --git a/doc/source/admin/release_history/1.6.rst b/doc/source/admin/release_history/1.6.rst index 52d434c..77dbf6d 100644 --- a/doc/source/admin/release_history/1.6.rst +++ b/doc/source/admin/release_history/1.6.rst @@ -15,6 +15,7 @@ In particular, this release provides: * Improved computation speed for :ref:`ctskymap` and :ref:`csphagen` * Parallelisation of various cscripts * Support for Python pickeling +* A Code Generator to facilitate adding ctools and cscripts Bug fixes @@ -90,6 +91,8 @@ Improvements New features ------------ +* [`2709 `_] - + Add code generator * [`2694 `_] - Add :ref:`csbkgmodel` script * [`2421 `_] - diff --git a/src/template/Makefile.am b/src/template/Makefile.am index 29b2e15..44ef0f0 100755 --- a/src/template/Makefile.am +++ b/src/template/Makefile.am @@ -46,18 +46,25 @@ ctool_like_CPPFLAGS = @CPPFLAGS@ ctool_like_LDADD = $(top_builddir)/src/support/libsupport.la # Extra files to be distributed in the tar file -EXTRA_DIST = ctool.par \ +EXTRA_DIST = cscript.par \ + cscript.rst \ + cscript_base.py \ + cscript_like.py \ + cscript_obs.py \ + cscript_test.py \ + ctool.par \ + ctool.rst \ ctool_base.cpp \ ctool_base.hpp \ ctool_base.i \ - main_base.cpp \ ctool_like.cpp \ ctool_like.hpp \ ctool_like.i \ - main_like.cpp \ + ctool_Makefile.am \ ctool_obs.cpp \ ctool_obs.hpp \ ctool_obs.i \ - main_obs.cpp \ - ctool_Makefile.am \ - ctool_test.py + ctool_test.py \ + main_base.cpp \ + main_like.cpp \ + main_obs.cpp diff --git a/src/template/cscript.par b/src/template/cscript.par new file mode 100755 index 0000000..3e08b06 --- /dev/null +++ b/src/template/cscript.par @@ -0,0 +1,28 @@ +############################################################################# +# # +# CTA Science Analysis Tools # +# # +# ------------------------------------------------------------------------- # +# # +# File: xxx.par # +# # +# Author: [AUTHOR] # +# [EMAIL] # +# [AFFILIATION] # +# # +# Purpose: Parameter file for the xxx script # +# # +############################################################################# +# +# General parameters +#=================== +# Your parameters go here + +# +# Standard parameters +#==================== +chatter, i, h, 2,0,4, "Chattiness of output" +clobber, b, h, yes,,, "Overwrite existing output files with new output files?" +debug, b, h, no,,, "Activate debugging mode?" +mode, s, h, ql,,, "Mode of automatic parameters" +logfile, f, h, xxx.log,,, "Log filename" diff --git a/src/template/cscript.rst b/src/template/cscript.rst new file mode 100755 index 0000000..fb8f232 --- /dev/null +++ b/src/template/cscript.rst @@ -0,0 +1,54 @@ +.. _xxx: + +xxx +============================== + +ToDo: Describe in a one liner what the script is doing. + + +Synopsis +-------- + +ToDo: Desribe in detail what the script is doing, what it takes on input and +what it produces on output. Please do not write more than 80 characters per +line since this file is also used to produce a help text for the terminal. + + +General parameters +------------------ + +ToDo: Add here your parameters. + + +Standard parameters +------------------- + +``(chatter = 2) [integer]`` + Verbosity of the executable: + ``chatter = 0``: no information will be logged + + ``chatter = 1``: only errors will be logged + + ``chatter = 2``: errors and actions will be logged + + ``chatter = 3``: report about the task execution + + ``chatter = 4``: detailed report about the task execution + +``(clobber = yes) [boolean]`` + Specifies whether an existing output file should be overwritten. + +``(debug = no) [boolean]`` + Enables debug mode. In debug mode the executable will dump any log file output to the console. + +``(mode = ql) [string]`` + Mode of automatic parameters (default is ``ql``, i.e. "query and learn"). + +``(logfile = xxx.log) [string]`` + Name of log file. + + +Related tools or scripts +------------------------ + +None diff --git a/src/template/cscript_base.py b/src/template/cscript_base.py new file mode 100755 index 0000000..f512eab --- /dev/null +++ b/src/template/cscript_base.py @@ -0,0 +1,136 @@ +#! /usr/bin/env python +# ========================================================================== +# [WHAT] script +# +# Copyright (C) [YEAR] [AUTHOR] +# +# 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 . +# +# ========================================================================== +import sys +import gammalib +import ctools + + +# ================== # +# cscript_base class # +# ================== # +class cscript_base(ctools.cscript): + """ + [WHAT] script + """ + + # Constructor + def __init__(self, *argv): + """ + Constructor + + Parameters + ---------- + argv : list of str + List of IRAF command line parameter strings of the form + ``parameter=3``. + """ + # Initialise application by calling the base class constructor + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) + + # Return + return + + # State methods for pickling + def __getstate__(self): + """ + Extend ctools.cscript __getstate__ method + + Returns + ------- + state : dict + Pickled instance + """ + # Set pickled dictionary + state = {'base' : ctools.cscript.__getstate__(self)} + + # Return pickled dictionary + return state + + def __setstate__(self, state): + """ + Extend ctools.cscript __setstate__ method + + Parameters + ---------- + state : dict + Pickled instance + """ + # Set state + ctools.cscript.__setstate__(self, state['base']) + + # Return + return + + + # Private methods + def _get_parameters(self): + """ + Get parameters from parfile + """ + # TODO: Add code to query all relevant parameters + + # Write input parameters into logger + self._log_parameters(gammalib.TERSE) + + # Return + return + + + # Public methods + def run(self): + """ + Run the script + """ + # Switch screen logging on in debug mode + if self._logDebug(): + self._log.cout(True) + + # Get parameters + self._get_parameters() + + # TODO: Your code goes here + + # Return + return + + def save(self): + """ + Save something + """ + # Write header + self._log_header1(gammalib.TERSE, 'Save something') + + # TODO: Your code goes here + + # Return + return + + +# ======================== # +# Main routine entry point # +# ======================== # +if __name__ == '__main__': + + # Create instance of application + app = cscript_base(sys.argv) + + # Execute application + app.execute() diff --git a/src/template/cscript_like.py b/src/template/cscript_like.py new file mode 100755 index 0000000..560eec9 --- /dev/null +++ b/src/template/cscript_like.py @@ -0,0 +1,136 @@ +#! /usr/bin/env python +# ========================================================================== +# [WHAT] script +# +# Copyright (C) [YEAR] [AUTHOR] +# +# 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 . +# +# ========================================================================== +import sys +import gammalib +import ctools + + +# ================== # +# cscript_like class # +# ================== # +class cscript_like(ctools.cslikelihood): + """ + [WHAT] script + """ + + # Constructor + def __init__(self, *argv): + """ + Constructor + + Parameters + ---------- + argv : list of str + List of IRAF command line parameter strings of the form + ``parameter=3``. + """ + # Initialise application by calling the base class constructor + self._init_cslikelihood(self.__class__.__name__, ctools.__version__, argv) + + # Return + return + + # State methods for pickling + def __getstate__(self): + """ + Extend ctools.cslikelihood __getstate__ method + + Returns + ------- + state : dict + Pickled instance + """ + # Set pickled dictionary + state = {'base' : ctools.cslikelihood.__getstate__(self)} + + # Return pickled dictionary + return state + + def __setstate__(self, state): + """ + Extend ctools.cslikelihood __setstate__ method + + Parameters + ---------- + state : dict + Pickled instance + """ + # Set state + ctools.cslikelihood.__setstate__(self, state['base']) + + # Return + return + + + # Private methods + def _get_parameters(self): + """ + Get parameters from parfile + """ + # TODO: Add code to query all relevant parameters + + # Write input parameters into logger + self._log_parameters(gammalib.TERSE) + + # Return + return + + + # Public methods + def run(self): + """ + Run the script + """ + # Switch screen logging on in debug mode + if self._logDebug(): + self._log.cout(True) + + # Get parameters + self._get_parameters() + + # TODO: Your code goes here + + # Return + return + + def save(self): + """ + Save something + """ + # Write header + self._log_header1(gammalib.TERSE, 'Save something') + + # TODO: Your code goes here + + # Return + return + + +# ======================== # +# Main routine entry point # +# ======================== # +if __name__ == '__main__': + + # Create instance of application + app = cscript_like(sys.argv) + + # Execute application + app.execute() diff --git a/src/template/cscript_obs.py b/src/template/cscript_obs.py new file mode 100755 index 0000000..63125e9 --- /dev/null +++ b/src/template/cscript_obs.py @@ -0,0 +1,136 @@ +#! /usr/bin/env python +# ========================================================================== +# [WHAT] script +# +# Copyright (C) [YEAR] [AUTHOR] +# +# 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 . +# +# ========================================================================== +import sys +import gammalib +import ctools + + +# ================= # +# cscript_obs class # +# ================= # +class cscript_obs(ctools.csobservation): + """ + [WHAT] script + """ + + # Constructor + def __init__(self, *argv): + """ + Constructor + + Parameters + ---------- + argv : list of str + List of IRAF command line parameter strings of the form + ``parameter=3``. + """ + # Initialise application by calling the base class constructor + self._init_csobservation(self.__class__.__name__, ctools.__version__, argv) + + # Return + return + + # State methods for pickling + def __getstate__(self): + """ + Extend ctools.csobservation __getstate__ method + + Returns + ------- + state : dict + Pickled instance + """ + # Set pickled dictionary + state = {'base' : ctools.csobservation.__getstate__(self)} + + # Return pickled dictionary + return state + + def __setstate__(self, state): + """ + Extend ctools.csobservation __setstate__ method + + Parameters + ---------- + state : dict + Pickled instance + """ + # Set state + ctools.csobservation.__setstate__(self, state['base']) + + # Return + return + + + # Private methods + def _get_parameters(self): + """ + Get parameters from parfile + """ + # TODO: Add code to query all relevant parameters + + # Write input parameters into logger + self._log_parameters(gammalib.TERSE) + + # Return + return + + + # Public methods + def run(self): + """ + Run the script + """ + # Switch screen logging on in debug mode + if self._logDebug(): + self._log.cout(True) + + # Get parameters + self._get_parameters() + + # TODO: Your code goes here + + # Return + return + + def save(self): + """ + Save something + """ + # Write header + self._log_header1(gammalib.TERSE, 'Save something') + + # TODO: Your code goes here + + # Return + return + + +# ======================== # +# Main routine entry point # +# ======================== # +if __name__ == '__main__': + + # Create instance of application + app = cscript_obs(sys.argv) + + # Execute application + app.execute() diff --git a/src/template/cscript_test.py b/src/template/cscript_test.py new file mode 100755 index 0000000..8721fb2 --- /dev/null +++ b/src/template/cscript_test.py @@ -0,0 +1,157 @@ +#! /usr/bin/env python +# ========================================================================== +# This scripts performs unit tests for the xxx script. +# +# Copyright (C) [YEAR] [AUTHOR] +# +# 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 . +# +# ========================================================================== +import os +import gammalib +import cscripts +from testing import test + + +# ========================= # +# Test class for xxx script # +# ========================= # +class Test(test): + """ + Test class for xxx script + + This test class makes unit tests for the xxx script by using it from + the command line and from Python. + """ + + # Constructor + def __init__(self): + """ + Constructor + """ + # Call base class constructor + test.__init__(self) + + # Return + return + + # Set test functions + def set(self): + """ + Set all test functions + """ + # Set test name + self.name('xxx') + + # Append tests + self.append(self._test_cmd, 'Test xxx on command line') + self.append(self._test_python, 'Test xxx from Python') + self.append(self._test_pickeling, 'Test xxx pickeling') + + # Return + return + + # Test xxx on command line + def _test_cmd(self): + """ + Test xxx on the command line + """ + # Set script name + xxx = self._script('xxx') + + # Setup xxx command + cmd = xxx+' logfile="xxx_cmd1.log" chatter=1' + + # Check if execution was successful + self.test_value(self._execute(cmd), 0, + 'Check successful execution from command line') + + # Check xxx --help + self._check_help(xxx) + + # Return + return + + # Test xxx from Python + def _test_python(self): + """ + Test xxx from Python + """ + # Allocate xxx + script = cscripts.xxx() + + # Check that saving does not nothing + script['logfile'] = 'xxx_py0.log' + script.logFileOpen() + script.save() + self.test_assert(not os.path.isfile('xxx_py0.fits'), + 'Check that no FITS file has been created') + + # Check that clearing does not lead to an exception or segfault + script.clear() + + # Now set xxx parameters + script['logfile'] = 'xxx_py1.log' + script['chatter'] = 2 + + # Run xxx script + script.logFileOpen() + script.run() + + # Check result + self._check_result(script) + + # Return + return + + # Test xxx pickeling + def _test_pickeling(self): + """ + Test xxx pickeling + """ + # Perform pickeling test of empty class + self._pickeling(cscripts.xxx()) + + # Setup script for pickling text + script = cscripts.xxx() + script['logfile'] = 'xxx_py1_pickle.log' + script['chatter'] = 2 + + # Perform pickeling tests of filled class + obj = self._pickeling(script) + + # Run xxx script and save result + obj.logFileOpen() # Make sure we get a log file + obj.run() + obj.save() + + # TODO: Check result file + + # Return + return + + # Check xxx result + def _check_result(self, script): + """ + Check content of script + + Parameters + ---------- + script : `~cscripts.xxx` + xxx instance + """ + # TODO: Implement test on script result + + # Return + return diff --git a/src/template/ctool.par b/src/template/ctool.par index d6bacab..4696851 100755 --- a/src/template/ctool.par +++ b/src/template/ctool.par @@ -6,9 +6,9 @@ # # # File: xxx.par # # # -# Author: Juergen Knoedlseder # -# Jurgen.Knodlseder@irap.omp.eu # -# IRAP # +# Author: [AUTHOR] # +# [EMAIL] # +# [AFFILIATION] # # # # Purpose: Parameter file for the xxx tool # # # diff --git a/src/template/ctool.rst b/src/template/ctool.rst index 35886b4..18655e0 100755 --- a/src/template/ctool.rst +++ b/src/template/ctool.rst @@ -44,7 +44,7 @@ Standard parameters ``(mode = ql) [string]`` Mode of automatic parameters (default is ``ql``, i.e. "query and learn"). -``(logfile = ctbin.log) [string]`` +``(logfile = xxx.log) [string]`` Name of log file. diff --git a/src/template/ctool_test.py b/src/template/ctool_test.py index 598d3ce..f9f7e9c 100755 --- a/src/template/ctool_test.py +++ b/src/template/ctool_test.py @@ -123,7 +123,8 @@ class Test(test): cpy_tool.logFileOpen() cpy_tool.run() - # TODO: Check result + # Check result + self._check_result(cpy_tool) # Return return @@ -131,7 +132,7 @@ class Test(test): # Check xxx result def _check_result(self, tool): """ - Check content of an observation + Check content of tool Parameters ----------