InstituteforDiseaseModeling / covasim

COVID-19 Agent-based Simulator (Covasim): a model for exploring coronavirus dynamics and interventions
https://covasim.org
MIT License
250 stars 223 forks source link

Possible type issue #291

Closed sba5827 closed 3 years ago

sba5827 commented 4 years ago

https://github.com/InstituteforDiseaseModeling/covasim/blob/a55a849b2a1666e866c552356020a85fe7bd521f/covasim/base.py#L1235-L1238

cvu.find_contacts expects an int64 array, but the if statement does not ensure that the datatype is correct

cliffckerr commented 3 years ago

Thanks @sba5827 -- in our 2.0.0 release slated for next week, this issue will be fixed. FYI the fix is simply:

        # Check types
        if not isinstance(inds, np.ndarray):
            inds = sc.promotetoarray(inds)
        if inds.dtype != np.int64: # This is int64 since indices often come from cv.true(), which returns int64
            inds = np.array(inds, dtype=np.int64)
cliffckerr commented 3 years ago

Fixed in version 2.0 (now released)