def test_power_law_primary_secondary_zero_below_mmin(self):
     for ii in range(self.n_test):
         parameters = self.power_prior.sample()
         p_m = mass.power_law_primary_secondary_independent(
             self.dataset, **parameters)
         self.assertEqual(
             xp.max(p_m[self.dataset["mass_2"] <= parameters["mmin"]]), 0.0)
 def test_spin_magnitude_normalised(self):
     norms = list()
     for ii in range(self.n_test):
         parameters = self.prior.sample()
         temp = spin.iid_spin_magnitude_beta(self.test_data, **parameters)
         norms.append(trapz(trapz(temp, self.a_array), self.a_array))
     self.assertAlmostEqual(float(xp.max(xp.abs(1 - xp.asarray(norms)))), 0, 1)
 def test_power_law_primary_mass_ratio_zero_above_mmax(self):
     for ii in range(self.n_test):
         parameters = self.power_prior.sample()
         p_m = mass.double_power_law_primary_power_law_mass_ratio(
             self.dataset, **parameters)
         self.assertEqual(
             xp.max(p_m[self.dataset["mass_1"] >= parameters["mmax"]]), 0.0)
Exemple #4
0
 def test_fhf_normalised(self):
     norms = list()
     for _ in range(self.n_test):
         lamb = np.random.uniform(-15, 15)
         p_z = redshift.power_law_redshift(self.test_data, lamb)
         norms.append(trapz(p_z, self.zs))
     self.assertAlmostEqual(xp.max(xp.abs(xp.asarray(norms) - 1)), 0.0)
Exemple #5
0
 def test_two_component_primary_mass_ratio_zero_below_mmin(self):
     m2s = self.dataset["mass_1"] * self.dataset["mass_ratio"]
     for ii in range(self.n_test):
         parameters = self.power_prior.sample()
         parameters.update(self.gauss_prior.sample())
         p_m = mass.two_component_primary_mass_ratio(self.dataset, **parameters)
         self.assertEqual(xp.max(p_m[m2s <= parameters["mmin"]]), 0.0)
 def test_power_law_primary_secondary_zero_above_mmax(self):
     for ii in range(self.n_test):
         parameters = self.power_prior.sample()
         del parameters["beta"]
         p_m = mass.power_law_primary_secondary_identical(
             self.dataset, **parameters)
         self.assertEqual(
             xp.max(p_m[self.dataset["mass_1"] >= parameters["mmax"]]), 0.0)
Exemple #7
0
 def test_iid_matches_independent_tilts(self):
     iid_params = dict(xi_spin=0.5, sigma_spin=0.5)
     ind_params = dict(xi_spin=0.5, sigma_1=0.5, sigma_2=0.5)
     self.assertEquals(0.0, xp.max(
         spin.iid_spin_orientation_gaussian_isotropic(
             self.test_data, **iid_params) -
         spin.independent_spin_orientation_gaussian_isotropic(
             self.test_data, **ind_params)))
Exemple #8
0
 def test_spin_orientation_normalised(self):
     norms = list()
     for ii in range(self.n_test):
         parameters = self.prior.sample()
         temp = spin.iid_spin_orientation_gaussian_isotropic(
             self.test_data, **parameters)
         norms.append(trapz(trapz(temp, self.costilts), self.costilts))
     self.assertAlmostEqual(float(xp.max(xp.abs(1 - xp.asarray(norms)))), 0, 5)
 def test_two_component_primary_secondary_zero_below_mmin(self):
     for ii in range(self.n_test):
         parameters = self.power_prior.sample()
         parameters.update(self.gauss_prior.sample())
         del parameters["beta"]
         p_m = mass.two_component_primary_secondary_identical(
             self.dataset, **parameters)
         self.assertEqual(
             xp.max(p_m[self.dataset["mass_2"] <= parameters["mmin"]]), 0.0)
Exemple #10
0
 def test_iid_matches_independent_magnitudes(self):
     iid_params = self.prior.sample()
     ind_params = dict()
     ind_params.update({key + '_1': iid_params[key] for key in iid_params})
     ind_params.update({key + '_2': iid_params[key] for key in iid_params})
     self.assertEquals(0.0, xp.max(
         spin.iid_spin_magnitude_beta(self.test_data, **iid_params) -
         spin.independent_spin_magnitude_beta(
             self.test_data, **ind_params)))
Exemple #11
0
 def test_iid_matches_independent(self):
     params = self.prior.sample()
     mag_params = {key: params[key] for key in ['amax', 'alpha_chi', 'beta_chi']}
     tilt_params = {key: params[key] for key in ['xi_spin', 'sigma_spin']}
     self.assertEquals(0.0, xp.max(
         spin.iid_spin(self.test_data, **params) -
         spin.iid_spin_magnitude_beta(self.test_data, **mag_params) *
         spin.iid_spin_orientation_gaussian_isotropic(
             self.test_data, **tilt_params)))
 def _run_model_normalisation(self, model, priors):
     norms = list()
     for _ in range(self.n_test):
         p_z = model(self.test_data, **priors.sample())
         norms.append(trapz(p_z, self.zs))
     self.assertAlmostEqual(xp.max(xp.abs(xp.asarray(norms) - 1)), 0.0)
 def test_double_power_law_zero_below_mmin(self):
     for ii in range(self.n_test):
         parameters = self.power_prior.sample()
         del parameters["beta"]
         p_m = mass.double_power_law_primary_mass(self.m1s, **parameters)
         self.assertEqual(xp.max(p_m[self.m1s <= parameters["mmin"]]), 0.0)
def _max_abs_difference(array, comparison):
    return float(xp.max(xp.abs(comparison - xp.asarray(array))))
 def test_power_law_primary_mass_ratio_zero_below_mmin(self):
     m2s = self.dataset['mass_1'] * self.dataset['mass_ratio']
     for ii in range(self.n_test):
         parameters = self.power_prior.sample()
         p_m = mass.power_law_primary_mass_ratio(self.dataset, **parameters)
         self.assertEqual(xp.max(p_m[m2s <= parameters['mmin']]), 0.0)