mrc-ide / covid-sim

This is the COVID-19 CovidSim microsimulation model developed by the MRC Centre for Global Infectious Disease Analysis hosted at Imperial College, London.
GNU General Public License v3.0
1.23k stars 257 forks source link

Simplify Param::get_micro_cell_index_from_position #402

Closed zlatanvasovic closed 4 years ago

zlatanvasovic commented 4 years ago

If the function doesn't have some hidden logic behind it, then it can be simplified based on the fact that (a + b) % b = a % b + b % b = a % b

matt-gretton-dann commented 4 years ago

The magic is that there is nowhere else ensures that the indices in position are valid. The original function ensures that values in the range [-b, +inf] get mapped to [0, b).

zlatanvasovic commented 4 years ago

Maybe not the best solution to do that, but I understood. Closing.