Skip to content

Commit

Permalink
Added ctypes call to ri.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Bloedow committed Aug 2, 2024
1 parent a90cacd commit 080367c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions nnmm/ri.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import numpy as np
import numba as nb
import ctypes

lib = ctypes.CDLL('./libri.so')

# Define the argument types for the C function
lib.update_susceptibility_based_on_ri_timer.argtypes = [
ctypes.c_uint32, # count
np.ctypeslib.ndpointer(dtype=np.uint16, ndim=1, flags='C_CONTIGUOUS'), # ri_timer
np.ctypeslib.ndpointer(dtype=np.uint8, ndim=1, flags='C_CONTIGUOUS'), # susceptibility
np.ctypeslib.ndpointer(dtype=np.uint16, ndim=1, flags='C_CONTIGUOUS'), # age_at_vax
np.ctypeslib.ndpointer(dtype=np.int32, ndim=1, flags='C_CONTIGUOUS'), # dob
ctypes.c_int64 # tick
]


def add(model, count_births, istart, iend):
# Randomly set ri_timer for coverage fraction of agents to a value between 8.5*30.5 and 9.5*30.5 days
Expand Down Expand Up @@ -55,6 +69,10 @@ def add_with_ips(model, count_births, istart, iend):

return

def _update_susceptibility_based_on_ri_timer(count, ri_timer, susceptibility, age_at_vax, dob, tick):
lib.update_susceptibility_based_on_ri_timer(count, ri_timer, susceptibility, age_at_vax, dob, tick)

"""
# Define the function to decrement ri_timer and update susceptibility
@nb.njit((nb.uint32, nb.uint16[:], nb.uint8[:], nb.uint16[:], nb.int32[:], nb.int64 ), parallel=True)
def _update_susceptibility_based_on_ri_timer(count, ri_timer, susceptibility, age_at_vax, dob, tick):
Expand All @@ -67,3 +85,5 @@ def _update_susceptibility_based_on_ri_timer(count, ri_timer, susceptibility, ag
susceptibility[i] = 0
#age_at_vax[i] = tick-dob[i] # optional for reporting
"""

0 comments on commit 080367c

Please sign in to comment.