Changeset 465 for trunk

Show
Ignore:
Timestamp:
09/04/10 00:07:14 (21 months ago)
Author:
emuller
Message:

MERGE branches/parameter_set_schema_validation [449:464] into trunk - implements ParameterSchema? and validation

Location:
trunk
Files:
1 removed
2 modified
10 copied

Legend:

Unmodified
Added
Removed
  • trunk/setup.py

    r451 r465  
    1414                'NeuroTools.spike2.sonpy', 
    1515                'NeuroTools.datastore', 
     16                'NeuroTools.parameters', 
    1617                'NeuroTools.datastore.django_orm', 
    1718                'NeuroTools.optimize', 
  • trunk/test/test_parameters.py

    r355 r465  
    8686        ps2 = ParameterSet({'a': 1, 'b':2}) 
    8787        self.assertEqual(ps1, ps2) 
     88 
     89    def test_create_from_flat_iterator(self): 
     90        ps = ParameterSet({'a':1, 'b':2}, label="PS1") 
     91        ps2 = ParameterSet({'ps':ps, 'c':19}, label="PS2") 
     92        ps3 = ParameterSet({'hello': 'world', 'ps2': ps2, 'null': None, 
     93                            'true': False, 'mylist': [1,2,3,4], 
     94                            'mydict': {'c': 3, 'd':4}, 'yourlist': [1,2,{'e':5, 'f':6}], 
     95                            }, label="PS3") 
     96        ps4 = ParameterSet({}) 
     97        for x in ps3.flat(): 
     98            ps4.flat_add(x[0],x[1]) 
     99        self.assertEqual(ps4, ps3) 
     100 
    88101         
    89102    def test_create_with_syntax_error(self): 
     
    95108    def test_create_with_invalid_initialiser(self): 
    96109        self.assertRaises(TypeError, ParameterSet, object) 
     110 
     111    def test_create_yaml_url(self): 
     112        import tempfile, yaml 
     113 
     114        conf1_str = """ 
     115        # user info 
     116        username: joe 
     117        email:  joe@example.com 
     118 
     119        # recipes 
     120        recipes: 
     121           all: /somewhere1/file1.xml 
     122           specific: /somewhere2/file2.xml 
     123        """ 
     124 
     125        ps = ParameterSet 
     126         
     127        tf = tempfile.NamedTemporaryFile(suffix='.yaml') 
     128        tf.file.writelines(conf1_str) 
     129         
     130        tf.file.flush() 
     131        tf.file.seek(0) 
     132 
     133        ps = ParameterSet("file://"+tf.name) 
     134 
     135        tf.close() 
     136 
     137        ps1 = ParameterSet(yaml.load(conf1_str)) 
     138        assert ps1 == ps 
     139         
     140         
     141         
     142 
    97143     
    98144class ParameterSetSaveLoadTest(unittest.TestCase):