Skip to content

Commit

Permalink
remove most recent year import
Browse files Browse the repository at this point in the history
  • Loading branch information
hussain-jafari committed Feb 20, 2024
1 parent 3089abd commit ab6b1c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"pytest",
"pytest-mock",
"hypothesis",
"vivarium-gbd-access",
]

doc_requirements = [
Expand Down
6 changes: 3 additions & 3 deletions src/vivarium_inputs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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))
)
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions src/vivarium_inputs/utility_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/vivarium_inputs/validation/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ab6b1c3

Please sign in to comment.