only construct s_uids if needed
@@ -332,8 +332,9 @@ class Sim(cvbase.BaseSim):
n_susceptible = len(self.people)
# Randomly infect some people (imported infections)
+ if n_import>0:
s_uids = [person.uid for person in self.people.values() if person.susceptible]
- if len(s_uids)>self['n_import'] and self['n_import']>0: # Check there are actually susceptibles
+ if len(s_uids)>n_import: # Make sure there are actually susceptibles to infect
for i in range(int(n_import)):
new_infections += self.people[s_uids[i]].infect(t=t)
