示例#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()
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