def test_age_weights_agree_with_analytical_calculation_of_constant_sfr_weights():
    constant_sfr = (1.0 * 1000000000.0)
    log_ages_gyr = (FSPS_LG_AGES - 9)
    ages_gyr = (10 ** log_ages_gyr)
    dt_ages = _jax_get_dt_array(ages_gyr)
    mstar_age_bins = (dt_ages * constant_sfr)
    correct_weights = (mstar_age_bins / mstar_age_bins.sum())
    t_obs = 16.0
    t_table = np.linspace(T_BIRTH_MIN, t_obs, 50000)
    lgt_table = np.log10(t_table)
    mstar_table = (constant_sfr * t_table)
    logsm_table = np.log10(mstar_table)
    lgt_age_bin_edges = _get_lg_age_bin_edges(log_ages_gyr)
    lgt_birth_bin_edges = _get_lgt_birth(t_obs, lgt_age_bin_edges)
    dsps_age_weights = _get_age_weights_from_tables(lgt_birth_bin_edges, lgt_table, logsm_table)
    assert np.allclose(dsps_age_weights, correct_weights, atol=0.01)
def test_age_weights_agree_with_analytical_calculation_of_constant_sfr_weights():
    constant_sfr = (1.0 * 1000000000.0)
    log_ages_gyr = (FSPS_LG_AGES - 9)
    ages_gyr = (10 ** log_ages_gyr)
    dt_ages = _jax_get_dt_array(ages_gyr)
    mstar_age_bins = (dt_ages * constant_sfr)
    correct_weights = (mstar_age_bins / mstar_age_bins.sum())
    t_obs = 16.0
    t_table = np.linspace(T_BIRTH_MIN, t_obs, 50000)
    lgt_table = np.log10(t_table)
    mstar_table = (constant_sfr * t_table)
    logsm_table = np.log10(mstar_table)
    lgt_age_bin_edges = _get_lg_age_bin_edges(log_ages_gyr)
    lgt_birth_bin_edges = _get_lgt_birth(t_obs, lgt_age_bin_edges)
    dsps_age_weights = _get_age_weights_from_tables(lgt_birth_bin_edges, lgt_table, logsm_table)
    assert np.allclose(dsps_age_weights, correct_weights, atol=0.01)