Exemplo n.º 1
0
 def test_calc_pop_avg(self):
     population = [[1, 2, 3], [2, 5, 9], [6, 7, 10]]
     self.assertEqual(ps4.calc_pop_avg(population, 0), 2, 'expected 2')
     self.assertEqual(ps4.calc_pop_avg(population, 1), 16 / 3,
                      'expected 5 1/3')
     self.assertEqual(ps4.calc_pop_avg(population, 2), 23 / 3,
                      'expected 7 2/3')
     populations = np.array([[1, 2, 3], [10, 20, 30]])
     self.assertEqual(ps4.calc_pop_avg(populations, 0), 2)
     self.assertEqual(ps4.calc_pop_avg(populations, 1), 20)
Exemplo n.º 2
0
 def test_calc_pop_avg(self):
     avg = 762.5
     calc_avg = ps4.calc_pop_avg(population, 299)
     print(calc_avg)
     self.assertTrue(
         avg - 1 < calc_avg < avg + 1,
         "Got incorrect population average {} instead of {}.".format(
             calc_avg, avg))