def test_args_algorithm_iter(self):
     args = OptimizeArgs(iter=400)
     args.validate()
     cmd = args.compose(None, cmd=['output'])
     self.assertIn('iter=400', ' '.join(cmd))
     args = OptimizeArgs(iter=-1)
     self.assertRaises(ValueError, lambda: args.validate())
 def test_args_algorithm(self):
     args = OptimizeArgs(algorithm='non-valid_algorithm')
     self.assertRaises(ValueError, lambda: args.validate())
     args = OptimizeArgs(algorithm='Newton')
     args.validate()
     cmd = args.compose(None, cmd=['output'])
     self.assertIn('algorithm=newton', ' '.join(cmd))
Esempio n. 3
0
 def test_args_algorithm_init_alpha(self):
     args = OptimizeArgs(init_alpha=2e-4)
     args.validate()
     cmd = args.compose(None, 'output')
     self.assertIn('init_alpha=0.0002', cmd)
     args = OptimizeArgs(init_alpha=-1.0)
     self.assertRaises(ValueError, lambda: args.validate())
     args = OptimizeArgs(init_alpha=1.0, algorithm='Newton')
     self.assertRaises(ValueError, lambda: args.validate())
Esempio n. 4
0
    def test_args_algorithm_init_alpha(self):
        args = OptimizeArgs(init_alpha=2e-4)
        args.validate()
        cmd = args.compose(None, cmd=['output'])

        self.assertIn('init_alpha=0.0002', ' '.join(cmd))
        args = OptimizeArgs(init_alpha=-1.0)
        with self.assertRaises(ValueError):
            args.validate()
        args = OptimizeArgs(init_alpha=1.0, algorithm='Newton')
        with self.assertRaises(ValueError):
            args.validate()