Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code duplication across functions #15

Closed
patrickbarks opened this issue Feb 26, 2018 · 0 comments
Closed

Code duplication across functions #15

patrickbarks opened this issue Feb 26, 2018 · 0 comments
Assignees
Labels
devel-resolved Issue resolved in devel branch

Comments

@patrickbarks
Copy link
Collaborator

Related to #14 , there's a fair amount of code duplication across a few Rage functions:

  • makeLifeTable, dEntropy, and kEntropy all use the same loop to calculate survivorship. I believe the loop within longevity is mathematically equivalent (it's finding the age where lx = 0.01), though coded a bit differently.

  • makeLifeTable and dEntropy use the same loops to calculate age-specific fertility (mx) and clonality (cx).

To avoid some of this duplication and make for easier code maintainability, we could perhaps pull some of the duplicated sections into separate internal functions that get called by the user-facing functions when required.

Alternatively, we could keep the lx/mx/cx functions within makeLifeTable, and then re-work dEntropy and kEntropy so that they take a life table or life table components as arguments, instead of transition matrices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devel-resolved Issue resolved in devel branch
Projects
None yet
Development

No branches or pull requests

2 participants