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