Skip to content

Commit f4cf120

Browse files
committed
Overwrite any changes to hiv and tb file
1 parent 1b83823 commit f4cf120

File tree

2 files changed

+23
-108
lines changed

2 files changed

+23
-108
lines changed

src/tlo/methods/hiv.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,37 +1682,6 @@ def do_at_generic_first_appt(
16821682
# Main Polling Event
16831683
# ---------------------------------------------------------------------------
16841684

1685-
class HivPollingEventForDataGeneration(RegularEvent, PopulationScopeEventMixin):
1686-
""" The HIV Polling Events for Data Generation
1687-
* Ensures that
1688-
"""
1689-
1690-
def __init__(self, module):
1691-
super().__init__(
1692-
module, frequency=DateOffset(years=120)
1693-
) # repeats every 12 months, but this can be changed
1694-
1695-
def apply(self, population):
1696-
1697-
df = population.props
1698-
1699-
# Make everyone who is alive and not infected (no-one should be) susceptible
1700-
susc_idx = df.loc[
1701-
df.is_alive
1702-
& ~df.hv_inf
1703-
].index
1704-
1705-
n_susceptible = len(susc_idx)
1706-
print("Number of individuals susceptible", n_susceptible)
1707-
# Schedule the date of infection for each new infection:
1708-
for i in susc_idx:
1709-
date_of_infection = self.sim.date + pd.DateOffset(
1710-
# Ensure that individual will be infected before end of sim
1711-
days=self.module.rng.randint(0, 365*(int(self.sim.end_date.year - self.sim.date.year)+1))
1712-
)
1713-
self.sim.schedule_event(
1714-
HivInfectionEvent(self.module, i), date_of_infection
1715-
)
17161685

17171686
class HivRegularPollingEvent(RegularEvent, PopulationScopeEventMixin):
17181687
""" The HIV Regular Polling Events
@@ -1734,7 +1703,6 @@ def apply(self, population):
17341703
fraction_of_year_between_polls = self.frequency.months / 12
17351704
beta = p["beta"] * fraction_of_year_between_polls
17361705

1737-
17381706
# ----------------------------------- HORIZONTAL TRANSMISSION -----------------------------------
17391707
def horizontal_transmission(to_sex, from_sex):
17401708
# Count current number of alive 15-80 year-olds at risk of transmission
@@ -1810,7 +1778,6 @@ def horizontal_transmission(to_sex, from_sex):
18101778
HivInfectionEvent(self.module, idx), date_of_infection
18111779
)
18121780

1813-
18141781
# ----------------------------------- SPONTANEOUS TESTING -----------------------------------
18151782
def spontaneous_testing(current_year):
18161783

@@ -1935,8 +1902,6 @@ def vmmc_for_child():
19351902
vmmc_for_child()
19361903

19371904

1938-
1939-
19401905
# ---------------------------------------------------------------------------
19411906
# Natural History Events
19421907
# ---------------------------------------------------------------------------

src/tlo/methods/tb.py

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -864,31 +864,29 @@ def initialise_population(self, population):
864864
df["tb_on_ipt"] = False
865865
df["tb_date_ipt"] = pd.NaT
866866

867-
868867
# # ------------------ infection status ------------------ #
869-
if self.sim.generate_event_chains is False or self.sim.generate_event_chains is None:
870-
# WHO estimates of active TB for 2010 to get infected initial population
871-
# don't need to scale or include treated proportion as no-one on treatment yet
872-
inc_estimates = p["who_incidence_estimates"]
873-
incidence_year = (inc_estimates.loc[
874-
(inc_estimates.year == self.sim.date.year), "incidence_per_100k"
875-
].values[0]) / 100_000
876-
877-
incidence_year = incidence_year * p["scaling_factor_WHO"]
878-
879-
self.assign_active_tb(
880-
population,
881-
strain="ds",
882-
incidence=incidence_year)
883-
884-
self.assign_active_tb(
885-
population,
886-
strain="mdr",
887-
incidence=incidence_year * p['prop_mdr2010'])
888-
889-
self.send_for_screening_general(
890-
population
891-
) # send some baseline population for screening
868+
# WHO estimates of active TB for 2010 to get infected initial population
869+
# don't need to scale or include treated proportion as no-one on treatment yet
870+
inc_estimates = p["who_incidence_estimates"]
871+
incidence_year = (inc_estimates.loc[
872+
(inc_estimates.year == self.sim.date.year), "incidence_per_100k"
873+
].values[0]) / 100_000
874+
875+
incidence_year = incidence_year * p["scaling_factor_WHO"]
876+
877+
self.assign_active_tb(
878+
population,
879+
strain="ds",
880+
incidence=incidence_year)
881+
882+
self.assign_active_tb(
883+
population,
884+
strain="mdr",
885+
incidence=incidence_year * p['prop_mdr2010'])
886+
887+
self.send_for_screening_general(
888+
population
889+
) # send some baseline population for screening
892890

893891
def initialise_simulation(self, sim):
894892
"""
@@ -901,10 +899,8 @@ def initialise_simulation(self, sim):
901899
sim.schedule_event(TbActiveEvent(self), sim.date)
902900
sim.schedule_event(TbRegularEvents(self), sim.date)
903901
sim.schedule_event(TbSelfCureEvent(self), sim.date)
904-
905902
sim.schedule_event(TbActiveCasePoll(self), sim.date + DateOffset(years=1))
906903

907-
908904
# 2) log at the end of the year
909905
# Optional: Schedule the scale-up of programs
910906
if self.parameters["type_of_scaleup"] != 'none':
@@ -1406,53 +1402,6 @@ def is_subset(col_for_set, col_for_subset):
14061402
# # TB infection event
14071403
# # ---------------------------------------------------------------------------
14081404

1409-
class TbActiveCasePollGenerateData(RegularEvent, PopulationScopeEventMixin):
1410-
"""The Tb Regular Poll Event for Data Generation for assigning active infections
1411-
* selects everyone to develop an active infection and schedules onset of active tb
1412-
sometime during the simulation
1413-
"""
1414-
1415-
def __init__(self, module):
1416-
super().__init__(module, frequency=DateOffset(years=120))
1417-
1418-
def apply(self, population):
1419-
1420-
df = population.props
1421-
now = self.sim.date
1422-
rng = self.module.rng
1423-
# Make everyone who is alive and not infected (no-one should be) susceptible
1424-
susc_idx = df.loc[
1425-
df.is_alive
1426-
& (df.tb_inf != "active")
1427-
].index
1428-
1429-
len(susc_idx)
1430-
1431-
middle_index = len(susc_idx) // 2
1432-
1433-
# Will equally split two strains among the population
1434-
list_ds = susc_idx[:middle_index]
1435-
list_mdr = susc_idx[middle_index:]
1436-
1437-
# schedule onset of active tb. This will be equivalent to the "Onset", so it
1438-
# doesn't matter how long after we have decided which infection this is.
1439-
for person_id in list_ds:
1440-
date_progression = now + pd.DateOffset(
1441-
# At some point during their lifetime, this person will develop TB
1442-
days=self.module.rng.randint(0, 365*(int(self.sim.end_date.year - self.sim.date.year)+1))
1443-
)
1444-
# set date of active tb - properties will be updated at TbActiveEvent poll daily
1445-
df.at[person_id, "tb_scheduled_date_active"] = date_progression
1446-
df.at[person_id, "tb_strain"] = "ds"
1447-
1448-
for person_id in list_mdr:
1449-
date_progression = now + pd.DateOffset(
1450-
days=rng.randint(0, 365*int(self.sim.end_date.year - self.sim.start_date.year + 1))
1451-
)
1452-
# set date of active tb - properties will be updated at TbActiveEvent poll daily
1453-
df.at[person_id, "tb_scheduled_date_active"] = date_progression
1454-
df.at[person_id, "tb_strain"] = "mdr"
1455-
14561405

14571406
class TbActiveCasePoll(RegularEvent, PopulationScopeEventMixin):
14581407
"""The Tb Regular Poll Event for assigning active infections
@@ -1527,6 +1476,7 @@ def apply(self, population):
15271476
self.module.update_parameters_for_program_scaleup()
15281477
# note also culture test used in target/max scale-up in place of clinical dx
15291478

1479+
15301480
class TbActiveEvent(RegularEvent, PopulationScopeEventMixin):
15311481
"""
15321482
* check for those with dates of active tb onset within last time-period

0 commit comments

Comments
 (0)