code: def test_select_new_region_of_interest(space, n_levels, threshold):
      EPSILON = 1e-5
      factorial_importance_analysis = []
      for i, key in enumerate(space.keys()):
          factorial_importance_analysis.append(
              (key, i % n_levels + 1, 0.1 * (i % n_levels))
          )
      factorial_importance_analysis = pd.DataFrame(
          factorial_importance_analysis,
          columns=["param", "best_level", "importance"],
      )
  
      new_space, frozen_param_values = select_new_region_of_interest(
          factorial_importance_analysis, space, threshold, n_levels
      )
  
      tested_dim = set()
      for _, row in factorial_importance_analysis[
          factorial_importance_analysis["importance"] < threshold
      ].iterrows():
          tested_dim.add(str(row["param"]))
          assert row["param"] in frozen_param_values
          assert (
              frozen_param_values[row["param"]]
              == sum(space[row["param"]].interval()) / 2.0
          )
  
      for _, row in factorial_importance_analysis[
          factorial_importance_analysis["importance"] >= threshold
      ].iterrows():
          dim_name = str(row["param"])
          tested_dim.add(dim_name)
          assert dim_name in new_space
          assert new_space[dim_name].type == space[dim_name].type
          # New ROI in smaller than original space
          assert (
              space[dim_name].interval()[0] - EPSILON
              <= new_space[dim_name].interval()[0]
          )
          assert (
              space[dim_name].interval()[1] + EPSILON
              >= new_space[dim_name].interval()[1]
          )
          low, high = space[dim_name].interval()
          intervals = (high - low) / n_levels
          new_low = low + intervals * (int(row["best_level"]) - 1)
          # New ROI is correct level
          assert new_space[dim_name].interval()[0] == new_low
          assert (
              new_space[dim_name].interval()[1] == new_low + intervals
          )
  
      assert tested_dim == set(space.keys())
  
file_path: orion/tests/unittests/algo/mofa/test_analysis.py
imports: import itertools
  import numpy
  import pandas
  import pytest
  from orion.algo.mofa.mofa import MOFA, get_factorial_importance_analysis, get_factorial_performance_analysis, select_new_region_of_interest
  from orion.algo.mofa.transformer import Transformer
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 8 for calling a global function with example usage: test_select_new_region_of_interest(space, n_levels, threshold) without return types