Пример #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)
Пример #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_)
Пример #3
0
def test_schaffer2_output(common_minima):
    """Test schaffer2 function output."""
    assert np.isclose(fx.schaffer2_func(common_minima), np.zeros(3)).all()
Пример #4
0
def test_schaffer2_dim_fail(outdim):
    """Test schaffer2 dim exception"""
    with pytest.raises(IndexError):
        fx.schaffer2_func(outdim)
Пример #5
0
 def test_schaffer2_output_size(self):
     """Test schaffer2 output size."""
     self.assertEqual(fx.schaffer2_func(self.input).shape, self.target_size)
Пример #6
0
 def test_schaffer2_output(self):
     """Test schaffer2 function output."""
     assert np.isclose(fx.schaffer2_func(self.input), self.target).all()
Пример #7
0
 def test_schaffer2_dim_fail(self):
     """Test schaffer2 dim exception"""
     with self.assertRaises(IndexError):
         fx.schaffer2_func(self.bad_input)
Пример #8
0
def test_schaffer2_output_size(common_minima, targetdim):
    """Test schaffer2 output size."""
    assert fx.schaffer2_func(common_minima).shape == targetdim