Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in cv.make_synthpop #376

Closed
cmerenstein opened this issue Dec 7, 2021 · 2 comments
Closed

Error in cv.make_synthpop #376

cmerenstein opened this issue Dec 7, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@cmerenstein
Copy link

Hello,

I think there's an error in the newest version cv.make_synthpop, or at least a change in behavior that I can't find documentation on.

I made a minimal example of the issue in this colab: https://colab.research.google.com/drive/1fG8MxWYqhv44wpEDg0QzRpL1ySysfSp6?usp=sharing
which gets an error when running on the newest version of covasim, but not when installed with version 3.0.7. Below is more information on the bug:

I am trying to use make_synthpop to add a population to a Sim object, with a synthpops population dict as my reference. I had been using this in a script previously, but with the latest update it no longer works, giving me an error originating in the "make_random_contacts" function.

The error message is:

TypeError                                 Traceback (most recent call last)

<ipython-input-6-465ff658c7d6> in <module>()
      3                         use_waning=True))
      4 
----> 5 sim_household.popdict = cv.make_synthpop(sim=sim_household,population=sc.dcp(pop_dict))

1 frames

/usr/local/lib/python3.7/dist-packages/covasim/population.py in make_random_contacts(pop_size, n, overshoot, dispersion, mapping)
    223 
    224     # Precalculate contacts
--> 225     n_all_contacts  = int(pop_size*n*overshoot) # The overshoot is used so we won't run out of contacts if the Poisson draws happen to be higher than the expected value
    226     all_contacts    = cvu.choose_r(max_n=pop_size, n=n_all_contacts) # Choose people at random
    227     if dispersion is None:

TypeError: unsupported operand type(s) for *: 'int' and 'dict'
@cliffckerr cliffckerr added the bug Something isn't working label Dec 13, 2021
@cliffckerr
Copy link
Member

cliffckerr commented Dec 13, 2021

Well spotted @cmerenstein , we'll fix this in the 3.1.2 release later this week. Thanks!

@cliffckerr
Copy link
Member

cliffckerr commented Jan 17, 2022

Thanks for your patience @cmerenstein and apologies it took much longer than we hoped to fix! We ended up completely revamping the way population loading/saving is handled, but the new system should be much easier to use. You can now do things like:

import covasim as cv
import synthpops as sp

n = 2e3
people = sp.Pop(n=n)
sim = cv.Sim(pop_size=n, pop_type='synthpops', people=people).run()
sim.people.plot()
sim.plot()

Full changes listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants