def time_deaths_np(): lx = np.array(gbd_example.us_male_lx_one()) qx = np.array(gbd_example.us_male_qx_one()) deaths_time = timeit.timeit(stmt="deaths_np(lx, qx)", globals={ **globals(), **locals() }) print("Deaths_np takes {} s".format(deaths_time))
def compare_list_array(): lx = gbd_example.us_male_lx_one() qx = gbd_example.us_male_qx_one() lx_np = np.array(lx) qx_np = np.array(qx) print("add lx {}".format(lx + lx)) print("mult lx {}".format(lx * 3)) print("add lx_np {}".format(lx_np + lx_np)) print("mult lx_np {}".format(lx_np * 3)) print("mult lx_np {}".format(lx_np * qx_np))
def examine_input_data(): years = gbd_example.years() age_groups = gbd_example.age_groups() lx = gbd_example.us_male_lx_one() qx = gbd_example.us_male_qx_one() LOGGER.info("All years: {}".format(", ".join(str(y) for y in years))) LOGGER.info("Age group count: {}".format(len(age_groups))) LOGGER.debug("lx males 2010 {}".format(lx)) LOGGER.debug("qx males 2010 {}".format(qx)) for idx in range(len(lx)): print(lx[idx], lx[idx] * qx[idx])
def test_calculate_death(): dx = deaths(gbd_example.us_male_lx_one(), gbd_example.us_male_qx_one()) assert np.allclose(dx, gbd_example.us_male_dx_one())