Author: bugman Date: Sat Jan 5 19:02:54 2008 New Revision: 4356 URL: http://svn.gna.org/viewcvs/relax?rev=4356&view=rev Log: Started to convert the model-free system tests to the new unittest framework. The relaxation data reading test has been converted, but no other tests are currently functional. Modified: 1.3/test_suite/system_tests/__init__.py 1.3/test_suite/system_tests/main.py 1.3/test_suite/system_tests/model_free.py Modified: 1.3/test_suite/system_tests/__init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/__init__.py?rev=4356&r1=4355&r2=4356&view=diff ============================================================================== --- 1.3/test_suite/system_tests/__init__.py (original) +++ 1.3/test_suite/system_tests/__init__.py Sat Jan 5 19:02:54 2008 @@ -28,6 +28,7 @@ # relax system/functional test module imports. from test_pipe_create import Test_pipe_create +from model_free import Mf __all__ = ['angles', @@ -61,6 +62,7 @@ # Create the test suite (add your new TestCase classes here). suite = TestLoader().loadTestsFromTestCase(Test_pipe_create) + suite = TestLoader().loadTestsFromTestCase(Mf) # Add the relax namespace to each TestCase object. for test in suite._tests: Modified: 1.3/test_suite/system_tests/main.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/main.py?rev=4356&r1=4355&r2=4356&view=diff ============================================================================== --- 1.3/test_suite/system_tests/main.py (original) +++ 1.3/test_suite/system_tests/main.py Sat Jan 5 19:02:54 2008 @@ -32,7 +32,6 @@ from diffusion_tensor import Diffusion_tensor from generic import Generic from jw_mapping import Jw -from model_free import Mf from model_selection import Modsel from relax_fit import Relax_fit from sequence import Sequence @@ -129,40 +128,6 @@ # Execute the tests. self.exec_tests(self.relax_fit_test_array) - - - # Model-free tests. - ################### - - # Heading. - heading("The model-free tests") - - # Initialise the array containing each test element. - self.mf_test_array = [] - - # User function results.read() test. - self.mf_test_array.append(Mf(self.relax, 'read relaxation data')) - self.mf_test_array.append(Mf(self.relax, 'set csa')) - self.mf_test_array.append(Mf(self.relax, 'set bond length')) - self.mf_test_array.append(Mf(self.relax, 'set csa and bond length')) - self.mf_test_array.append(Mf(self.relax, 'select m4')) - self.mf_test_array.append(Mf(self.relax, 'create m4')) - self.mf_test_array.append(Mf(self.relax, 'read results')) - self.mf_test_array.append(Mf(self.relax, 'opendx {S2, te, Rex} map')) - self.mf_test_array.append(Mf(self.relax, 'opendx {theta, phi, Da} map')) - self.mf_test_array.append(Mf(self.relax, 'opendx {local_tm, S2, te} map')) - self.mf_test_array.append(Mf(self.relax, 'Constrained grid search {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained SD, backtracking opt {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained SD, MT opt {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained CD, backtracking opt {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained CD, MT opt {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained BFGS, backtracking opt {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained BFGS, backtracking opt {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained Newton, GMW, backtracking opt {S2=0.970, te=2048, Rex=0.149}')) - self.mf_test_array.append(Mf(self.relax, 'Constrained Newton, GMW, MT opt {S2=0.970, te=2048, Rex=0.149}')) - - # Execute the tests. - self.exec_tests(self.mf_test_array) # Reduced spectral density mapping tests. @@ -329,21 +294,6 @@ summary_line(test.name, test.passed) - # Model-free tests. - ################### - - # Heading. - sys.stdout.write("\nThe model-free tests:\n") - - # Loop over the tests. - for test in self.mf_test_array: - # Synopsis. - global_pass = global_pass and test.passed - - # Print the summary line. - summary_line(test.name, test.passed) - - # Reduced spectral density Mapping tests. ######################################### Modified: 1.3/test_suite/system_tests/model_free.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/model_free.py?rev=4356&r1=4355&r2=4356&view=diff ============================================================================== --- 1.3/test_suite/system_tests/model_free.py (original) +++ 1.3/test_suite/system_tests/model_free.py Sat Jan 5 19:02:54 2008 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2006-2007 Edward d'Auvergne # +# Copyright (C) 2006-2008 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -23,30 +23,30 @@ # Python module imports. from math import pi import sys +from unittest import TestCase # relax module imports. from data import Data as relax_data_store from physical_constants import N15_CSA, NH_BOND_LENGTH -# The relax data storage object. - - - - -class Mf: - def __init__(self, relax, test_name): - """Class for testing various aspects specific to model-free analysis.""" - - self.relax = relax - - # Relaxation data reading test. - if test_name == 'read relaxation data': - # The name of the test. - self.name = "The user function relax_data.read()" - - # The test. - self.test = self.read_relax_data +class Mf(TestCase): + """TestCase class for the functional tests of model-free analysis.""" + + def setUp(self): + """Set up for all the functional tests.""" + + # Create the data pipe. + self.relax.interpreter._Pipe.create('mf', 'mf') + + + def tearDown(self): + """Reset the relax data storage object.""" + + relax_data_store.__reset__() + + + def old_code(self): # Test of setting the CSA. if test_name == 'set csa': @@ -925,11 +925,8 @@ self.relax.interpreter._Model_free.select_model(model='m4') - def read_relax_data(self, pipe): - """The relaxation data reading test.""" - - # Create the data pipe. - self.relax.interpreter._Pipe.create(pipe, 'mf') + def test_read_relax_data(self): + """Reading of relaxation data using the user function relax_data.read().""" # Path of the files. path = sys.path[-1] + '/test_suite/system_tests/data/model_free/S2_0.970_te_2048_Rex_0.149' @@ -940,17 +937,12 @@ # Read the relaxation data. self.relax.interpreter._Relax_data.read('R1', '600', 600.0 * 1e6, 'r1.600.out', dir=path) - # Test the data. - if relax_data_store[pipe].mol[0].res[1].spin[0].relax_data[0] != 1.3874977659397683: - print "The relaxation data does not match." - return - - # Test the error. - if relax_data_store[pipe].mol[0].res[1].spin[0].relax_error[0] != 0.027749955318795365: - print "The relaxation error does not match." - return - - return 1 + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Test the data and error. + self.assertEqual(cdp.mol[0].res[1].spin[0].relax_data[0], 1.3874977659397683) + self.assertEqual(cdp.mol[0].res[1].spin[0].relax_error[0], 0.027749955318795365) def read_results(self, pipe):