Ejemplo n.º 1
0
def test_schaffer2_bound_fail(outbound):
    """Test schaffer2 bound exception"""
    with pytest.raises(ValueError):
        x = outbound(b["schaffer2"].low,
                     b["schaffer2"].high,
                     tol=200,
                     size=(3, 2))
        fx.schaffer2_func(x)
Ejemplo n.º 2
0
    def test_schaffer2_bound_fail(self):
        """Test schaffer2 bound exception"""
        x = - np.random.uniform(low=100.001,high=1000,size=(3,2))
        x_ = np.random.uniform(low=100.001,high=1000,size=(3,2))

        with self.assertRaises(ValueError):
            fx.schaffer2_func(x)
        with self.assertRaises(ValueError):
            fx.schaffer2_func(x_)
Ejemplo n.º 3
0
def test_schaffer2_output(common_minima):
    """Test schaffer2 function output."""
    assert np.isclose(fx.schaffer2_func(common_minima), np.zeros(3)).all()
Ejemplo n.º 4
0
def test_schaffer2_dim_fail(outdim):
    """Test schaffer2 dim exception"""
    with pytest.raises(IndexError):
        fx.schaffer2_func(outdim)
Ejemplo n.º 5
0
 def test_schaffer2_output_size(self):
     """Test schaffer2 output size."""
     self.assertEqual(fx.schaffer2_func(self.input).shape, self.target_size)
Ejemplo n.º 6
0
 def test_schaffer2_output(self):
     """Test schaffer2 function output."""
     assert np.isclose(fx.schaffer2_func(self.input), self.target).all()
Ejemplo n.º 7
0
 def test_schaffer2_dim_fail(self):
     """Test schaffer2 dim exception"""
     with self.assertRaises(IndexError):
         fx.schaffer2_func(self.bad_input)
Ejemplo n.º 8
0
def test_schaffer2_output_size(common_minima, targetdim):
    """Test schaffer2 output size."""
    assert fx.schaffer2_func(common_minima).shape == targetdim