Skip to content

Commit

Permalink
Merge branch 'develop' into webapp-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffckerr committed Mar 22, 2020
2 parents 4f67a60 + 00dfe12 commit 889fcc4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
17 changes: 9 additions & 8 deletions covasim/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,22 @@ def init_people(self, verbose=None, id_len=6):
print(f'Creating {self["n"]} people...')

# Create the people -- just placeholders if we're using actual data
self.people = {} # Dictionary for storing the people -- use plain dict since faster than odict
for p in range(int(self['n'])): # Loop over each person
people = {} # Dictionary for storing the people -- use plain dict since faster than odict
n_people = int(self['n'])
uids = sc.uuid(which='ascii', n=n_people, length=id_len)
for p in range(n_people): # Loop over each person
uid = uids[p]
if self['usepopdata']:
age,sex,cfr = -1, -1, -1 # These get overwritten later
else:
age,sex,cfr = cvpars.get_age_sex(cfr_by_age=self['cfr_by_age'], default_cfr=self['default_cfr'], use_data=False)
uid = None
while not uid or uid in self.people.keys(): # Avoid duplicates!
uid = sc.uuid(length=id_len)

person = Person(age=age, sex=sex, cfr=cfr, uid=uid) # Create the person
self.people[person.uid] = person # Save them to the dictionary
people[uid] = person # Save them to the dictionary

# Store all the UIDs as a list
self.uids = list(self.people.keys())
# Store UIDs and people
self.uids = uids
self.people = people

# Make the contact matrix
if not self['usepopdata']:
Expand Down
7 changes: 5 additions & 2 deletions tests/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import covasim as cova

sim = cova.Sim()
to_profile = 'sim' # Must be one of the options listed below...currently only 1
sim['n_days'] = 10
to_profile = 'init_people' # Must be one of the options listed below...currently only 1

func_options = {'sim': sim.run,
func_options = {'run': sim.run,
'initialize': sim.initialize,
'init_people': sim.init_people,
}

sc.profile(run=sim.run, follow=func_options[to_profile])

0 comments on commit 889fcc4

Please sign in to comment.