Author: tlinnet Date: Wed Dec 3 21:39:12 2014 New Revision: 26945 URL: http://svn.gna.org/viewcvs/relax?rev=26945&view=rev Log: Split the systemtest Nmrglue.xtest_plot_contour into setup, test, and plot sub tests. Task #7873 (https://gna.org/task/index.php?7873): Write wrapper function to nmrglue, to read .ft2 files and process them. Homepage: http://www.nmrglue.com/ Link to nmrglue discussion: https://groups.google.com/forum/#!forum/nmrglue-discuss The code is develop at Github: https://github.com/jjhelmus/nmrglue/ Documentation: http://nmrglue.readthedocs.org/en/latest/index.html Modified: branches/nmrglue/test_suite/system_tests/nmrglue.py Modified: branches/nmrglue/test_suite/system_tests/nmrglue.py URL: http://svn.gna.org/viewcvs/relax/branches/nmrglue/test_suite/system_tests/nmrglue.py?rev=26945&r1=26944&r2=26945&view=diff ============================================================================== --- branches/nmrglue/test_suite/system_tests/nmrglue.py (original) +++ branches/nmrglue/test_suite/system_tests/nmrglue.py Wed Dec 3 21:39:12 2014 @@ -27,6 +27,7 @@ # relax module imports. from data_store import Relax_data_store; ds = Relax_data_store() +import dep_check from lib.errors import RelaxError from lib.io import file_root, get_file_list from pipe_control.nmrglue import plot_contour, plot_hist @@ -34,11 +35,34 @@ from test_suite.system_tests.base_classes import SystemTestCase from extern import nmrglue +# Dependent import. +# If not matplotlib module +if dep_check.matplotlib_module: + import matplotlib.pyplot as plt + class Nmrglue(SystemTestCase): """TestCase class for the functionality of the external module nmrglue. This is from U{Task #7873<https://gna.org/task/index.php?7873>}: Write wrapper function to nmrglue, to read .ft2 files and process them.""" + def plot_plot_contour(self): + """Plot the plot_contour function in pipe_control. + This is from the U{tutorial<http://jjhelmus.github.io/nmrglue/current/examples/plot_2d_spectrum.html>}.""" + + # Call setup function. + self.setup_plot_contour(show=False) + + # Set new limits. + ds.ax.set_xlim(30, 0) + ds.ax.set_ylim(15, -20) + + # add some labels + ds.ax.text(25.0, 0.0, "Test", size=8, color='r') + + # Now show + plt.show() + + def setUp(self): """Set up for all the functional tests.""" @@ -50,6 +74,19 @@ # Create path to nmrglue test data. ds.ng_test = status.install_path +sep+ 'extern' +sep+ 'nmrglue' +sep+ 'nmrglue_0_4' +sep+ 'tests' +sep+ 'pipe_proc_tests' + + + def setup_plot_contour(self, show=False): + """Setup the plot_contour function in pipe_control. + This is from the U{tutorial<http://jjhelmus.github.io/nmrglue/current/examples/plot_2d_spectrum.html>}.""" + + # Read the spectrum. + fname = 'freq_real.ft2' + sp_id = 'test' + self.interpreter.spectrum.nmrglue_read(file=fname, dir=ds.ng_test, spectrum_id=sp_id) + + # Call the pipe_control function and get the return axis. + ds.ax = plot_contour(spectrum_id=sp_id, ppm=True, show=show) def test_nmrglue_read(self): @@ -116,6 +153,14 @@ self.assertEqual(cdp.spectrum_ids[1], file_root_list[1]) + def test_plot_contour(self): + """Test the plot_contour function in pipe_control. + This is from the U{tutorial<http://jjhelmus.github.io/nmrglue/current/examples/plot_2d_spectrum.html>}.""" + + # Call setup function. + self.setup_plot_contour(show=False) + + def test_version(self): """Test version of nmrglue.""" @@ -125,30 +170,6 @@ # Assert the version to be 0.4. self.assertEqual(ng_vers, '0.4') - - - def xtest_plot_contour(self): - """Test the plot_contour function in pipe_control. - This is from the U{tutorial<http://jjhelmus.github.io/nmrglue/current/examples/plot_2d_spectrum.html>}.""" - - # Read the spectrum. - fname = 'freq_real.ft2' - sp_id = 'test' - self.interpreter.spectrum.nmrglue_read(file=fname, dir=ds.ng_test, spectrum_id=sp_id) - - # Call the pipe_control function and get the return axis. - ax = plot_contour(spectrum_id=sp_id, ppm=True, show=False) - - # Set new limits. - ax.set_xlim(30, 0) - ax.set_ylim(15, -20) - - # add some labels - ax.text(25.0, 0.0, "Test", size=8, color='r') - - # Now show - import matplotlib.pyplot as plt - plt.show() def xtest_plot_contour_cpmg(self):