class_docstr: Defing unit tests for Multi-fidelity Cartesian Product GPs. 
class_docstr_tok: ["Defing","unit","tests","for","Multi-fidelity","Cartesian","Product","GPs","."]
docstr: Tests fitting and creation. 
docstr_tok: ["Tests","fitting","and","creation","."]
code: def test_gp_fitting_and_creation(self):
      """Tests fitting and creation."""
      self.report(
          "Testing fitting Multi-fidelity Cartesian Product GPs. "
          + "Probabilistic test, might fail."
      )
      num_successes = 0
      for idx, dataset in enumerate(self.cpmfgp_datasets):
          fit_start_time = time()
          fitted_gp = fit_cpmfgp_with_dataset(dataset)
          fit_end_time = time()
          fit_time = fit_end_time - fit_start_time
          lml = fitted_gp.compute_log_marginal_likelihood()
          gp_preds, _ = fitted_gp.eval_at_fidel(
              dataset.ZZ_test, dataset.XX_test, uncert_form="none"
          )
          preds_with_eval_func, _ = fitted_gp.eval(
              dataset.ZX_test, uncert_form="none"
          )
          diff_eval_err = self._compute_rmse(
              gp_preds, preds_with_eval_func
          )
          test_succ, test_str = self._test_prediction(
              gp_preds, dataset.YY_test, dataset.YY_train
          )
          self.report(
              "[%d/%d] Fitted GP: lml=%0.4f, GP=%s, time taken=%0.4fs."
              % (
                  idx + 1,
                  len(self.cpmfgp_datasets),
                  lml,
                  fitted_gp,
                  fit_time,
              ),
              "test_result",
          )
          self.report(
              "   Test result: %s, diff_eval_err=%0.4f."
              % (test_str, diff_eval_err),
              "test_result",
          )
          self.report(
              "   fidel_space=%s." % (dataset.config.fidel_space),
              "test_result",
          )
          self.report(
              "   domain=%s." % (dataset.config.domain), "test_result"
          )
          num_successes += test_succ
          assert diff_eval_err < 1e-5 * np.linalg.norm(gp_preds)
      success_frac = num_successes / float(self.num_datasets)
      self.report(
          "Num successes = %d/%d (%0.4f).\n"
          % (num_successes, self.num_datasets, success_frac),
          "test_result",
      )
      assert success_frac > 0.5
  
imports: from argparse import Namespace
  import numpy
  import os
  from time import time
  from ..exd.cp_domain_utils import load_cp_domain_from_config_file, get_processed_func_from_raw_func_for_cp_domain, get_processed_func_from_raw_func_via_config, load_config_file, sample_from_config_space
  from .None import cartesian_product_gp
  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.park2_4.park2_4 import park2_4
  from ..test_data.park2_4.park2_4_mf import park2_4_mf
  from ..utils.base_test_class import BaseTestClass, execute_tests
  from ..utils.general_utils import map_to_bounds, get_idxs_from_list_of_lists
label_desc: Use image node_id 1 for calling the CPMFGPTestCaseDefinitions obj's underlying member method code with example usage: obj.test_gp_fitting_and_creation() without return types