def test3(self): numpy.random.seed(345672) instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha=-2.35) n = 10000 total_mass, set_of_masses = instance.next_set(n) self.assertAlmostEqual(instance.mass_mean(), 0.35136877959 | units.MSun) self.assertAlmostEqual(total_mass / n, 0.35136877959 | units.MSun, 1) self.assertAlmostEqual(total_mass / n, 0.33999456911 | units.MSun) self.assertAlmostEqual(instance.mass(0.5), set_of_masses.median(), 2)
def test3(self): numpy.random.seed(345672) instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha = -2.35) n = 10000 total_mass, set_of_masses = instance.next_set(n) self.assertAlmostEqual(instance.mass_mean(), 0.35136877959 | units.MSun) self.assertAlmostEqual(total_mass / n, 0.35136877959 | units.MSun, 1) self.assertAlmostEqual(total_mass / n, 0.33999456911 | units.MSun) self.assertAlmostEqual(instance.mass(0.5), set_of_masses.median(), 2)
def test4(self): instance = SalpeterIMF(0.1 | units.MSun, 125 | units.MSun, alpha=-2.35) self.assertAlmostEqual(instance.mass_mean(), 0.353943475903 | units.MSun)
def test1(self): instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha=-2.35) self.assertAlmostEqual(instance.mass_mean().value_in(units.MSun), 0.351, 3)