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_)
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()
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)
def test_goldstein_dim_fail(outdim): """Test goldstein dim exception""" with pytest.raises(IndexError): fx.goldstein_func(outdim)
def test_goldstein_output_size(self): """Test goldstein output size.""" self.assertEqual(fx.goldstein_func(self.input).shape, self.target_size)
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()
def test_goldstein_dim_fail(self): """Test golstein dim exception""" with self.assertRaises(IndexError): fx.goldstein_func(self.bad_input)
def test_goldstein_output_size(common_minima, targetdim): """Test goldstein output size.""" assert fx.goldstein_func(common_minima).shape == targetdim