InstituteforDiseaseModeling / covasim

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

Apply aggregate in "Immunity.py" #330

Closed ChimingChen0724 closed 3 years ago

ChimingChen0724 commented 3 years ago

what is this

It is the first time that I contribute to an open source project. I am trying to achieve the "aggregate" design pattern in the project and hopefully simplify the whole structure after those changes.

what I change

In the current version of "Immunity.py", there exists some "calculation" methods and "update_nab" method which have the similar logic but not group together. Therefore, I apply the "aggregate design pattern" to "immunity.py" and create two root classes "Calculation" and "Update_Nab" to store all those methods.

what do I not change

Actually, I also noticed that there are some "decay" methods which can be united together. However, because the author directly import those methods in the "test" files, it is very complex to move and put those methods into a new class. Therefore, I decide to only change the structure of "calculation" and "update_nab" methods.