code: def test_population_initiation(self):
      # test the different modes of population initiation
  
      # init must be either 'latinhypercube' or 'random'
      # raising ValueError is something else is passed in
      assert_raises(
          ValueError,
          DifferentialEvolutionSolver,
          *(rosen, self.bounds),
          **{"init": "rubbish"},
      )
  
      solver = DifferentialEvolutionSolver(rosen, self.bounds)
  
      # check that population initiation:
      # 1) resets _nfev to 0
      # 2) all population energies are np.inf
      solver.init_population_random()
      assert_equal(solver._nfev, 0)
      assert_(np.all(np.isinf(solver.population_energies)))
  
      solver.init_population_lhs()
      assert_equal(solver._nfev, 0)
      assert_(np.all(np.isinf(solver.population_energies)))
  
      # we should be able to initialise with our own array
      population = np.linspace(-1, 3, 10).reshape(5, 2)
      solver = DifferentialEvolutionSolver(
          rosen,
          self.bounds,
          init=population,
          strategy="best2bin",
          atol=0.01,
          seed=1,
          popsize=5,
      )
  
      assert_equal(solver._nfev, 0)
      assert_(np.all(np.isinf(solver.population_energies)))
      assert_(solver.num_population_members == 5)
      assert_(solver.population_shape == (5, 2))
  
      # check that the population was initialised correctly
      unscaled_population = np.clip(
          solver._unscale_parameters(population), 0, 1
      )
      assert_almost_equal(solver.population[:5], unscaled_population)
  
      # population values need to be clipped to bounds
      assert_almost_equal(np.min(solver.population[:5]), 0)
      assert_almost_equal(np.max(solver.population[:5]), 1)
  
      # shouldn't be able to initialise with an array if it's the wrong shape
      # this would have too many parameters
      population = np.linspace(-1, 3, 15).reshape(5, 3)
      assert_raises(
          ValueError,
          DifferentialEvolutionSolver,
          *(rosen, self.bounds),
          **{"init": population},
      )
  
imports: import multiprocessing
  from scipy.optimize import _differentialevolution
  from scipy.optimize._differentialevolution import DifferentialEvolutionSolver
  from scipy.optimize import differential_evolution
  import numpy
  from scipy.optimize import rosen
  from numpy.testing import assert_equal, assert_allclose, assert_almost_equal, assert_string_equal, assert_
  from pytest import raises, warns
label_desc: Use image node_id 32 for calling the TestDifferentialEvolutionSolver obj's underlying member method code with example usage: obj.test_population_initiation() without return types