code: def test_params_to_array():
      space = TargetSpace(target_func, PBOUNDS)
  
      assert all(
          space.params_to_array({"p1": 2, "p2": 3}) == np.array([2, 3])
      )
      assert all(
          space.params_to_array({"p2": 2, "p1": 9}) == np.array([9, 2])
      )
      with pytest.raises(ValueError):
          space.params_to_array({"p2": 1})
      with pytest.raises(ValueError):
          space.params_to_array({"p2": 1, "p1": 7, "other": 4})
      with pytest.raises(ValueError):
          space.params_to_array({"other": 1})
  
imports: import pytest
  import numpy
  from bayes_opt.constraint import ConstraintModel
  from bayes_opt.target_space import TargetSpace
  from bayes_opt.util import NotUniqueError
label_desc: Use image node_id 3 for calling a global function with example usage: test_params_to_array() without return types