class_docstr: Unit test for Cartesian Product Function Caller. 
class_docstr_tok: ["Unit","test","for","Cartesian","Product","Function","Caller","."]
docstr: Unit test to test if the function callers are calling correctly. 
docstr_tok: ["Unit","test","to","test","if","the","function","callers","are","calling","correctly","."]
code: def test_all_functions(self):
      """Unit test to test if the function callers are calling correctly."""
      # pylint: disable=too-many-locals
      num_samples = 5
      test_data = self.test_function_data + self.mf_test_function_data
      num_noise_tests = 0.0
      num_noise_successes = 0.0
      for idx, (
          domain_config_file,
          raw_func,
          noise_type,
          noise_scale,
          raw_fidel_cost_func,
      ) in enumerate(test_data):
          config = cp_domain_utils.load_config_file(domain_config_file)
          func_caller = (
              experiment_caller.get_multifunction_caller_from_config(
                  raw_func,
                  domain_config_file,
                  raw_fidel_cost_func=raw_fidel_cost_func,
                  noise_type=noise_type,
                  noise_scale=noise_scale,
              )
          )
          proc_samples = cp_domain_utils.sample_from_config_space(
              config, num_samples
          )
          raw_samples = [
              cp_domain_utils.get_raw_from_processed_via_config(
                  x, config
              )
              for x in proc_samples
          ]
          if (
              hasattr(config, "fidel_space")
              and config.fidel_space is not None
          ):
              raw_vals = [raw_func(z, x) for (z, x) in raw_samples]
              fc_vals = [
                  func_caller.eval_at_fidel_single(z, x)[0]
                  for (z, x) in proc_samples
              ]
              # Check if the cost functions are evaluated properly
              raw_fidel_cost_vals = [
                  raw_fidel_cost_func(z) for z, _ in raw_samples
              ]
              fc_fidel_cost_vals = [
                  func_caller.fidel_cost_func(z)
                  for z, _ in proc_samples
              ]
              fidel_cost_err = np.linalg.norm(
                  np.array(raw_fidel_cost_vals)
                  - np.array(fc_fidel_cost_vals)
              )
              assert fidel_cost_err < 1e-4 * np.linalg.norm(
                  raw_fidel_cost_vals
              )
              fidel_cost_err_str = ", fidel_cost_err=%0.3f" % (
                  fidel_cost_err
              )
          else:
              raw_vals = [raw_func(x) for x in raw_samples]
              fc_vals = [
                  func_caller.eval_single(x)[0] for x in proc_samples
              ]
              fidel_cost_err_str = ""
          err = np.linalg.norm(np.array(raw_vals) - np.array(fc_vals))
          noise_scale = 0.0 if noise_type == "no_noise" else noise_scale
          noise_tolerance = 3 * noise_scale * np.sqrt(num_samples)
          is_succ = (
              err
              < 1e-4 * np.linalg.norm(np.array(raw_vals))
              + noise_tolerance
          )
          if noise_type == "no_noise":
              assert is_succ
          else:
              num_noise_tests += 1.0
              num_noise_successes += float(is_succ)
          self.report(
              "[%d/%d] Testing functionevals for %s, err=%0.5f, is_succ=%d%s."
              % (
                  idx + 1,
                  len(test_data),
                  domain_config_file,
                  err,
                  is_succ,
                  fidel_cost_err_str,
              ),
              "test_result",
          )
      self.report(
          "num_noise_successes/num_noise_tests = %d/%d."
          % (num_noise_successes, num_noise_tests),
          "test_result",
      )
      assert (
          num_noise_tests == 0
          or num_noise_successes / num_noise_tests > 0.75
      )
      self.report("", "")
  
imports: import os
  import numpy
  from .None import cp_domain_utils, experiment_caller
  from ..utils import euclidean_synthetic_functions
  from ..utils.base_test_class import BaseTestClass, execute_tests
  from ..utils.ancillary_utils import get_list_of_floats_as_str
  from ..test_data.park2_4.park2_4 import park2_4
  from ..test_data.park2_4.park2_4_mf import park2_4_mf
  from ..test_data.park2_4.park2_4_mf import cost
  from ..test_data.park1_3.park1_3 import park1_3
  from ..test_data.park1_3.park1_3_mf import park1_3_mf
  from ..test_data.park1_3.park1_3_mf import cost
label_desc: Use image node_id 2 for calling the CPFunctionCaller obj's underlying member method code with example usage: obj.test_all_functions() without return types