"Fossies" - the Fresh Open Source Software Archive

Member "relax-5.0.0/test_suite/gui_tests/test_user_functions.py" (2 Dec 2019, 26723 Bytes) of package /linux/privat/relax-5.0.0.src.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "test_user_functions.py": 4.1.3_vs_5.0.0.

    1 ###############################################################################
    2 #                                                                             #
    3 # Copyright (C) 2012,2014,2016,2019 Edward d'Auvergne                         #
    4 #                                                                             #
    5 # This file is part of the program relax (http://www.nmr-relax.com).          #
    6 #                                                                             #
    7 # This program is free software: you can redistribute it and/or modify        #
    8 # it under the terms of the GNU General Public License as published by        #
    9 # the Free Software Foundation, either version 3 of the License, or           #
   10 # (at your option) any later version.                                         #
   11 #                                                                             #
   12 # This program is distributed in the hope that it will be useful,             #
   13 # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
   14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
   15 # GNU General Public License for more details.                                #
   16 #                                                                             #
   17 # You should have received a copy of the GNU General Public License           #
   18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
   19 #                                                                             #
   20 ###############################################################################
   21 
   22 """Module for testing the special features of the user function GUI windows."""
   23 
   24 # Python module imports.
   25 from os import path, sep
   26 import sys
   27 
   28 # relax module imports.
   29 import dep_check
   30 from status import Status; status = Status()
   31 from test_suite.gui_tests.base_classes import GuiTestCase
   32 
   33 # relax GUI imports.
   34 from gui.interpreter import Interpreter; interpreter = Interpreter()
   35 from gui.string_conv import float_to_gui, int_to_gui, str_to_gui
   36 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
   37 
   38 
   39 class User_functions(GuiTestCase):
   40     """Class for testing special features of the user function GUI windows."""
   41 
   42     def exec_uf_pipe_create(self, pipe_name=None, pipe_type='mf'):
   43         """Execute the pipe.create user function via the GUI user function window.
   44 
   45         @keyword pipe_name:     The pipe_name argument of the pipe.create user function.
   46         @type pipe_name:        str
   47         @keyword pipe_type:     The pipe_type argument of the pipe.create user function.
   48         @type pipe_type:        str
   49         """
   50 
   51         # Open the pipe.create user function window.
   52         uf = uf_store['pipe.create']
   53         uf._sync = True
   54         uf.create_wizard(parent=self.app.gui)
   55 
   56         # Set the arguments.
   57         uf.page.SetValue('pipe_name', str_to_gui(pipe_name))
   58         uf.page.SetValue('pipe_type', str_to_gui(pipe_type))
   59 
   60         # Execute.
   61         uf.wizard._go_next(None)
   62 
   63 
   64     def test_bug_2_structure_read_pdb_failure(self):
   65         """Catch U{bug #2<https://sourceforge.net/p/nmr-relax/tickets/2/>}, the failure of the structure.read_pdb user function.
   66 
   67         This was reported by U{Stefano Ciurli<https://sourceforge.net/u/stefanociurli/>}.
   68         """
   69 
   70         # Create the data pipe.
   71         self.exec_uf_pipe_create(pipe_name='structure.read_pdb user function failure test')
   72 
   73         # Open the structure.read_pdb user function window.
   74         uf = uf_store['structure.read_pdb']
   75         uf._sync = True
   76         uf.create_wizard(parent=self.app.gui)
   77 
   78         # The PDB file.
   79         file = path.join(status.install_path, 'test_suite', 'shared_data', 'structures', '1J7O.pdb')
   80 
   81         # Manually set the PDB file on the first text element - as this is not attached to a uf_args dictionary element!
   82         uf.page.GetChildren()[6].SetValue(str_to_gui(file))
   83 
   84         # Execute the user function.
   85         uf.wizard._go_next(None)
   86 
   87         # Check the structural data.
   88         self.assert_(hasattr(cdp, 'structure'))
   89         self.assert_(hasattr(cdp.structure, 'structural_data'))
   90         self.assertEqual(len(cdp.structure.structural_data), 3)
   91         self.assertEqual(cdp.structure.structural_data[0].num, 1)
   92         self.assertEqual(cdp.structure.structural_data[1].num, 2)
   93         self.assertEqual(cdp.structure.structural_data[2].num, 3)
   94 
   95 
   96     def test_bug_3_no_argument_validation(self):
   97         """Catch U{bug #3<https://sourceforge.net/p/nmr-relax/tickets/3/>}, the absence of user function argument validation in the GUI.
   98 
   99         Without argument validation, the structure.read_pdb user function would fail with the error::
  100 
  101             relax> pipe.create(pipe_name='validation_test', pipe_type='mf', bundle=None)
  102 
  103             relax> structure.read_pdb(file=None, dir=None, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, alt_loc=None, verbosity=1, merge=False)
  104             Traceback (most recent call last):
  105               File "/data/relax/relax/gui/interpreter.py", line 306, in run
  106                 fn(*args, **kwds)
  107               File "/data/relax/relax/pipe_control/structure/main.py", line 1277, in read_pdb
  108                 if not access(file_path, F_OK):
  109             TypeError: coercing to Unicode: need string or buffer, NoneType found
  110 
  111         However with validation, a RelaxStrFileError error is raised.   This is caught by the GUI, presenting a pop up window for the error, printing out the error text, but not raising the error.  Hence an error cannot be caught.
  112         """
  113 
  114         # Create the data pipe.
  115         self.exec_uf_pipe_create(pipe_name='user function argument validation test')
  116 
  117         # Open the structure.read_pdb user function window.
  118         uf = uf_store['structure.read_pdb']
  119         uf._sync = True
  120         uf.create_wizard(parent=self.app.gui)
  121 
  122         # Execute the user function with no arguments set.
  123         uf.wizard._go_next(None)
  124 
  125 
  126     def test_dx_map(self):
  127         """Test the operation of the dx.map user function GUI window."""
  128 
  129         # Open the dx.map user function window.
  130         uf = uf_store['dx.map']
  131         uf._sync = True
  132         uf.create_wizard(parent=self.app.gui)
  133 
  134         # Set the y-value of a single point, and check.
  135         uf.page.uf_args['point'].selection_win_show()
  136         if dep_check.wx_classic:
  137             uf.page.uf_args['point'].sel_win.sequence.SetStringItem(0, 2, int_to_gui(2))
  138         else:
  139             uf.page.uf_args['point'].sel_win.sequence.SetItem(0, 2, int_to_gui(2))
  140         uf.page.uf_args['point'].selection_win_data()
  141         points = uf.page.uf_args['point'].GetValue()
  142         print("Points:  %s" % points)
  143         self.assertEqual(len(points), 1)
  144         self.assertEqual(len(points[0]), 3)
  145         self.assertEqual(points[0][0], None)
  146         self.assertEqual(points[0][1], 2.0)
  147         self.assertEqual(points[0][2], None)
  148 
  149         # Set the point to nothing in the wizard, open the Sequence_2D window, close the window, and check that None comes back.
  150         uf.page.uf_args['point'].SetValue(str_to_gui(''))
  151         uf.page.uf_args['point'].selection_win_show()
  152         uf.page.uf_args['point'].selection_win_data()
  153         points = uf.page.uf_args['point'].GetValue()
  154         print("Points:  %s" % points)
  155         self.assertEqual(points, None)
  156 
  157         # Set a valid point in the wizard, open and close the Sequence_2D window (twice), and check that the point comes back.
  158         uf.page.uf_args['point'].SetValue(str_to_gui('[[1, 2, -3.]]'))
  159         uf.page.uf_args['point'].selection_win_show()
  160         uf.page.uf_args['point'].selection_win_data()
  161         uf.page.uf_args['point'].selection_win_show()
  162         uf.page.uf_args['point'].selection_win_data()
  163         points = uf.page.uf_args['point'].GetValue()
  164         print("Points:  %s" % points)
  165         self.assertEqual(len(points), 1)
  166         self.assertEqual(len(points[0]), 3)
  167         self.assertEqual(points[0][0], 1.0)
  168         self.assertEqual(points[0][1], 2.0)
  169         self.assertEqual(points[0][2], -3.0)
  170 
  171         # Set 2 valid points in the wizard, open and close the Sequence_2D window (twice), and check that the points come back.
  172         uf.page.uf_args['point'].SetValue(str_to_gui('[[1, 2, 3], [-2, -3, -4]]'))
  173         uf.page.uf_args['point'].selection_win_show()
  174         uf.page.uf_args['point'].selection_win_data()
  175         uf.page.uf_args['point'].selection_win_show()
  176         uf.page.uf_args['point'].selection_win_data()
  177         points = uf.page.uf_args['point'].GetValue()
  178         print("Points:  %s" % points)
  179         self.assertEqual(len(points), 2)
  180         self.assertEqual(len(points[0]), 3)
  181         self.assertEqual(len(points[1]), 3)
  182         self.assertEqual(points[0][0], 1.0)
  183         self.assertEqual(points[0][1], 2.0)
  184         self.assertEqual(points[0][2], 3.0)
  185         self.assertEqual(points[1][0], -2.0)
  186         self.assertEqual(points[1][1], -3.0)
  187         self.assertEqual(points[1][2], -4.0)
  188 
  189         # Set the points to a number of invalid values, checking that they are ignored.
  190         for val in ['2', 'die', '[1, 2, 3', '[1]', '[[1, 2, 3], 1, 2, 3], [1, 2, 3]]']:
  191             uf.page.uf_args['point'].SetValue(str_to_gui(val))
  192             uf.page.uf_args['point'].selection_win_show()
  193             uf.page.uf_args['point'].selection_win_data()
  194             points = uf.page.uf_args['point'].GetValue()
  195             print("Points:  %s" % points)
  196             self.assertEqual(points, None)
  197 
  198         # Set the Sequence_2D elements to invalid values.
  199         for val in ['x']:
  200             uf.page.uf_args['point'].SetValue(str_to_gui(''))
  201             uf.page.uf_args['point'].selection_win_show()
  202             if dep_check.wx_classic:
  203                 uf.page.uf_args['point'].sel_win.sequence.SetStringItem(0, 2, str_to_gui(val))
  204                 uf.page.uf_args['point'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(1))
  205             else:
  206                 uf.page.uf_args['point'].sel_win.sequence.SetItem(0, 2, str_to_gui(val))
  207                 uf.page.uf_args['point'].sel_win.sequence.SetItem(0, 1, int_to_gui(1))
  208             uf.page.uf_args['point'].selection_win_data()
  209             points = uf.page.uf_args['point'].GetValue()
  210             print("Points:  %s" % points)
  211             self.assertEqual(len(points), 1)
  212             self.assertEqual(len(points[0]), 3)
  213             self.assertEqual(points[0][0], 1.0)
  214             self.assertEqual(points[0][1], None)
  215             self.assertEqual(points[0][2], None)
  216 
  217 
  218     def test_spectrum_read_intensities(self):
  219         """Test the operation of the spectrum.read_intensities user function GUI window."""
  220 
  221         # Open the spectrum.read_intensities user function window.
  222         uf = uf_store['spectrum.read_intensities']
  223         uf._sync = True
  224         uf.create_wizard(parent=self.app.gui)
  225 
  226         # Set the y-value of a single pos, and check.
  227         uf.page.uf_args['file'].selection_win_show()
  228         uf.page.uf_args['file'].sel_win.SetValue('test_file')
  229         uf.page.uf_args['file'].selection_win_data()
  230         file = uf.page.uf_args['file'].GetValue()
  231         print("File names:  %s" % file)
  232         self.assert_(isinstance(file, str))
  233         self.assertEqual(file, 'test_file')
  234 
  235         # Set the file to nothing in the wizard, open the Sequence window, close the window, and check that None comes back.
  236         uf.page.uf_args['file'].SetValue(str_to_gui(''))
  237         uf.page.uf_args['file'].selection_win_show()
  238         uf.page.uf_args['file'].selection_win_data()
  239         file = uf.page.uf_args['file'].GetValue()
  240         print("File names:  %s" % file)
  241         self.assertEqual(file, None)
  242 
  243         # Set a valid file list in the wizard, open and close the Sequence window (twice), and check that the file comes back.
  244         uf.page.uf_args['file'].SetValue(str_to_gui("['test1', 'test2']"))
  245         uf.page.uf_args['file'].selection_win_show()
  246         uf.page.uf_args['file'].selection_win_data()
  247         uf.page.uf_args['file'].selection_win_show()
  248         uf.page.uf_args['file'].selection_win_data()
  249         file = uf.page.uf_args['file'].GetValue()
  250         print("File names:  %s" % file)
  251         self.assertEqual(len(file), 2)
  252         self.assertEqual(file[0], 'test1')
  253         self.assertEqual(file[1], 'test2')
  254 
  255         # Set the file to a number of invalid values, checking that they are ignored.
  256         for val in ["['1', '2', '3'", "['1'"]:
  257             uf.page.uf_args['file'].SetValue(str_to_gui(val))
  258             uf.page.uf_args['file'].selection_win_show()
  259             uf.page.uf_args['file'].selection_win_data()
  260             file = uf.page.uf_args['file'].GetValue()
  261             print("Invalid file: %s\nFile names:  %s" % (val, file))
  262             self.assertEqual(file, None)
  263 
  264 
  265     def test_structure_add_atom(self):
  266         """Test the operation of the structure.add_atom user function GUI window."""
  267 
  268         # Open the structure.add_atom user function window.
  269         uf = uf_store['structure.add_atom']
  270         uf._sync = True
  271         uf.create_wizard(parent=self.app.gui)
  272 
  273         # Set the y-value of a single pos, and check.
  274         #uf.page.uf_args['pos'].selection_win_show()
  275         #if dep_check.wx_classic:
  276         #    uf.page.uf_args['pos'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(2))
  277         #else:
  278         #    uf.page.uf_args['pos'].sel_win.sequence.SetItem(1, 1, int_to_gui(2))
  279         #uf.page.uf_args['pos'].selection_win_data()
  280         #pos = uf.page.uf_args['pos'].GetValue()
  281         #print("Pos:  %s" % pos)
  282         #self.assertEqual(len(pos), 3)
  283         #self.assertEqual(pos[0], None)
  284         #self.assertEqual(pos[1], 2.0)
  285         #self.assertEqual(pos[2], None)
  286 
  287         # Set the pos to nothing in the wizard, open the Sequence window, close the window, and check that None comes back.
  288         val = ''
  289         sys.stdout.write("Value: %40s;  " % repr(val))
  290         uf.page.uf_args['pos'].SetValue(str_to_gui(val))
  291         uf.page.uf_args['pos'].selection_win_show()
  292         uf.page.uf_args['pos'].selection_win_data()
  293         pos = uf.page.uf_args['pos'].GetValue()
  294         sys.stdout.write("Return: %40s\n" % repr(pos))
  295         self.assertEqual(pos, None)
  296 
  297         # Set a valid pos in the wizard, open and close the Sequence window (twice), and check that the pos comes back.
  298         val = '[1, 2, -3.]'
  299         sys.stdout.write("Value: %40s;  " % repr(val))
  300         uf.page.uf_args['pos'].SetValue(str_to_gui(val))
  301         uf.page.uf_args['pos'].selection_win_show()
  302         uf.page.uf_args['pos'].selection_win_data()
  303         uf.page.uf_args['pos'].selection_win_show()
  304         uf.page.uf_args['pos'].selection_win_data()
  305         pos = uf.page.uf_args['pos'].GetValue()
  306         sys.stdout.write("Return: %40s\n" % repr(pos))
  307         self.assertEqual(len(pos), 1)
  308         self.assertEqual(len(pos[0]), 3)
  309         self.assertEqual(pos[0][0], 1.0)
  310         self.assertEqual(pos[0][1], 2.0)
  311         self.assertEqual(pos[0][2], -3.0)
  312 
  313         # Set the pos to a number of invalid values, checking that they are ignored.
  314         for val in ['die', '[1, 2, 3', '[[1, 2, 3], 1, 2, 3], [1, 2, 3]]']:
  315             sys.stdout.write("Value: %40s;  " % repr(val))
  316             uf.page.uf_args['pos'].SetValue(str_to_gui(val))
  317             uf.page.uf_args['pos'].selection_win_show()
  318             uf.page.uf_args['pos'].selection_win_data()
  319             pos = uf.page.uf_args['pos'].GetValue()
  320             sys.stdout.write("Return: %40s\n" % repr(pos))
  321             self.assertEqual(pos, None)
  322 
  323         # Set the Sequence elements to invalid values.
  324         for val in ['x']:
  325             sys.stdout.write("Value: %40s;  " % repr(val))
  326             uf.page.uf_args['pos'].SetValue(str_to_gui(''))
  327             uf.page.uf_args['pos'].selection_win_show()
  328             uf.page.uf_args['pos'].sel_win.add_element()
  329             if dep_check.wx_classic:
  330                 uf.page.uf_args['pos'].sel_win.sequence.SetStringItem(1, 1, str_to_gui(val))
  331                 uf.page.uf_args['pos'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(1))
  332             else:
  333                 uf.page.uf_args['pos'].sel_win.sequence.SetItem(1, 1, str_to_gui(val))
  334                 uf.page.uf_args['pos'].sel_win.sequence.SetItem(0, 1, int_to_gui(1))
  335             uf.page.uf_args['pos'].selection_win_data()
  336             pos = uf.page.uf_args['pos'].GetValue()
  337             sys.stdout.write("Return: %40s\n" % repr(pos))
  338             #self.assertEqual(len(pos), 1)
  339             self.assertEqual(pos[0][0], 1.0)
  340             #self.assertEqual(pos[0][1], None)
  341             #self.assertEqual(pos[0][2], None)
  342 
  343 
  344     def test_structure_pdb_read(self):
  345         """Test the full operation of the structure.read_pdb user function GUI window."""
  346 
  347         # Create the data pipe.
  348         self.exec_uf_pipe_create(pipe_name='PDB reading test')
  349 
  350         # Open the structure.read_pdb user function window.
  351         uf = uf_store['structure.read_pdb']
  352         uf._sync = True
  353         uf.create_wizard(parent=self.app.gui)
  354 
  355         # The PDB file to operate on.
  356         file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'structures' + sep + 'trunc_ubi_pcs.pdb'
  357         uf.page.SetValue('file', str_to_gui(file))
  358 
  359         # Set the models to read.
  360         uf.page.SetValue('read_model', str_to_gui('6'))
  361         uf.page.uf_args['read_model'].selection_win_show()
  362         uf.page.uf_args['read_model'].sel_win.add_element(None)
  363         if dep_check.wx_classic:
  364             uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(2))
  365             uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(4))
  366         else:
  367             uf.page.uf_args['read_model'].sel_win.sequence.SetItem(0, 1, int_to_gui(2))
  368             uf.page.uf_args['read_model'].sel_win.sequence.SetItem(1, 1, int_to_gui(4))
  369         uf.page.uf_args['read_model'].selection_win_data()
  370 
  371         # Renumber the models.
  372         uf.page.uf_args['set_model_num'].selection_win_show()
  373         uf.page.uf_args['set_model_num'].sel_win.add_element(None)
  374         if dep_check.wx_classic:
  375             uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(1))
  376             uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(3))
  377         else:
  378             uf.page.uf_args['set_model_num'].sel_win.sequence.SetItem(0, 1, int_to_gui(1))
  379             uf.page.uf_args['set_model_num'].sel_win.sequence.SetItem(1, 1, int_to_gui(3))
  380         uf.page.uf_args['set_model_num'].selection_win_data()
  381 
  382         # GUI data checks.
  383         self.assertEqual(uf.page.uf_args['read_model'].GetValue(), [2, 4])
  384         self.assertEqual(uf.page.uf_args['set_model_num'].GetValue(), [1, 3])
  385 
  386         # Execute the user function.
  387         uf.wizard._go_next(None)
  388 
  389         # Check the structural data.
  390         self.assert_(hasattr(cdp, 'structure'))
  391         self.assert_(hasattr(cdp.structure, 'structural_data'))
  392         self.assertEqual(len(cdp.structure.structural_data), 2)
  393         self.assertEqual(cdp.structure.structural_data[0].num, 1)
  394         self.assertEqual(cdp.structure.structural_data[1].num, 3)
  395 
  396 
  397     def test_structure_rotate(self):
  398         """Test the operation of the structure.rotate user function GUI window."""
  399 
  400         # Create the data pipe.
  401         self.exec_uf_pipe_create(pipe_name='PDB rotation test')
  402 
  403         # Open the structure.read_pdb user function window.
  404         uf = uf_store['structure.read_pdb']
  405         uf._sync = True
  406         uf.create_wizard(parent=self.app.gui)
  407 
  408         # The PDB file to operate on.
  409         file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'structures' + sep + 'trunc_ubi_pcs.pdb'
  410         uf.page.SetValue('file', str_to_gui(file))
  411 
  412         # Set the models to read.
  413         uf.page.SetValue('read_model', str_to_gui('6'))
  414         uf.page.uf_args['read_model'].selection_win_show()
  415         uf.page.uf_args['read_model'].sel_win.add_element(None)
  416         if dep_check.wx_classic:
  417             uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(2))
  418             uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(4))
  419         else:
  420             uf.page.uf_args['read_model'].sel_win.sequence.SetItem(0, 1, int_to_gui(2))
  421             uf.page.uf_args['read_model'].sel_win.sequence.SetItem(1, 1, int_to_gui(4))
  422         uf.page.uf_args['read_model'].selection_win_data()
  423 
  424         # Renumber the models.
  425         uf.page.uf_args['set_model_num'].selection_win_show()
  426         uf.page.uf_args['set_model_num'].sel_win.add_element(None)
  427         if dep_check.wx_classic:
  428             uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(0, 1, int_to_gui(1))
  429             uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(3))
  430         else:
  431             uf.page.uf_args['set_model_num'].sel_win.sequence.SetItem(0, 1, int_to_gui(1))
  432             uf.page.uf_args['set_model_num'].sel_win.sequence.SetItem(1, 1, int_to_gui(3))
  433         uf.page.uf_args['set_model_num'].selection_win_data()
  434 
  435         # GUI data checks.
  436         self.assertEqual(uf.page.uf_args['read_model'].GetValue(), [2, 4])
  437         self.assertEqual(uf.page.uf_args['set_model_num'].GetValue(), [1, 3])
  438 
  439         # Execute the user function.
  440         uf.wizard._go_next(None)
  441 
  442         # Open the structure.rotate user function window.
  443         uf = uf_store['structure.rotate']
  444         uf._sync = True
  445         uf.create_wizard(parent=self.app.gui)
  446 
  447         # Change the rotation matrix in the Sequence_2D window, without changing anything, then check it.
  448         uf.page.uf_args['R'].selection_win_show()
  449         if dep_check.wx_classic:
  450             uf.page.uf_args['R'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(2))
  451         else:
  452             uf.page.uf_args['R'].sel_win.sequence.SetItem(1, 1, int_to_gui(2))
  453         uf.page.uf_args['R'].selection_win_data()
  454         R = uf.page.uf_args['R'].GetValue()
  455         print("Rotation matrix:\n%s" % R)
  456         self.assertEqual(len(R), 3)
  457         self.assertEqual(len(R[0]), 3)
  458         self.assertEqual(R[0][0], 1)
  459         self.assertEqual(R[0][1], 0)
  460         self.assertEqual(R[0][2], 0)
  461         self.assertEqual(R[1][0], 0)
  462         self.assertEqual(R[1][1], 2)
  463         self.assertEqual(R[1][2], 0)
  464         self.assertEqual(R[2][0], 0)
  465         self.assertEqual(R[2][1], 0)
  466         self.assertEqual(R[2][2], 1)
  467 
  468         # Set the rotation matrix to nothing in the wizard, open the Sequence_2D window, set a value, close the window, and check what happens.
  469         uf.page.uf_args['R'].SetValue(str_to_gui(''))
  470         uf.page.uf_args['R'].selection_win_show()
  471         if dep_check.wx_classic:
  472             uf.page.uf_args['R'].sel_win.sequence.SetStringItem(1, 1, int_to_gui(2))
  473         else:
  474             uf.page.uf_args['R'].sel_win.sequence.SetItem(1, 1, int_to_gui(2))
  475         uf.page.uf_args['R'].selection_win_data()
  476         R = uf.page.uf_args['R'].GetValue()
  477         print("Rotation matrix:\n%s" % R)
  478         self.assertEqual(len(R), 3)
  479         self.assertEqual(len(R[0]), 3)
  480         self.assertEqual(R[0][0], None)
  481         self.assertEqual(R[0][1], None)
  482         self.assertEqual(R[0][2], None)
  483         self.assertEqual(R[1][0], None)
  484         self.assertEqual(R[1][1], 2)
  485         self.assertEqual(R[1][2], None)
  486         self.assertEqual(R[2][0], None)
  487         self.assertEqual(R[2][1], None)
  488         self.assertEqual(R[2][2], None)
  489 
  490         # Set the rotation matrix to nothing in the wizard, open the Sequence_2D window, close the window, and check that None comes back.
  491         uf.page.uf_args['R'].SetValue(str_to_gui(''))
  492         uf.page.uf_args['R'].selection_win_show()
  493         uf.page.uf_args['R'].selection_win_data()
  494         R = uf.page.uf_args['R'].GetValue()
  495         print("Rotation matrix:\n%s" % R)
  496         self.assertEqual(R, None)
  497 
  498         # Set the rotation matrix to a number of invalid values, checking that they are ignored.
  499         for val in ['2', 'die', '[1, 2, 3]', '[1]', '[[1, 2, 3], 1, 2, 3], [1, 2, 3]]']:
  500             uf.page.uf_args['R'].SetValue(str_to_gui(val))
  501             uf.page.uf_args['R'].selection_win_show()
  502             uf.page.uf_args['R'].selection_win_data()
  503             R = uf.page.uf_args['R'].GetValue()
  504             print("Rotation matrix:\n%s" % R)
  505             self.assertEqual(R, None)
  506 
  507         # Set the Sequence_2D elements to invalid values.
  508         for val in ['x']:
  509             uf.page.uf_args['R'].SetValue(str_to_gui(''))
  510             uf.page.uf_args['R'].selection_win_show()
  511             if dep_check.wx_classic:
  512                 uf.page.uf_args['R'].sel_win.sequence.SetStringItem(1, 1, str_to_gui(val))
  513                 uf.page.uf_args['R'].sel_win.sequence.SetStringItem(0, 0, int_to_gui(1))
  514             else:
  515                 uf.page.uf_args['R'].sel_win.sequence.SetItem(1, 1, str_to_gui(val))
  516                 uf.page.uf_args['R'].sel_win.sequence.SetItem(0, 0, int_to_gui(1))
  517             uf.page.uf_args['R'].selection_win_data()
  518             R = uf.page.uf_args['R'].GetValue()
  519             print("Rotation matrix:\n%s" % R)
  520             self.assertEqual(len(R), 3)
  521             self.assertEqual(len(R[0]), 3)
  522             self.assertEqual(R[0][0], 1.0)
  523             self.assertEqual(R[0][1], None)
  524             self.assertEqual(R[0][2], None)
  525             self.assertEqual(R[1][0], None)
  526             self.assertEqual(R[1][1], None)
  527             self.assertEqual(R[1][2], None)
  528             self.assertEqual(R[2][0], None)
  529             self.assertEqual(R[2][1], None)
  530             self.assertEqual(R[2][2], None)
  531 
  532         # Check the structural data.
  533         self.assert_(hasattr(cdp, 'structure'))
  534         self.assert_(hasattr(cdp.structure, 'structural_data'))
  535         self.assertEqual(len(cdp.structure.structural_data), 2)
  536         self.assertEqual(cdp.structure.structural_data[0].num, 1)
  537         self.assertEqual(cdp.structure.structural_data[1].num, 3)
  538 
  539 
  540     def test_value_set(self):
  541         """Test the full operation of the value.set user function GUI window."""
  542 
  543         # Create the data pipe.
  544         self.exec_uf_pipe_create(pipe_name='value.set user function test')
  545 
  546         # Create a spin to add data to.
  547         uf = uf_store['spin.create']
  548         uf._sync = True
  549         uf.create_wizard(parent=self.app.gui)
  550         uf.page.SetValue('res_num', int_to_gui(1))
  551         uf.page.SetValue('res_name', str_to_gui('Gly'))
  552         uf.page.SetValue('spin_name', str_to_gui('N'))
  553         uf.wizard._go_next(None)
  554 
  555         # Open the value.set user function window.
  556         uf = uf_store['value.set']
  557         uf._sync = True
  558         uf.create_wizard(parent=self.app.gui)
  559         uf.page.SetValue('val', float_to_gui(-0.000172))
  560         uf.page.SetValue('param', str_to_gui('csa'))
  561         uf.wizard._go_next(None)