InstituteforDiseaseModeling / covasim

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

Aggregate Patterns to integrate domain object boundaries in Utils.py #335

Closed Utkarsh333 closed 2 years ago

Utkarsh333 commented 3 years ago

What my code does?

This new add-on applies aggregate pattern on utils.py by organizing functions such as compute__viral_load, sample, and Poisson into classes defined by characteristics of the work they perform. The init class here being the root as it holds the method sample which draws a sample based on the inputs provided by the user.

### What does it looks like?

There are namely five classes to be added to divide the code. init for initiating the sample (serving as the root for aggregate pattern), compute_infects for organizing compute functions, math_functions for organizing all the mathematical operations being performed on the set, subset_selection for operations based on sets, and array_ops for operations based on various input arrays.

Why is this a good idea?

This pull request is an attempt for me to practice applying aggregate design patterns to established and reputed code libraries such as covasim. I'm a final-year computer science student so please highlight and correct the rookie mistakes I would have made. I hope this commit helps in moving this project further. :)