class_docstr: Test object for unittest of deap/benchmarks.
code: def test_bin2float(self):
      # Correct evaluation of bin2float.
      zero_individual = creator.Individual([0] * 10)
      full_individual = creator.Individual([1] * 10)
      two_individiual = creator.Individual(8 * [0] + [1, 0])
      population = [zero_individual, full_individual, two_individiual]
      fitnesses = map(self.toolbox.evaluate, population)
      for ind, fit in zip(population, fitnesses):
          ind.fitness.values = fit
      assert population[0].fitness.values == (0.0,)
      assert population[1].fitness.values == (1023.0,)
      assert population[2].fitness.values == (2.0,)
  
      # Incorrect evaluation of bin2float.
      wrong_size_individual = creator.Individual(
          [0, 1, 0, 1, 0, 1, 0, 1, 1]
      )
      wrong_population = [wrong_size_individual]
      # It is up the user to make sure that bin2float gets an individual with
      # an adequate length; no exceptions are raised.
      fitnesses = map(self.toolbox.evaluate, wrong_population)
      for ind, fit in zip(wrong_population, fitnesses):
          # In python 2.7 operator.mul works in a different way than in
          # python3. Thus an error occurs in python2.7 but an assignment is
          # correctly executed in python3.
          if sys.version_info < (3,):
              with self.assertRaises(AssertionError):
                  ind.fitness.values = fit
          else:
              assert wrong_population[0].fitness.values == ()
  
file_path: deap/tests/test_benchmarks.py
imports: import sys
  import unittest
  from deap import base
  from deap import creator
  from deap.benchmarks import binary
label_desc: Use image node_id 3 for calling the BenchmarkTest obj's underlying member method code with example usage: obj.test_bin2float() without return types