Пример #1
0
    def test_levi_bound_fail(self):
        """Test levi bound exception"""
        x = - np.random.uniform(low=10.001,high=100,size=(3,2))
        x_ = np.random.uniform(low=10.001,high=100,size=(3,2))

        with self.assertRaises(ValueError):
            fx.levi_func(x)
        with self.assertRaises(ValueError):
            fx.levi_func(x_)
Пример #2
0
def test_levi_output(common_minima2):
    """Test levi function output."""
    assert np.isclose(fx.levi_func(common_minima2), np.zeros(3)).all()
Пример #3
0
def test_levi_bound_fail(outbound):
    """Test levi bound exception"""
    with pytest.raises(ValueError):
        x = outbound(b["levi"].low, b["levi"].high, size=(3, 2))
        fx.levi_func(x)
Пример #4
0
def test_levi_dim_fail(outdim):
    """Test levi dim exception"""
    with pytest.raises(IndexError):
        fx.levi_func(outdim)
Пример #5
0
 def test_levi_output_size(self):
     """Test levi output size."""
     self.assertEqual(fx.levi_func(self.input).shape, self.target_size)
Пример #6
0
 def test_levi_output(self):
     """Test levi function output."""
     assert np.isclose(fx.levi_func(self.input2), self.target).all()
Пример #7
0
 def test_levi_dim_fail(self):
     """Test levi dim exception"""
     with self.assertRaises(IndexError):
         fx.levi_func(self.bad_input)
Пример #8
0
def test_levi_output_size(common_minima, targetdim):
    """Test levi output size."""
    assert fx.levi_func(common_minima).shape == targetdim