code: def test_single_constraint_upper():
      def target_function(x, y):
          return np.cos(2 * x) * np.cos(y) + np.sin(x)
  
      def constraint_function(x, y):
          return np.cos(x) * np.cos(y) - np.sin(x) * np.sin(y)
  
      constraint_limit_upper = 0.5
  
      constraint = NonlinearConstraint(
          constraint_function, -np.inf, constraint_limit_upper
      )
      pbounds = {"x": (0, 6), "y": (0, 6)}
  
      optimizer = BayesianOptimization(
          f=target_function,
          constraint=constraint,
          pbounds=pbounds,
          verbose=0,
          random_state=1,
      )
  
      optimizer.maximize(
          init_points=2,
          n_iter=10,
      )
  
      assert (
          constraint_function(**optimizer.max["params"])
          <= constraint_limit_upper
      )
  
file_path: BayesianOptimization/tests/test_constraint.py
imports: import numpy
  from bayes_opt import BayesianOptimization
  from pytest import approx, raises
  from scipy.optimize import NonlinearConstraint
label_desc: Use image node_id 1 for calling a global function with example usage: test_single_constraint_upper() and returns: unknown, unknown