From 207474d527a8929a25569b11b1856c0fe2cdab30 Mon Sep 17 00:00:00 2001 From: "Knox S. Long" Date: Sun, 3 Sep 2017 15:31:34 -0500 Subject: [PATCH] Added a new python routine regression.py which is intended as a program to run a series of srhort python models for testing various aspects of the code. The models that are run are stored (by default) in the directory examples/regress. This is intended as way to partially address #292 --- examples/regress/1d_sn.pf | 1 + examples/regress/cv_standard.pf | 1 + py_progs/regression.py | 302 ++++++++++++++++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 120000 examples/regress/1d_sn.pf create mode 120000 examples/regress/cv_standard.pf create mode 100755 py_progs/regression.py diff --git a/examples/regress/1d_sn.pf b/examples/regress/1d_sn.pf new file mode 120000 index 000000000..9bf7145c4 --- /dev/null +++ b/examples/regress/1d_sn.pf @@ -0,0 +1 @@ +../core/1d_sn.pf \ No newline at end of file diff --git a/examples/regress/cv_standard.pf b/examples/regress/cv_standard.pf new file mode 120000 index 000000000..a3e3ee7d9 --- /dev/null +++ b/examples/regress/cv_standard.pf @@ -0,0 +1 @@ +../core/cv_standard.pf \ No newline at end of file diff --git a/py_progs/regression.py b/py_progs/regression.py new file mode 100755 index 000000000..f57165b60 --- /dev/null +++ b/py_progs/regression.py @@ -0,0 +1,302 @@ +#!/usr/bin/env python + +''' + Space Telescope Science Institute + +Synopsis: + +Execute a series of short python runs to test whether a version +of python is working. + + +Command line usage (if any): + + usage: regression.py [-np 3 -pf_dir test -out_dir foo] version + + where + + version the executable of python + -np 3 the number of processors with which to run (default 3) + -pf_dir test the directory containing all of the .pf files which will be run + The defaults is $PYTHON/examples/regress + -out_dir foo The directory (below the current working directory) where the + tests will run. The defauld is constructed for the version + and the data + +Description: + + The basic process is as follows + + 1. Create a directory in which to work and intialize it + 2. Copy all of the relevant .pf files to this directory + 3. Switch to the working directory and run all the models, performing + some basic checks + +Primary routines: + + doit: Internal routine which runs python on all of the pf files of interest. Use + this if working in a python shell + steer: A routine to parse the command lineh + check_one: A routine which oversees checking of the runs + +Notes: + + Regression here means to run a series of models. These routines do not compare the + models to earlier runs + +History: + +170903 ksl Coding begun + +''' + +import sys +from astropy.io import ascii +import numpy +from glob import glob +import time +import subprocess +import os +import shutil + + + + +def sum_errors(root='1d_sn'): + ''' + This sums the errors from various threads + + Note that this effectively duplicates a routine + py_error which James wrote, but in Python 3 + + + ''' + diag_files=glob('diag_%s/%s_*.diag' % (root,root)) + + errors=[] + for one in diag_files: + x=open(one) + lines=x.readlines() + lines=lines[len(lines)-100:] + test=False + for one_line in lines: + if test and one_line.count(' -- '): + errors.append(one_line) + if one_line.count('Recurrences -- Description'): + test=True + + # At this point we have the error but we need to parse them etc + + i=0 + error_names=[] + error_counts=[] + while i1: + steer(sys.argv) + else: + print(__doc__)