Пример #1
0
 def test_mutate_force_disable(self, centre_allele, spread_allele,
                               mutation_magnitude):
     elem = CentreSpreadElem(centre_allele, spread_allele)
     register_hyperparams({"mu": 0.0, "m": mutation_magnitude})
     elem.mutate()
     centre_value_same = elem._centre_allele == centre_allele
     spread_value_same = elem._spread_allele == spread_allele
     assert centre_value_same and spread_value_same
Пример #2
0
 def test_mutate_force_enable(self, centre_allele, spread_allele,
                              mutation_magnitude):
     orig_centre_value = centre_allele.value
     orig_spread_value = spread_allele.value
     elem = CentreSpreadElem(centre_allele, spread_allele)
     register_hyperparams({"mu": 1.0, "m": mutation_magnitude})
     elem.mutate()
     centre_value_valid = \
         (orig_centre_value - mutation_magnitude) <= elem._centre_allele \
         <= (orig_centre_value + mutation_magnitude)
     spread_value_valid = \
         (orig_spread_value - mutation_magnitude) <= elem._spread_allele \
         <= (orig_spread_value + mutation_magnitude)
     assert centre_value_valid and spread_value_valid
Пример #3
0
 def test_upper(self, centre_allele, spread_allele):
     elem = CentreSpreadElem(centre_allele, spread_allele)
     expected_upper = centre_allele + spread_allele
     assert elem.upper() == expected_upper
Пример #4
0
 def test_lower(self, centre_allele, spread_allele):
     elem = CentreSpreadElem(centre_allele, spread_allele)
     expected_lower = centre_allele - spread_allele
     assert elem.lower() == expected_lower
Пример #5
0
 def test_ne_pos_case_both_diff(self, centre_allele, spread_allele, diff):
     elem = CentreSpreadElem(centre_allele, spread_allele)
     both_diff_elem = \
         CentreSpreadElem(centre_allele + diff,
                          spread_allele + diff)
     assert elem != both_diff_elem
Пример #6
0
 def test_ne_pos_case_diff_spread(self, centre_allele, spread_allele, diff):
     elem = CentreSpreadElem(centre_allele, spread_allele)
     diff_spread_elem = CentreSpreadElem(centre_allele,
                                         spread_allele + diff)
     assert elem != diff_spread_elem
Пример #7
0
 def test_eq_pos_case(self, centre_allele, spread_allele):
     elem = CentreSpreadElem(centre_allele, spread_allele)
     same_elem = CentreSpreadElem(centre_allele, spread_allele)
     assert elem == same_elem