From ab6b1c3ad14ff88c60e4130cac01f0f1be2781af Mon Sep 17 00:00:00 2001 From: hussain-jafari Date: Tue, 20 Feb 2024 10:23:06 -0800 Subject: [PATCH] remove most recent year import --- setup.py | 1 - src/vivarium_inputs/core.py | 6 +++--- src/vivarium_inputs/utility_data.py | 4 ++++ src/vivarium_inputs/validation/sim.py | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index af0c7f59..9c634659 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,6 @@ "pytest", "pytest-mock", "hypothesis", - "vivarium-gbd-access", ] doc_requirements = [ diff --git a/src/vivarium_inputs/core.py b/src/vivarium_inputs/core.py index b62928b4..dc22a5bd 100644 --- a/src/vivarium_inputs/core.py +++ b/src/vivarium_inputs/core.py @@ -5,7 +5,6 @@ import pandas as pd from gbd_mapping import Cause, Covariate, Etiology, RiskFactor, Sequela, causes from loguru import logger -from vivarium_gbd_access.constants import MOST_RECENT_YEAR from vivarium_inputs import extract, utilities, utility_data from vivarium_inputs.globals import ( @@ -163,7 +162,8 @@ def get_disability_weight( if entity.kind == "cause": data = utility_data.get_demographic_dimensions(location_id, draws=True, value=0.0) if not get_all_years: - data = data.query("year_id==@MOST_RECENT_YEAR") + most_recent_year = utility_data.get_most_recent_year() + data = data.query("year_id==@most_recent_year") data = data.set_index( utilities.get_ordered_index_cols(data.columns.difference(DRAW_COLUMNS)) ) @@ -198,7 +198,7 @@ def get_disability_weight( ) # add year id with single year so normalization doesn't fill in all years if not get_all_years: - data["year_id"] = MOST_RECENT_YEAR + data["year_id"] = utility_data.get_most_recent_year() data = utilities.normalize(data) cause = [c for c in causes if c.sequelae and entity in c.sequelae][0] diff --git a/src/vivarium_inputs/utility_data.py b/src/vivarium_inputs/utility_data.py index 8388b950..51d7eb79 100644 --- a/src/vivarium_inputs/utility_data.py +++ b/src/vivarium_inputs/utility_data.py @@ -11,6 +11,10 @@ def get_estimation_years(*_, **__) -> pd.Series: return data +def get_most_recent_year() -> int: + return get_estimation_years().max() + + def get_year_block(*_, **__) -> pd.DataFrame: estimation_years = get_estimation_years() year_block = pd.DataFrame( diff --git a/src/vivarium_inputs/validation/sim.py b/src/vivarium_inputs/validation/sim.py index 01fea99b..7ae38923 100644 --- a/src/vivarium_inputs/validation/sim.py +++ b/src/vivarium_inputs/validation/sim.py @@ -11,7 +11,6 @@ Sequela, causes, ) -from vivarium_gbd_access.constants import MOST_RECENT_YEAR from vivarium_inputs import utilities, utility_data from vivarium_inputs.globals import ( @@ -148,8 +147,9 @@ def validate_for_simulation( if measure not in validators: raise NotImplementedError() + most_recent_year = utility_data.get_most_recent_year() context_args["years"] = pd.DataFrame( - {"year_start": MOST_RECENT_YEAR, "year_end": MOST_RECENT_YEAR + 1}, index=[0] + {"year_start": most_recent_year, "year_end": most_recent_year + 1}, index=[0] ) context = SimulationValidationContext(location, **context_args) validators[measure](data, entity, context)