Exemplo n.º 1
0
    def test_goldstein_bound_fail(self):
        """Test goldstein bound exception"""
        x = - np.random.uniform(low=2.00001,high=100,size=(3,2))
        x_ = np.random.uniform(low=2.00001,high=100,size=(3,2))

        with self.assertRaises(ValueError):
            fx.goldstein_func(x)
        with self.assertRaises(ValueError):
            fx.goldstein_func(x_)
Exemplo n.º 2
0
def test_goldstein_output(common_minima2):
    """Tests goldstein-price function output."""
    assert np.isclose(fx.goldstein_func([0, -1] * common_minima2),
                      (3 * np.ones(3))).all()
Exemplo n.º 3
0
def test_goldstein_bound_fail(outbound):
    """Test goldstein bound exception"""
    with pytest.raises(ValueError):
        x = outbound(b["goldstein"].low, b["goldstein"].high, size=(3, 2))
        fx.goldstein_func(x)
Exemplo n.º 4
0
def test_goldstein_dim_fail(outdim):
    """Test goldstein dim exception"""
    with pytest.raises(IndexError):
        fx.goldstein_func(outdim)
Exemplo n.º 5
0
 def test_goldstein_output_size(self):
     """Test goldstein output size."""
     self.assertEqual(fx.goldstein_func(self.input).shape, self.target_size)
Exemplo n.º 6
0
 def test_goldstein_output(self):
     """Tests goldstein-price function output."""
     assert np.isclose(fx.goldstein_func([0, -1] * self.input2),
         (3 * np.ones(3))).all()
Exemplo n.º 7
0
 def test_goldstein_dim_fail(self):
     """Test golstein dim exception"""
     with self.assertRaises(IndexError):
         fx.goldstein_func(self.bad_input)
Exemplo n.º 8
0
def test_goldstein_output_size(common_minima, targetdim):
    """Test goldstein output size."""
    assert fx.goldstein_func(common_minima).shape == targetdim