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

Quickstart.ipynb - loading model error #14

Open
krosenfeld-IDM opened this issue Jun 18, 2024 · 3 comments
Open

Quickstart.ipynb - loading model error #14

krosenfeld-IDM opened this issue Jun 18, 2024 · 3 comments

Comments

@krosenfeld-IDM
Copy link
Collaborator

krosenfeld-IDM commented Jun 18, 2024

Error while initializing the model (https://github.com/InstituteforDiseaseModeling/laser/blob/jbloedow/end_of_may_wip/jb/QuickStart.ipynb)

ctx = model.initialize_database() # should really be called "load model"
ctx = model.eula_init( ctx, demographics_settings.eula_age )
csv_writer = report.init()

Error:

---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[2], [line 1](vscode-notebook-cell:?execution_count=2&line=1)
----> [1](vscode-notebook-cell:?execution_count=2&line=1) ctx = model.initialize_database() # should really be called "load model"
      [2](vscode-notebook-cell:?execution_count=2&line=2) ctx = model.eula_init( ctx, demographics_settings.eula_age )
      [3](vscode-notebook-cell:?execution_count=2&line=3) csv_writer = report.init()

File ~/projects/laser/jb/sandbox/sir_numpy_c.py:231, in initialize_database()
    [230](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:230) def initialize_database():
--> [231](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:231)     return load( demographics_settings.pop_file )

File ~/projects/laser/jb/sandbox/sir_numpy_c.py:180, in load(pop_file)
    [178](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:178) unborn = {header: [] for i, header in enumerate(headers)}
    [179](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:179) global unborn_end_idx 
--> [180](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:180) sir_numpy.add_expansion_slots( unborn, num_slots=settings.expansion_slots )
    [181](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:181) unborn_end_idx = int(settings.expansion_slots)
    [183](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy_c.py:183) data = {header: data[:, i] for i, header in enumerate(headers)}

File ~/projects/laser/jb/sandbox/sir_numpy.py:78, in add_expansion_slots(columns, num_slots)
     [76](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:76) print( f"Adding {num_slots} expansion slots for future babies." )
     [77](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:77) new_ids = [ x for x in range( num_slots ) ]
---> [78](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:78) new_nodes = np.ones( num_slots, dtype=np.uint32 )*-1
     [79](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:79) new_ages = np.ones( num_slots, dtype=np.float32 )*-1
     [80](https://vscode-remote+ssh-002dremote-002bipapvwks23-002elinux-002eidm-002ectr.vscode-resource.vscode-cdn.net/home/krosenfeld/projects/laser/jb/sandbox/~/projects/laser/jb/sandbox/sir_numpy.py:80) new_infected = np.zeros( num_slots, dtype=bool )

OverflowError: Python integer -1 out of bounds for uint32

Machine RAM: MemTotal: 16371640 kB

@krosenfeld-IDM
Copy link
Collaborator Author

I think this has to do with using the np.uint32 here:

new_nodes = np.ones( num_slots, dtype=np.uint32 )*-1

krosenfeld-IDM added a commit that referenced this issue Jun 18, 2024
krosenfeld-IDM added a commit to krosenfeld-IDM/laser that referenced this issue Jun 18, 2024
@jonathanhhb
Copy link
Collaborator

There are a bunch of associated changes that should probably go along with this fix. They are present in jb_modulify branch, which is also installable as idmlaser==0.0.1.

@krosenfeld-IDM
Copy link
Collaborator Author

ok, that's helpful to know. It makes the most sense to me to have both @KevinMcCarthyAtIDM and myself working off of the same branch (or as close as possible) for this loop. I don't plan to change branches at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants