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

Logistic Growth Function and Tests #16

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

nsryan2
Copy link
Member

@nsryan2 nsryan2 commented Jul 22, 2021

This PR adds the capability for a logistic growth model and closes #11.
I based this off of the website in the issue and the wikipedia page.

@pep8speaks
Copy link

pep8speaks commented Jul 22, 2021

Hello @nsryan2! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-07-23 15:34:43 UTC

@nsryan2 nsryan2 requested a review from samgdotson July 22, 2021 21:04
@nsryan2 nsryan2 added Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:1-Beginner This issue does not require expert knowledge and may be a good issue for new contributors. Priority:2-Normal This work is important and should be completed ASAP. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Feature New feature or feature request labels Jul 22, 2021
@nsryan2 nsryan2 removed the request for review from samgdotson July 22, 2021 21:09
@nsryan2 nsryan2 requested a review from samgdotson July 22, 2021 21:15
Copy link
Collaborator

@samgdotson samgdotson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this PR! It looks good. I've requested some minor changes and ask that you find another more "pythonic" way to calculate the values for logistic growth (rather than a for-loop).

Finally, don't forget to update the documentation! If it says "TODO: add logistic" and you've done it, ditch that comment!

I'll merge once these changes are made. You can use the "add suggestion to batch" button to reduce the number of emails you send with each change.

pygenesys/tests/utils_tests/test_growth_model.py Outdated Show resolved Hide resolved
pygenesys/tests/utils_tests/test_growth_model.py Outdated Show resolved Hide resolved
pygenesys/tests/utils_tests/test_growth_model.py Outdated Show resolved Hide resolved
pygenesys/tests/utils_tests/test_growth_model.py Outdated Show resolved Hide resolved
pygenesys/tests/utils_tests/test_growth_model.py Outdated Show resolved Hide resolved
Comment on lines 131 to 134
for year in years:
growth = cap/(1 + np.exp(-growth_rate * (year - sigmoid)))
growth_data.append(growth)
np.asarray(growth_data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments

  1. for loops are slow. can you find a way to do this without using a for loop? (see linear and exponential growth models for examples -- i like lambda functions but pep8 doesn't like them for some reason)
  2. By using a for-loop, the style of this function is different than the style of the other functions. can you match the styles?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if you don't introduce growth_data as a list, there is no reason to convert it to an array. The function will be applied to years which is already an np.array.

Copy link
Member Author

@nsryan2 nsryan2 Jul 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, I can switch it to match the style of the others!

pygenesys/tests/utils_tests/test_growth_model.py Outdated Show resolved Hide resolved
pygenesys/tests/utils_tests/test_growth_model.py Outdated Show resolved Hide resolved
@nsryan2
Copy link
Member Author

nsryan2 commented Jul 23, 2021

@samgdotson Should be all good to go! Thanks for the feedback

@nsryan2 nsryan2 requested a review from samgdotson June 12, 2024 12:19
@nsryan2
Copy link
Member Author

nsryan2 commented Oct 3, 2024

@samgdotson, any hesitations on getting this merged or closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:1-Beginner This issue does not require expert knowledge and may be a good issue for new contributors. Priority:2-Normal This work is important and should be completed ASAP. Status:5-In Review This issue has been handled, and the solution is being reviewed. (probably as a PR) Type:Feature New feature or feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add logistic growth model to growth_model.py
3 participants