예제 #1
0
 def test_migration_matrices(self):
     m1 = models.Model()
     m2 = models.Model()
     m1.migration_matrix = [[]]
     self.assertFalse(m1.equals(m2))
     m2.migration_matrix = [[]]
     self.assertTrue(m1.equals(m2))
     mm1 = np.arange(100, dtype=float).reshape(10, 10)
     m1.migration_matrix = mm1
     self.assertFalse(m1.equals(m2))
     m2.migration_matrix = mm1
     self.assertTrue(m1.equals(m2))
     # Perturb the matrix by a tiny bit and see if we're still equal
     mm2 = mm1.copy() + 1e-9
     m2.migration_matrix = mm2
     self.assertFalse(np.all(m1.migration_matrix == m2.migration_matrix))
     self.assertTrue(m1.equals(m2))
     # If we have higher tolerances we catch the differences
     self.assertFalse(m1.equals(m2, atol=1e-10, rtol=1e-9))
예제 #2
0
 def test_model_generation_time(self):
     self.assertTrue(models.Model().generation_time == -1)
     known_models = list(stdpopsim.all_models())
     n = len(known_models)
     for j in range(n):
         self.assertTrue(known_models[j].generation_time > -2)
예제 #3
0
 def test_different_objects(self):
     m1 = models.Model()
     self.assertFalse(m1.equals(self))
     self.assertFalse(m1.equals({}))
     self.assertFalse(m1.equals(None))
예제 #4
0
 def test_default_models(self):
     m1 = models.Model()
     m2 = models.Model()
     self.assertTrue(m1.equals(m2))
예제 #5
0
 def test_known_models(self):
     # All models should be equal to themselves.
     other_model = models.Model()
     for model in stdpopsim.all_models():
         self.assertTrue(model.equals(model))
         self.assertFalse(model.equals(other_model))