class_docstr: Tests for `BracketEVES` class..
class_docstr_tok: ["Tests","for","`","BracketEVES","`","class",".."]
docstr: Verify mutated candidates is generated correctly.
code: def test_mutate_population(
      self, bracket: BracketEVES, rung_3: RungDict
  ):
      """Verify mutated candidates is generated correctly."""
      red_team = [0, 2]
      blue_team = [1, 3]
      population_range = 4
      rung_trials = list(rung_3["results"].values())
      for trial_index in range(4):
          objective, trial = rung_trials[trial_index]
  
          bracket.owner.performance[trial_index] = objective
          for ith_dim in [1, 2]:
              bracket.owner.population[ith_dim][
                  trial_index
              ] = trial.params[bracket.owner.space[ith_dim].name]
  
      org_data = np.stack(
          (
              list(bracket.owner.population.values())[0],
              list(bracket.owner.population.values())[1],
          ),
          axis=0,
      ).T
  
      org_data = copy.deepcopy(org_data)
  
      bracket._mutate_population(
          red_team,
          blue_team,
          rung_3["results"],
          population_range,
          fidelity=2,
      )
  
      mutated_data = np.stack(
          (
              list(bracket.owner.population.values())[0],
              list(bracket.owner.population.values())[1],
          ),
          axis=0,
      ).T
  
      # Winner team will be [0, 2], so [0, 2] will be remained, [1, 3] will be mutated.
      assert org_data.shape == mutated_data.shape
      assert (mutated_data[0] == org_data[0]).all()
      assert (mutated_data[2] == org_data[2]).all()
      assert (mutated_data[1] != org_data[1]).any()
      assert (mutated_data[3] != org_data[3]).any()
      assert (mutated_data[1] != org_data[0]).any()
      assert (mutated_data[3] != org_data[2]).any()
  
      # For each individual, mutation occurs in only one dimension chosen from two.
      if mutated_data[1][0] != org_data[0][0]:
          assert mutated_data[1][1] == org_data[0][1]
      else:
          assert mutated_data[1][1] != org_data[0][1]
  
      if mutated_data[3][0] != org_data[2][0]:
          assert mutated_data[3][1] == org_data[2][1]
      else:
          assert mutated_data[3][1] != org_data[2][1]
  
imports: from __future__ import annotations
  import copy
  from typing import ClassVar
  import numpy
  import pytest
  from test_hyperband import create_rung_from_points, create_trial_for_hb
  from orion.algo.evolution_es import BracketEVES, BudgetTuple, EvolutionES, compute_budgets
  from orion.algo.hyperband import RungDict
  from orion.algo.space import Fidelity, Real, Space
  from orion.core.utils import backward
  from orion.core.worker.trial import Trial
  from orion.testing.algo import BaseAlgoTests, TestPhase, _are_equal
  from orion.testing.trial import create_trial
label_desc: Use image node_id 2 for calling the TestBracketEVES obj's underlying member method code with example usage: obj.test_mutate_population(bracket, rung_3) without return types