Skip to content

Commit

Permalink
Npi none fix (#4)
Browse files Browse the repository at this point in the history
* check that NPI is not None before iterating over NPIs

* attempt: fix iterating NoneType object

* check if inputted NPI's are iterable before iterating

* none type iterator fix

---------

Co-authored-by: Joseph Hendrix <[email protected]>
Co-authored-by: Joseph Hendrix <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2024
1 parent 06e98f5 commit 56be423
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/models/treatments/NonPharmaInterventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,23 @@ def pre_process(self, network:Type[Network]):
Iterate over each NPI and calculate total effectiveness for each age
group by Day & County
"""
for npi in self.npis:

npi_day = int(npi['day'])
npi_duration = int(npi['duration'])
npi_location = npi['location']
npi_index_list = self._location_to_index_list(npi_location, network)
npi_effectiveness = [float(x) for x in npi['effectiveness']]

logging.debug(f'npi_index_list = {npi_index_list}')
logging.debug(f'npi_day = {npi_day}; npis_length = {self.length}')
logging.debug(f'duration = {npi_duration}; effectiveness = {npi_effectiveness}')

for i in range(npi_day, npi_day+npi_duration):
if (i > self.length-1): continue
for j in npi_index_list:
self._add_percent_effectiveness(i, int(j), npi_effectiveness)
if self.npis is not None:
for npi in self.npis:

npi_day = int(npi['day'])
npi_duration = int(npi['duration'])
npi_location = npi['location']
npi_index_list = self._location_to_index_list(npi_location, network)
npi_effectiveness = [float(x) for x in npi['effectiveness']]

logging.debug(f'npi_index_list = {npi_index_list}')
logging.debug(f'npi_day = {npi_day}; npis_length = {self.length}')
logging.debug(f'duration = {npi_duration}; effectiveness = {npi_effectiveness}')

for i in range(npi_day, npi_day+npi_duration):
if (i > self.length-1): continue
for j in npi_index_list:
self._add_percent_effectiveness(i, int(j), npi_effectiveness)
return


Expand Down

0 comments on commit 56be423

Please sign in to comment.